text:
Q: Web server atack DDOS I have a server (vps) to use as a repository and testing (gitlab and redmine) server. However apache crashed, seeing the /var/log/apache2/error.log have many errors of this type:
[Fri Jan 31 16:07:31.056851 2014] [:error] [pid 1538] [client 63.141.239.204:4740] script '/var/www/ads.php' not found or unable to stat, referer: http://www.wealthsuperman.com/index.php/component/k2/item/1017-3-industry-impacting-innovations-on-the-horizon
[Fri Jan 31 16:07:31.377531 2014] [:error] [pid 1549] [client 216.244.79.163:2282] script '/var/www/ads.php' not found or unable to stat, referer: http://www.movieseeing.com/index.php?option=com_content&view=article&id=2244:bin-aflek-kevin-names-directory&catid=45:superman-movie&Itemid=418
[Fri Jan 31 16:07:31.538993 2014] [:error] [pid 1436] [client 23.88.201.68:4073] script '/var/www/banner_728x90.php' not found or unable to stat, referer: ://www.worldfinancialtoday.com/index.php?option=com_content&view=article&id=481:2011-07-01-23-20-39&catid=41:debt-management&Itemid=224
[Fri Jan 31 16:07:32.267787 2014] [:error] [pid 1573] [client 216.244.87.196:4726] script '/var/www/banner_160x600.php' not found or unable to stat, referer: http://www.sexwomanbaby.com/index.php?option=com_content&view=category&layout=blog&id=37&Itemid=71&limitstart=351
[Fri Jan 31 16:07:32.576526 2014] [:error] [pid 1383] [client 198.50.177.34:3046] script '/var/www/ads.php' not found or unable to stat, referer: http://www.healthlifeways.com/healthy-eating-2/2000-i-want-to-eat-healthy-i-want-to-lose-weight-and-eat-healthy-vegetarian.html
[Fri Jan 31 16:07:34.948099 2014] [:error] [pid 1525] [client 208.115.124.196:4361] script '/var/www/banner_300x250.php' not found or unable to stat, referer: http://www.gamebabygirls.com/index.php?option=com_content&view=article&id=1991:how-to-download-games-onto-your-psp-for-free-free-games-to-download&catid=58:free-game-downloads&Itemid=182
[Fri Jan 31 16:07:35.492746 2014] [:error] [pid 1429] [client 192.187.124.67:3583] script '/var/www/ads.php' not found or unable to stat, referer: http://www.entainmentworld.com/index.php/chicago-entertainment-2/262-ipelinecom-seattle-entertainment
[Fri Jan 31 16:07:35.938016 2014] [:error] [pid 1524] [client 172.246.42.245:1589] script '/var/www/banner_160x600.php' not found or unable to stat, referer: ://www.galacticearthalliance.com/index.php?option=com_content&view=category&layout=blog&id=43&Itemid=226

/var/log/apache2/other_vhosts_access.log
127.0.0.1:80 64.120.60.118 - - [01/Feb/2014:00:49:40 +0000] "GET http://ads.yahoo.com/st?ad_type=iframe&ad_size=728x90&section=4931465&pub_url=${PUB_URL} HTTP/1.0" 404 494 "http://happyhourstravel.com/index.php/international-travel/4088-china-eastern-airline" "Opera/10.60 (Windows NT 5.1; U; en-US) Presto/2.6.30 Version/10.60"
127.0.0.1:80 74.63.197.142 - - [01/Feb/2014:00:49:40 +0000] "GET http://ads.yahoo.com/st?ad_type=iframe&ad_size=300x250&section=3698931&pub_url=${PUB_URL} HTTP/1.0" 404 494 "http://www.mortcard.com/index.php?option=com_content&view=article&id=14:Amount-of-Pay-Earned-for-a-Kindergarten-Teacher--&catid=13" "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6"
127.0.0.1:80 142.54.183.92 - - [01/Feb/2014:00:49:40 +0000] "GET http://ads.yahoo.com/st?ad_type=iframe&ad_size=728x90&section=5245782&pub_url=${PUB_URL} HTTP/1.0" 404 494 "http://www.healthlifeways.com/healthy-eating-2/18-healthy-life/3339-what-is-a-healthy-balanced-diet-what-is-healthy-life.html" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.36 (KHTML, like Gecko) Chrome/13.0.766.0 Safari/534.36"
127.0.0.1:80 216.244.79.171 - - [01/Feb/2014:00:49:40 +0000] "GET http://ads.yahoo.com/st?ad_type=iframe&ad_size=728x90&section=5280785&pub_url=themoviebus.com HTTP/1.0" 404 494 "http://www.themoviebus.com/index.php/37-news/slideshow/67-donec-nec-feugiat-felis" "Mozilla/4.08 [en] (WinNT; U)"
127.0.0.1:80 198.2.200.40 - - [01/Feb/2014:00:49:40 +0000] "GET http://ib.adnxs.com/ttj?id=2023417&position=above HTTP/1.0" 404 494 "http://www.gameuloved.com/?cat=3" "Opera/9.80 (Windows NT 5.1; U; it) Presto/2.7.62 Version/11.00"
127.0.0.1:80 107.148.8.58 - - [01/Feb/2014:00:49:40 +0000] "GET http://ib.adnxs.com/ttj?id=2142019 HTTP/1.0" 404 494 "http://www.new-energy-auto.com/?p=548" "Mozilla/5.0 (Windows; U; Windows NT 6.0; fr-FR) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5"
127.0.0.1:80 63.141.239.206 - - [01/Feb/2014:00:49:40 +0000] "GET http://ad.yieldmanager.com/st?ad_type=pop&ad_size=0x0&section=5073837&banned_pop_types=28&pop_times=1&pop_frequency=86400&pub_url=${PUB_URL} HTTP/1.0" 404 500 "http://www.healthlifeways.com/healthy-eating-2/4591-eat-drink-be-healthy-eat-healthy-magazine.html" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4"
127.0.0.1:80 23.228.234.115 - - [01/Feb/2014:00:49:40 +0000] "GET http://ib.adnxs.com/ttj?id=1165515 HTTP/1.0" 404 494 "http://www.liekkas.com/?tag=pc" "Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"
127.0.0.1:80 199.231.212.25 - - [01/Feb/2014:00:49:41 +0000] "GET http://ib.adnxs.com/ttj?id=2169359&cb=[CACHEBUSTER]&referrer=[REFERRER_URL] HTTP/1.0" 404 494 "://www.twotags.com/o~c-Clothing~a-ap_gender_age_women-24330635_v_neck~b-31515.aspx" "Mozilla/4.75 [en] (Win98; U)"
127.0.0.1:80 137.175.9.44 - - [01/Feb/2014:00:49:42 +0000] "GET http://ads.deliads.com/ttj?id=2069500&referrer=financialgately.com HTTP/1.0" 404 497 "http://www.financialgately.com/?p=748" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b8pre) Gecko/20101114 Firefox/4.0b8pre"
127.0.0.1:80 198.56.202.213 - - [01/Feb/2014:00:49:42 +0000] "GET http://ib.adnxs.com/ttj?id=2168277&position=above HTTP/1.0" 404 494 "http://www.fulleducate.com/?p=723" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; ru-ru) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16"
127.0.0.1:80 198.2.208.247 - - [01/Feb/2014:00:49:42 +0000] "GET http://ib.adnxs.com/ttj?id=2048452&position=above HTTP/1.0" 404 494 "http://www.everyloans.net/?p=562" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.7) Gecko/20100726 CentOS/3.6-3.el5.centos Firefox/3.6.7"
127.0.0.1:80 63.141.244.45 - - [01/Feb/2014:00:49:42 +0000] "GET http://ads.yahoo.com/st?ad_type=iframe&ad_size=300x250&section=5233043&pub_url=probuinessp.com HTTP/1.0" 404 494 "http://probuinessp.com/index.php/small-business-marketing-ideas/" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b6pre) Gecko/20100903 Firefox/4.0b6pre"
127.0.0.1:80 174.34.159.13 - - [01/Feb/2014:00:49:42 +0000] "GET http://ib.adnxs.com/ttj?id=2168373&position=above HTTP/1.0" 404 494 "http://www.searchthenewsofmovie.com/?p=742" "Mozilla/5.0 ArchLinux (X11; U; Linux x86_64; en-US) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.100"
127.0.0.1:80 192.169.85.115 - - [01/Feb/2014:00:49:43 +0000] "GET http://ads.yahoo.com/st?ad_type=iframe&ad_size=728x90&section=5151124&pub_url=${PUB_URL} HTTP/1.0" 404 494 "http://www.salebusinessidea.com/index.php?option=com_content&view=article&id=234:What-Is-a-SAP-Inventory-System?--&catid=119&Itemid=83" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 95; Alexa Toolbar)"
127.0.0.1:80 23.239.119.194 - - [01/Feb/2014:00:49:43 +0000] "GET http://ib.adnxs.com/ttj?id=2106211&referrer=%5BREFERRER_URL%5D HTTP/1.1" 404 438 "http://ask.com" "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)"
127.0.0.1:80 198.56.202.212 - - [01/Feb/2014:00:49:43 +0000] "GET http://ib.adnxs.com/ttj?id=2168277&position=above HTTP/1.0" 404 494 "http://www.fulleducate.com/?p=633" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 2.0.50727; Media Center PC 6.0)"
127.0.0.1:80 198.56.202.213 - - [01/Feb/2014:00:49:43 +0000] "GET http://ib.adnxs.com/ttj?id=2168277&position=above HTTP/1.0" 404 494 "http://www.fulleducate.com/?p=209" "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5"
127.0.0.1:80 198.98.104.241 - - [01/Feb/2014:00:49:44 +0000] "GET http://tags.h12-media.com/tags.js?site=216e49346226002857e6bcd64223e7fc&type=728x90 HTTP/1.0" 404 504 "://www.lookforwardhappiness.com/index.php?view=article&catid=35%3Ahealth-insurance&id=5102%3A2013-12-28-11-28-29&format=pdf&option=com_content&Itemid=54" "Mozilla/4.0 (compatible; MSIE 6.01; Windows 98; Alexa Toolbar)"
127.0.0.1:80 173.234.41.37 - - [01/Feb/2014:00:49:44 +0000] "GET http://ad.smxchange.com/st?ad_type=iframe&ad_size=160x600&section=4848284&pub_url=${PUB_URL} HTTP/1.0" 404 497 "http://hotbizs.com/index.php?option=com_content&view=section&id=19&layout=blog&Itemid=412&limitstart=261" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Alexa Toolbar)"
127.0.0.1:80 198.200.42.8 - - [01/Feb/2014:00:49:44 +0000] "GET http://ib.adnxs.com/ttj?id=2150922 HTTP/1.0" 404 494 "http://www.autosoldbest.com/?p=33" "Mozilla/5.0 (Windows NT 5.1; U; de; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6 Opera 11.00"
127.0.0.1:80 192.169.85.227 - - [01/Feb/2014:00:49:44 +0000] "GET http://ads.yahoo.com/st?ad_type=pop&ad_size=0x0&section=3914696&banned_pop_types=28&pop_times=1&pop_frequency=0&pub_url=${PUB_URL} HTTP/1.0" 404 494 "http://www.eiaok.com/financial-affairs/reasons-why-you-want-to-start-a-business-financial-security.html" "Opera/9.80 (Windows NT 5.1; U; ru) Presto/2.7.39 Version/11.00"
127.0.0.1:80 198.2.199.147 - - [01/Feb/2014:00:49:44 +0000] "GET http://ib.adnxs.com/ttj?id=2059583&position=above HTTP/1.0" 404 494 "http://www.bodybecare.com/future-lady-fashion-institute-kerala-zardosi-painting-courses-cochin-kerala/" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; YPC 3.2.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506)"
127.0.0.1:80 172.246.42.139 - - [01/Feb/2014:00:49:44 +0000] "GET http://ib.adnxs.com/ttj?id=2198716 HTTP/1.0" 404 494 "http://www.fulleducate.com/?p=612" "Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8"

I suspect it's some kind of attack (DDoS).
Have reinstalled apache and php but the problem keeps. until now bloqueiei many ips that appear in the log, but does not solve.
Someone save what I can do to solve the problem?
I'm using:
Linux version 3.11.0-12-generic (buildd@allspice) (gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu7) ) #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013
Server version: Apache/2.4.6 (Ubuntu)
Server built:   Dec  5 2013 18:32:22

My proccess:
  PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND
 1384 www-data  20   0  181m 1652 1084 S   0.3  0.3   0:01.28 apache2
 1405 www-data  20   0  181m 1652 1084 S   0.3  0.3   0:01.24 apache2
 1544 www-data  20   0  181m 1688 1080 S   0.3  0.3   0:01.34 apache2
 1575 www-data  20   0  181m 1696 1088 S   0.3  0.3   0:01.30 apache2
 1783 root      20   0 17796 1556 1004 R   0.3  0.3   0:00.08 top
    1 root      20   0 26920 1500  588 S   0.0  0.3   0:01.45 init
    2 root      20   0     0    0    0 S   0.0  0.0   0:00.00 kthreadd
    3 root      20   0     0    0    0 S   0.0  0.0   0:02.56 ksoftirqd/0
    5 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 kworker/0:0H
    6 root      20   0     0    0    0 S   0.0  0.0   0:00.88 kworker/u2:0
    7 root      rt   0     0    0    0 S   0.0  0.0   0:00.00 migration/0
    8 root      20   0     0    0    0 S   0.0  0.0   0:00.00 rcu_bh
    9 root      20   0     0    0    0 S   0.0  0.0   0:00.00 rcuob/0
   10 root      20   0     0    0    0 S   0.0  0.0   0:07.99 rcu_sched
   11 root      20   0     0    0    0 R   0.0  0.0   0:17.54 rcuos/0
   12 root      rt   0     0    0    0 S   0.0  0.0   0:00.04 watchdog/0
   13 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 khelper
   14 root      20   0     0    0    0 S   0.0  0.0   0:00.00 kdevtmpfs
   15 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 netns
   16 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 writeback
   17 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 kintegrityd
   18 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 bioset
   19 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 kworker/u3:0
   20 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 kblockd
   21 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 ata_sff
   22 root      20   0     0    0    0 S   0.0  0.0   0:00.00 khubd
   23 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 md
   24 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 devfreq_wq
   25 root      20   0     0    0    0 S   0.0  0.0   0:01.06 kworker/0:1
   26 root      20   0     0    0    0 S   0.0  0.0   0:00.00 khungtaskd
   27 root      20   0     0    0    0 S   0.0  0.0   0:01.10 kswapd0
   28 root      25   5     0    0    0 S   0.0  0.0   0:00.00 ksmd
   29 root      20   0     0    0    0 S   0.0  0.0   0:00.00 fsnotify_mark
   30 root      20   0     0    0    0 S   0.0  0.0   0:00.00 ecryptfs-kthrea
   31 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 crypto
   43 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 kthrotld
   44 root      20   0     0    0    0 S   0.0  0.0   0:00.00 kworker/u2:1
   45 root      20   0     0    0    0 S   0.0  0.0   0:00.00 scsi_eh_0
   46 root      20   0     0    0    0 S   0.0  0.0   0:00.00 scsi_eh_1
   66 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 deferwq
   67 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 charger_manager
  119 root      20   0     0    0    0 S   0.0  0.0   0:00.28 jbd2/vda-8
  120 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 ext4-rsv-conver
  121 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 ext4-unrsv-conv
  299 root      20   0 17452  136  136 S   0.0  0.0   0:00.12 upstart-udev-br
  308 root      20   0 42624  508  508 S   0.0  0.1   0:00.03 systemd-udevd
  310 messageb  20   0 30508  496  304 S   0.0  0.1   0:00.16 dbus-daemon

I noticed something. deleted the logs and they only reappeared when I restarted apache.
PS: I am newbie in terminal.

A: Its probably not a DDOS - I suspect that this old question of mine on SF was the same thing, and you're just overhearing the screaming toddlers of the internet.
The best idea is to keep calm and carry on, unless you have excessive loads or traffic coming out of your system. Keep things patched up, and keep an eye on things, but this is really nothing to worry about.
If you must do something about this, setting up fail2ban to block these IP address may be an option, but I can't help there cause I didn't bother to.

A: Someone thinks you have an open proxy server and is trying to relay malicious traffic through it.
Fortunately, you don't actually have an open proxy and the traffic isn't going anywhere, but it is also filling up your logs and eating up your bandwidth.
I would recommend you set a default virtual host that serves any web site not specifically named in other virtual hosts, and that only returns a 403 error for all requests. They will eventually get the message and go away. The default virtual host on a Red Hat based system already does this (that nice test page is also a 403 error); I don't know about Ubuntu.


text:
Q: I am trying to amplify push however getting timedout error what can be the issue? I am trying out aws amplify with react native by following this tutorial :
https://docs.amplify.aws/start/q/integration/react
I was able to push a few days back, then I think I happened to update the cli and then amplify stopped working.
For example, amplify push is throwing the following error:
$ amplify push
- Fetching updates to backend environment: dev from the cloud.
(node:18960) UnhandledPromiseRejectionWarning: Error: connect ETIMEDOUT 169.254.169.254:80
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
(node:18960) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:18960) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

$ npm info amplify version
0.0.11

$ npm info aws-amplify version
3.0.18

aws-amplify/cli : 4.22.0

I couldn't find a solution for this on the internet hence kindly help.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Ajax not working on window safari? Hi I have the following code :
jQuery.ajax({
            method:"POST",
            url:"",
            data:jQuery("#payment").serialize(),
            success:function(data)
            {
            alert(data);
            //return false;

            }
            });

Working fine  on all browser except window safari. This code is working fine on mac safari also

A: I was doing an asynchronous post, and Safari stops running the JavaScript (due to the page being unloaded) before it issues the request. after making  setting async to false. It works
jQuery.ajax({
            async: false,
            method:"POST",
            url:"",
            data:jQuery("#payment").serialize(),
            success:function(data)
            {
            alert(data);
            //return false;

            }
            });


text:
Q: What is the timeout value for a non-blocking Python socket when reading? I'm using Python 2.7 and am working with some legacy code.  It sets a socket in non blocking mode with:
self._socket.setblocking(0)
self._socket.settimeout(0)

My question is, when doing a read, what determines the timeout on the socket?  Will it be the default used by the TCP stack on the OS?  If so, on Linux how would that be changed?  Also, will the write timeout be the same as the read timeout?

A: According to the documentation (emphasis mine):

In non-blocking mode, if a recv() call doesn't find any data, or if a
  send() call can't immediately dispose of the data, a error exception
  is raised.

So it seems as though the "timeout" is an instantaneous check.  If there is no data available or a write can't be made exactly when you call the function, you will receive an exception.

A: Following is from the help of socket.settimeout

settimeout(...) method of socket._socketobject instance
       settimeout(timeout)
Set a timeout on socket operations.  'timeout' can be a float,
     giving in seconds, or None.  Setting a timeout of None disables
    the timeout feature and is equivalent to setblocking(1).
     Setting a timeout of zero is the same as setblocking(0).

So I am not sure why both setblocking(0) and settimeout(0) both is done above. This means read is immediately going to return with EAGAIN or EWOULDBLOCK if there's no data available. When the other end closes connection, read will return with a value of 0.
Read timeout would make sense only in 'blocking' state where after the time equal to timeout has elapsed and there's no data to read, the read should return EAGAIN or EWOULDBLOCK.
In general that is not going to affect write timeout. When you set socket to non-blocking and if the 'write buffers' are full (which would rarely happen, unless there's a rather 'slow' receiver) and if write is likely to block,it should return immediately with EAGAIN or EWOULDBLOCK and then the onus is on the application to make sure the write is issued again.


text:
Q: IsEnabled = false; // not "immediate" I have something like this:
void ClickHandler() // Called from several places
{  // Try to prevent queuing accidental extra clicks during lengthy operation
    GetMainWindow().IsEnabled = false; // "GetMainWindow()" you know what I mean
    DoLengthyStuffInThisThread(); // Yes, I know I shouldnt
    PresentResult();
    GetMainWindow().IsEnabled = true;
}

That's it basically. To clarify though:
Even though I have set  IsEnabled = false it does not have the desired effect, my extra clicks go through during the operation. (It does have an effect if I return without restoring the value.) I assume that normally my thread needs to return in order for the disabling to to have effect but I'd rather not create an extra thread.

A: You have to offload the lengthy work to another thread. The UI isn't notified of this change (and hence, doesn't have a chance to refresh it's state with a layout pass) until after the enclosing method completes.
I would imagine whatever is happening inside of the lengthy method is manipulating some data that is displayed on the UI. If you are using data binding, this operation will populate the UI in the background (if its run on a background thread) and then when that operation completes, it can tell the UI to reenable itself.
This is semi-pseudo code, but check out Task.Factory.StartNew and Dispatcher.BeginInvoke.
public void ClickHandler()
    {
        MainWindow.IsEnabled = false;

        Task.Factory.StartNew(() =>
            {
                // Length work goes here
            }).ContinueWith((result) =>
                {
                    Dispatcher.BeginInvoke(() =>
                        {
                            MainWindow.IsEnabled = true;
                        });
                });
    }

A: Thank you all for answering. The best answer was actually in one one of the *comments, by Will Eddins. Extra thanks!*
The uggly answer to my uggly question is: System.Windows.Forms.Application.DoEvents();
Not a pretty sight but this is what I had to do. Kids, do not try this at home!
  public void WrapLengthyWork(Action lengthyWork)
    {
        SetWaiting(true);
        System.Windows.Forms.Application.DoEvents();
        lengthy();
        SetWaiting(false);
    }

    public void SetWaiting(bool wait)
    {
        if (wait == true)
        {
            Mouse.OverrideCursor = Cursors.Wait;
            Application.Current.MainWindow.IsEnabled = false;
       }
        else
        {
            IsEnabled = true;
            Mouse.OverrideCursor = Cursors.Arrow;
        }
    }

Also, to all of you that suggested that I do it properly, with a thread switch: Thanks to you as well. I am (as I mentioned) painfully aware that the above snippet is poor coding style. My problem was that "LengthyWork()" itself is riddled with stuff that references back to the GUI and must run in the GUI thread, such as:
while(stuffToDo)
{
    Fetch();
    Calculate();
    UpdateGUI();
}

Given the imposed time constraints (couple of hours) and the limited task ("prevent clicks during processing and show wait-cursor and touch nothing else") the proper solution was unfortunately not an option.

A: @william-custode is right, you should do the heavy work off the main application thread. However, a work-around is forcing the window's message loop to consume all currently dispatched messages before beginning the "DoLengthyStuffInThisThread".


text:
Q: how to change form response into ajax response? I have a form, that uses a php file. The form lets the user:
       -input 3 text fields for Title/Price/Description
       -Select an image for his product
       -Choose a table from the dropdown list (options are the table values)
As you see on my code after the user press the submit button, the browser redirects to another page, saying that "1 records was adder successfully".
I want it to be like after the user clicks the submit button on the form, a (javascript/ajax) messagewill appear letting him know that the records was added successfully.
Sorry for long coding, I think you might need everything.
OPEN TO ANY SUGGESTIONS
form

Add Product

    <form id = "additems" action="../cms/insert.php" enctype="multipart/form-data" method="post"/>
      Title: <input type="text" name="title"/>
      Desc: <input type="text" name="description"/>
      Price: <input type="text" name="price" />
      Quan: <input type="text" name="stock" />

Upload your image <input type="file" name="photoimg" id="photoimg" />

     <select name="categories">
              <option value="mens">Mens</option>
              <option value="baby_books">Baby Books</option>
              <option value="comics">Comics</option>
              <option value="cooking">Cooking</option>
              <option value="games">Games</option>
              <option value="garden">Garden</option>
              <option value="infants">Infants</option>
              <option value="kids">Kids</option>
              <option value="moviestv">Movies-TV</option>
              <option value="music">Music</option>
              <option value="women">Women</option>
    </select>

           <input type="submit" name="Submit" value="Add new item">
          </form>

insert.php (used on the form)
session_start();
$session_id='1'; //$session id
$path = "../cms/uploads/";

    $valid_formats = array("jpg", "png", "gif", "bmp");
    if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST")
        {
            $name = $_FILES['photoimg']['name'];
            $size = $_FILES['photoimg']['size'];

            if(strlen($name))
                {
                    list($txt, $ext) = explode(".", $name);
                    if(in_array($ext,$valid_formats))
                    {
                    if($size<(1024*1024))
                        {
                            $actual_image_name = time().substr(str_replace(" ", "_", $txt), 5).".".$ext;
                            $tmp = $_FILES['photoimg']['tmp_name'];
                            if(move_uploaded_file($tmp, $path.$actual_image_name))
                                {

$table = $_POST['categories'];
$title = $_POST['title'];
$des = $_POST['description'];
$price = $_POST['price'];
$stock = $_POST['stock'];
    $sql="INSERT INTO $table (title, description, price, image, stock)
    VALUES
    ('$title','$des','$price','$path$actual_image_name','$stock')";

    if (!mysqli_query($con,$sql))
    {
        die('Error: ' . mysqli_error($con));
    }
    echo "
1 record added into the $table table
";
    echo '<button onclick="goBack()">Go Back</button>';

A: with jquery its quite simple:
Just do the following:
1st thing, remove the type="submit" in your input and give it a unique identifier like this:
<input id="submit_form" name="Submit" value="Add new item">

2nd thing, in your javascript file, do:
$(document).ready(function(){
    $('input#submit_form').on('click', function() {
        $.ajax({
            url: 'addnew.php',// TARGET PHP SCRIPT
            type: 'post'      // HTTP METHOD
            data: {
                'title' : $('input[name="title"]').val()
            },
            success: function(data){
                alert(data); // WILL SHOW THE MESSAGE THAT YOU SHOWED IN YOUR PHP SCRIPT.
            }
        });
    });
})

3nd thing, in you php file:
Do the same thing but just do:
die("1 record added into the $table table")


text:
Q: Get sudoers information for all users on a server I want to collect information on what sudoers actions a user can perform on a server.  From what I've read, you can do this with the command sudo -l -U username.  However, one server that I have has a slightly older version of sudo (1.6.7p5) and the -U option doesn't seem to exist (I don't own the server so I can't just upgrade to a newer version of sudo).
Has anyone ever had to collect sudoers information for all users on a server?  How would you recommend doing it?
EDIT: This has to be an automated process, so "just look at the sudoers file" won't work.

A: As root:
cat /etc/sudoers > /home/username/sudoerprivs
cd /home/username
chown username:username sudoerprivs

A: You can just do visudo and see what options each user has.


text:
Q: Is it possible to call a variable by concatenating two strings in JavaScript? I'm trying to condense my code and I've looked at a number of articles on concatenating variables but I haven't been able to get anything to work the way I need it to.
Below are two snippets of code. They are functionally identical except the first snippet has variables that use 'Str' in their name and the second snippet uses 'Dex' instead. I plan on creating similar code with 'Int' and 'Ht' but I don't want to copy / paste and then go back to change the 'Str, Dex, Int, Ht' names all over my code over and over again.
Is it possible to put the 'Str, Dex, Int, Ht' into a variable [var1] (according to what button is pressed) and then use [var1] in place of 'Str, Dex, Int, Ht' so that the code only has to be written once?
//Define Stength Increase Function
var strIncrease = function () {
//Increase playerStrength by 1
    playerStr = playerStr + 1;
    playerStrDisplay.innerHTML = playerStr;
//Increase strengthCP by 10
    strCP = strCP + strCost;
    strCPDisplay.innerHTML = strCP;
//Decrease totalCP by 10
    totalCP = totalCP - strCost;
    totalCPDisplay.innerHTML = totalCP;
}

//Define Dexterity Increase Function
var dexIncrease = function () {
//Increase playerDexterity by 1
    playerDex = playerDex + 1;
    playerDexDisplay.innerHTML = playerDex;
//Increase DexterityCP by 20
    dexCP = dexCP + dexCost;
    dexCPDisplay.innerHTML = dexCP;
//Decrease totalCP by 20
    totalCP = totalCP - dexCost;
    totalCPDisplay.innerHTML = totalCP;
}

A: You can use an object as a map:
var player = { str: 0, dex: 0, ... };

function increase(stat) {
    player[stat]++;
    document.getElementById(stat + 'Display').innerHTML = player[stat];
}

increate('str');

A: You could define the attributes as properties of objects and access them using strings, like this:
var player = {
    str: 1,
    dex: 1,
    in: 1,
    ht: 1,
    strCP: 10,
    dexCP: 10,
    intCP: 10,
    htCP: 10,
    totalCP: 0
},
costs = {
   strCost: 10,
   dexCost: 10,
   inCost: 10,
   htCost: 10
};

function increaseAttribute(player, costs, attr) {
    player[attr] += 1;
    player[attr + "CP"] += costs[attr + "Cost"];
    player.totalCP += costs[attr + "Cost"];
.
.
}

function increaseStr () {
   increaseAttribute(player, costs, attr);
}
.
.
.

A: You can use closure to generate method dynamically.
For example.
var player = {
   str : 0
   dex : 0
   int : 0
   ht : 0
}

function methodFactory (player, property, diff) {
    var mathod = function () {
        player[property] += diff;
    }
    return method;
}

then
var addInt = methodFactory (player, 'int', 1);
var addIntBy2 = methodFactory (player, 'int', 2);

addInt();

Write once, use everywhere


text:
Q: How to write macro in c in this case? Given the following function in c:
int reset_values_of_string(char* s, int to_new_val){
   int l = strlen(s);
   int was_changed = 0;
   for(int i=0; i<l; i++) {
      if(s[i] != to_new_val) was_changed=1;
      s[i] = to_new_val;
   }
   return was_changed;
}

Can I write this function as MACRO (#define) in C? that will do exactly the same and will return this value ?
In addition, what is bascially preferred? to implement it with macro or with function like that i write it above.

A:
Can I write this function as MACRO (#define) in C? That will do exactly the same and will return this value

Yes, and it will be close enough to the function.

What is basically preferred?

A function would be preferred.
Modern compilers can choose to automatically inline functions if they deem it a better option. You may also encourage compilers to inline functions.


text:
Q: how to identify invalid date and replace default date How to identify inserted date is in correct format or not. sample_date column data type is in varchar.  Here i inserted two values '25-02-1999' and '2004'. When i found invalid date in sample_date column i want to replace with some dummy date.
Example:

        create table sample(sample_date varchar2(10 char));
        insert into sample values('25-02-1988');
        insert into sample values('2004')
        insert into sample values('2005')
        insert into sample values('2006')
        I want to replace 2004,2005,2006 with dummy date('01-01-1988')

A: Store your values as a DATE datatype, all your date related issues will become much simpler...
CREATE OR REPLACE TABLE sample(sample_date DATE);

INSERT INTO sample (sample_date) VALUES (TO_DATE('25-02-1988', 'DD-MM-YYYY'));

INSERT INTO sample (sample_date) VALUES (TO_DATE('2004', 'YYYY'));

INSERT INTO sample (sample_date) VALUES (TO_DATE('2005', 'YYYY'));

INSERT INTO sample (sample_date) VALUES (TO_DATE('2006', 'YYYY'));

If you then want to view the dates in DD-MM-YYYY format:
SELECT TO_CHAR(sample_date, 'DD-MM-YYYY') AS formatted_sample_date
  FROM sample;

Hope it helps...


text:
Q: Issue with DateTimeParseException when using STRICT resolver style I am trying to parse a date string using the following pattern: yyMMdd and the STRICT resolver as follows:
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dateFormat).withResolverStyle(ResolverStyle.STRICT);
LocalDate.parse(expiryDate, formatter);

I get the following DateTimeParseException:

java.time.format.DateTimeParseException: Text '160501' could not be
  parsed: Unable to obtain LocalDate from TemporalAccessor:
  {YearOfEra=2016, MonthOfYear=5, DayOfMonth=1},ISO of type
  java.time.format.Parsed

When I swith to the default resolve style, i.e. ResolverStyle.SMART it allows such dates as 30th of February.
Can someone please help?

A: While JodaStephen has nicely explained the reason for the exception and given one good solution (use uu rather than yy), I am offering a couple of other possible solutions:

*

*The obvious one that you probably don't want: leave the resolver style at SMART (the default). In other words either leave out .withResolverStyle(ResolverStyle.STRICT) completely or change it to .withResolverStyle(ResolverStyle.SMART).

*Provide a default era.

For the second option here is a code example:
    DateTimeFormatter formatter = new DateTimeFormatterBuilder()
            .appendPattern("yyMMdd")
            .parseDefaulting(ChronoField.ERA, 1)
            .toFormatter()
            .withResolverStyle(ResolverStyle.STRICT);

    String expiryDate = "160501";
    LocalDate result = LocalDate.parse(expiryDate, formatter);

    System.out.println(result);

Output is:

2016-05-01

Where the last solution may make a difference compared to using uu in the format pattern:

*

*It allows us to use a format pattern that is given to us where we cannot control whether pattern letter u or y is used.

*With pattern letter y it will fail with an exception if the string contains a negative year. Depending on your situation and requirements this may be desirable or unacceptable.

Edit: The second argument to parseDefaulting() may also be written IsoEra.CE.getValue() rather than just 1 to make it clear that we are specifying the current era (CE; also often called Anno Domini or AD).

A: The strict resolver requires an era to go with YearOfEra. Change your pattern to use "u" instead of "y" and it will work, ie. "uuMMdd".


text:
Q: How to connect mongodb instance region wise from my node js application server I have one master instance of mongo db and 3 read only instances configured on different regions. Now whenever a request lands on to my node js application server, i want to connect to near by db instance to get data.

A: Option 1: ( better, since you dont care where the application is , the driver find the nearest members automatically)
To achieve this behaviour you need to set the read-preference to  nearest.
That way your driver will route your read request to much closest member depending on periodical latency check.
Option 2:
You define custom tags for members known in advance are in the application region and use those tags when read request are sent.


text:
Q: How to make bash (Terminal.app) remember history of previous sessions? In my computer at work, my bash shell remembers history from previous sessions, even if I just opened a new terminal.
In my computer at home, this doesn't happen.
I have the same OS 10.6.8 in both machines and I don't have any history related setting in .bash_profile.
How could I set this up on my home computer so it remembers history across sessions?

A: I just discovered I had a similar problem, though my employer only has two Macs, and neither sits on my desk. Unacceptable, but a battle for another time.
Anyway, at home, Mac Mini (migrated from MacBook Pro) did not cooperate even after setting .bashrc and/or .profile. Then I discovered that my ~/.bash_history file was mysteriously owned by root. Had to do this:
sudo -iu root
cd ~(myusername)
chown (myusername) .bash_history

(Yes, I know it can be done in fewer commands. Habit.)
Then I exited Terminal, and started up a new one. Woot! All sorts of history previously lost came rushing back. How very nice.
Likelihood anyone reading this has accidentally put themselves in this predicament: 0.2%. I'm sure I mucked this up when over-zealously "fixing" something else.

A: I had this problem and what worked for me was create a file called .bash_sessions_disable in my user folder (~/).
Basically OS X create history files in .bash_sessions folder for each session (in my case, one for each Tab). And even properly closing these sessions, OS X don't replay the historical to .bash_history.
Creating the .bash_sessions_disable you disable this behavior.
touch ~/.bash_sessions_disable

A: You'll need to tell bash where to keep your history file, and how many lines to keep:
# Set the location of your HISTFILE
echo "export HISTFILE=/Users/<USERNAME>/.bash_history" >> ~/.bash_profile

# Number of lines to keep (1000 in this example)
echo "export HISTFILESIZE=1000" >> ~/.bash_profile

# Set how many commands to keep in the current session history list
echo "export HISTSIZE=80" >> ~/.bash_profile

# Ignore commands that start with a space
echo "export HISTIGNORE=\"&:[ ]*:exit\"" >> ~/.bash_profile

A: This answer from this Reddit thread saved me:

It's probably RVM preventing the exit "hook" for bash_sessions to run. If you comment out the following line in your .bash_profile, it should work.

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

A: I had a similar problem as well, no history recorded. The given solutions didn't work, but at long last I found out that the problem was as simple as a missing .bash_history
The solution was to go to /home/[username]/ and add a file .bash_history, so
nano .bash_history

and then type anything in the file (otherwise it won't be created), exit and save. After this the history started functioning normally.

A: If you add shopt -s histappend to your ~/.bash_profile then even with history sessions enabled (which it is by default in MacOS), the primary ~/.bash_history file will be appended with the results of each session. My ~/.bash_profile is configured as follows:
export HISTSIZE=100000000     # yes I know this is big I manage it manually
export HISTFILESIZE=100000000 # yes I know this is big I manage it manually
shopt -s histappend

This answer applies to <= MacOS 10.15.x


text:
Q: Why cors module can not be found? I'm trying to enable cors for my next.js API.
Based on docs and the example I installed cors:
npm i cors

And I can verify that it's in my package.json:
"cors": "^2.8.5",

And it's in my node_modules directory.
However, when I use import Cors from 'cors' in my api code, I get this error:

Module not found: Can't resolve 'cors'

Why do I get this error while the package is installed? I also tried const cors = require('cors') and got the same error.

A: First of all you can try delete node modules and package-lock.json:
rm -rf node_modules
rm -f package-lock.json
npm cache clean --force

npm install

After this be sure that cors is in your dependencies on package.json:
"dependencies": {
    "cors": "version",
  },

if not you can try to manually add the line with desired version and run npm install
If still not working you can try:
npm install cors --save

in your main project directory


text:
Q: How to generate multiline graphs from csv data with timestamp as x axis Below is my sample data in CSV format (stats_1.csv):
timestamp,ip,CPU,memory
2017-08-24 18:57:40,10.20.6.181,46,14
2017-08-24 18:57:50,10.20.6.182,43,12
2017-08-24 19:07:40,10.20.6.181,46,14
2017-08-24 19:07:50,10.20.6.182,43,12
2017-08-24 19:17:40,10.20.6.181,46,14
2017-08-24 19:17:50,10.20.6.182,43,12
2017-08-24 19:27:40,10.20.6.181,46,14
2017-08-24 19:27:50,10.20.6.182,43,12
2017-08-24 19:37:40,10.20.6.181,46,14
2017-08-24 18:37:50,10.20.6.182,43,12

I want to have 2D line graphs from this with X-axis as time stamp and Y-axis as
CPU (there will be a separate graph for memory).
In the graph, there should be one line for each IP and legends.
This is what I have tried so far:
import matplotlib.pyplot as plt
import pandas

# setup the dataframe
data_frame = pandas.read_csv("stats_1.csv")

def plot_cpu_utilization_graphs(df):
    column_name = 'CPU'
    df = df[[column_name, 'timestamp', 'ip']]
    max_value = df[column_name].max()
    if max_value < 100:
        max_value = 100
    min_value = df[column_name].min()
    if min_value > 0:
        min_value = 0
    start_idx = df['timestamp'].iloc[0]
    end_idx = df['timestamp'].iloc[-1]
    time_series = pandas.DatetimeIndex(freq='10T', start=start_idx, end=end_idx)
    y_axes_series = range(min_value, max_value, 10)
    #ax = df.groupby('ip').plot(x='timestamp', y='CPU')
    fig, ax = plt.subplots(1, 1)
    df.groupby("ip").plot(x='timestamp', y='CPU', ax=ax)
    ax.set_xlim(time_series[0], time_series[-1])
    ax.set_ylim(min_value, max_value)
    plt.show()

plot_cpu_utilization_graphs(data_frame)

And this is what I am getting:

A: Convert your timestamp column to datetime format, then it should work:
df['timestamp'] = pd.to_datetime(df['timestamp'])


text:
Q: Remove UILabel from UIView Swift 2 I am adding some labels on a UIScrollView and getting their text from a NSMutableArray:
import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var myScrollView: UIScrollView!

    let containerView = UIView()
    var array = NSMutableArray()

    override func viewDidLoad() {
        super.viewDidLoad()

       // containerView.frame = myScrollView.frame

         array = ["some text", "some other text", "text 3and 4 loremnd 4 lorem ips ipsum", "more text", "Lorem ipsum dolor sit amet", "consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam", "quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in", "reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident", "sunt in culpa qui officia deserunt mollit anim id est laborum"]

        self.update()

    }

    @IBAction func addSomething(sender: AnyObject) {

        array.addObject("this is at the end")

       self.update()
    }

    @IBAction func removeSomething(sender: AnyObject) {

        self.containerView.removeFromSuperview() //this doesn't work
        array.removeLastObject()

         self.update()

    }

    func update() {

        for i  in 0...array.count - 1 {

            let label = UILabel(frame: CGRectMake(10, CGFloat(i) * 74 + 20, 64, 64))
            label.text = array[i] as? String

            label.textAlignment = NSTextAlignment.Center
            label.numberOfLines = 0
            label.lineBreakMode = NSLineBreakMode.ByWordWrapping
            label.font = UIFont.systemFontOfSize(10)
            label.adjustsFontSizeToFitWidth = true
            label.minimumScaleFactor = 0.4
            label.layer.masksToBounds = true
            label.layer.cornerRadius = 32
            label.layer.borderColor = UIColor.brownColor().CGColor
            label.layer.borderWidth = 1.0

            self.containerView.addSubview(label)

        }

        self.myScrollView.contentSize.height = CGFloat(array.count) * 78
        myScrollView.addSubview(containerView)

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

My problem is that Although I can remove the last object from my array when I call the removeSomething function the last label is still on my view.
Any ideas?

A: I don't see you clear self.containerView before call self.update().  I bet you call update multiple times and there are several labels at the same places.
Try clear containerView at the beginning of update():
func update() {
    containerView.removeFromSuperview() // Clear containerView
    containerView = UIView() // Create a new instance

    for i  in 0...array.count - 1 {

        let label = UILabel(frame: CGRectMake(10, CGFloat(i) * 74 + 20, 64, 64))
        label.text = array[i] as? String

        label.textAlignment = NSTextAlignment.Center
        label.numberOfLines = 0
        label.lineBreakMode = NSLineBreakMode.ByWordWrapping
        label.font = UIFont.systemFontOfSize(10)
        label.adjustsFontSizeToFitWidth = true
        label.minimumScaleFactor = 0.4
        label.layer.masksToBounds = true
        label.layer.cornerRadius = 32
        label.layer.borderColor = UIColor.brownColor().CGColor
        label.layer.borderWidth = 1.0

        self.containerView.addSubview(label)

    }

    self.myScrollView.contentSize.height = CGFloat(array.count) * 78
    myScrollView.addSubview(containerView)

}


text:
Q: When is the composition of harmonic functions harmonic? I have already proven that if $u(z)$ is harmonic and  $v(z)$ is analytic then $u(v(z))$ is harmonic, I'm guessing that if $u(z)$ and $v(z)$ are harmonic then $u(v(z))$ is harmonic if and only if $v(z)$ is analytic.
Let $A$ be an open subset of $\mathbb{C}$, $u(z): A \rightarrow \mathbb{R}$, $v(z): A\rightarrow \mathbb{R}$ functions such that:
$$
\nabla^2 u(z) = \frac{\delta^2}{\delta x^2}u(z) + \frac{\delta^2}{\delta y^2}u(z) = 0
$$
$$
\nabla^2 v(z) = \frac{\delta^2}{\delta x^2}v(z) + \frac{\delta^2}{\delta y^2}v(z) = 0
$$
We call these functions harmonic. Let us consider the composition $u(v(z))$, by definition this function will be harmonic if:
$$
\nabla^2 u(v(z)) = \frac{\delta^2}{\delta x^2}u(v(z)) + \frac{\delta^2}{\delta y^2}u(v(z)) = 0
$$
By the chain rule we have that:
$$
\frac{\delta^2}{\delta x^2}u(v(z)) = \frac{\delta^2}{\delta [v(z)]^2}u(v(z)) \left( \frac{\delta}{\delta x} v(z) \right)^2 + \frac{\delta}{\delta v(z)} u(v(z)) \frac{\delta^2}{\delta x^2} v(z)
$$
$$
\frac{\delta^2}{\delta y^2}u(v(z)) = \frac{\delta^2}{\delta [v(z)]^2}u(v(z)) \left( \frac{\delta}{\delta y} v(z) \right)^2 + \frac{\delta}{\delta v(z)} u(v(z)) \frac{\delta^2}{\delta y^2} v(z)
$$
Because $v(z)$ is harmonic we will have that:
$$
\nabla^2 u(v(z)) = \frac{\delta^2}{\delta [v(z)]^2}u(v(z)) \left[\left( \frac{\delta}{\delta x} v(z) \right)^2 + \left( \frac{\delta}{\delta y} v(z) \right)^2 \right]
$$
We can easily see that $\nabla^2 u(v(z)) = 0$ if $v(z) = 0$.
I'm not sure what to do if $v(z) \neq 0$ or if the conjecture is true.


text:
Q: How can I disable HREF if onclick is executed? I have an anchor with both HREF and ONCLICK attributes set. If clicked and Javascript is enabled, I want it to only execute ONCLICK and ignore HREF. Likewise, if Javascript is disabled or unsupported, I want it to follow the HREF URL and ignore ONCLICK. Below is an example of what I'm doing, which would execute the JS and follow the link concurrently (usually the JS is executed and then the page changes):
Log in

what's the best way to do this?
I'm hoping for a Javascript answer, but I'll accept any method as long as it works, especially if this can be done with PHP.
I've read "a href link executes and redirects page before javascript onclick function is able to finish" already, but it only delays HREF, but doesn't completely disable it. I'm also looking for something much simpler.

A: You can use the first un-edited solution, if you put return first in the onclick attribute:
Log in

yes_js_login = function() {
     // Your code here
     return false;
}

Example: https://jsfiddle.net/FXkgV/289/

A: It's simpler if you pass an event parameter like this:
link

function yes_js_login(e) {
    e.stopImmediatePropagation();
}

A:     yes_js_login = function() {
         // Your code here
         return false;
    }

If you return false it should prevent the default action (going to the href).
Edit: Sorry that doesn't seem to work, you can do the following instead:
Link

A: Try using javascript:void(0) as follows-
Text

A: Simply disable default browser behaviour using preventDefault and pass the event within your HTML.
Lorem ipsum
yes_js_login = function(e) {
  e.preventDefault();
}

A: This might help.
No JQuery needed

This code does the following:
Pass the relative link to Google Docs Viewer

*

*Get the full link version of the anchor by this.href

*open the link the the new window.

So in your case this might work:

A: Test

with jQuery:

with JavaScript

You assign class .ignore-click to as many elements you like and clicks on those elements will be ignored

A: You can use this simple code:
add new action

A: I solved a situation where I needed a template for the  element that would handle alternatively a regular URL or a javascript call, where the js function needs a reference to the calling  element. In javascript, "this" works as a self reference only in the context of a form element, e.g., a button. I didn't want a button, just the apperance of a regular link.
Examples:
A regular link
javascript with self reference

The href and onClick attributes have the same values, exept I append "return false" on onClick when it's a javascript call. Having "return false" in the called function did not work.

A: In my case, I had a condition when the user click the "a" element.  The condition was:
If other section had more than ten items, then the user should be not redirected to other page.
If other section had less than ten items, then the user should be redirected to other page.
The functionality of the "a" elements depends of the other component. The code within click event is the follow:
var elementsOtherSection = document.querySelectorAll("#vehicle-item").length;
if (elementsOtherSection> 10){
     return true;
}else{
     event.preventDefault();
     return false;
}


text:
Q: Fetching problem with react, I am trying to fetch movie name from local api than based on that movie name fetch movie data from another api So I'm fetching movie name from localhost with getMovie function, and based on that name I fetch from online API. When i console.log name(that i got from getMovie function) constant i get undefined, then i get real movie name. Below are my function for fetching. Hope someone can help I am really stuck with this. :)
  async function getMovie() {
    try {
        const response = await fetch(`http://localhost:5000/dashboard/movies/movie/${movieId}`, {
          method:"GET",
          headers: { "Content-Type": "application/json" }
        })
        const parseRes = await response.json()
        setMovieFromBase(parseRes[0])
      } catch (error) {
        console.error(error.message)
      }
    }
    const {movie_name} = movieFromBase
    console.log(movie_name)

 const fetchPopular = async() => {
    try {
         const data = await fetch(`https://api.themoviedb.org/3/search/movie?API_KEY&query=${name}`)
         const movies = await data.json()
         console.log(movie)
         setMovie([movies.results[0]])
         console.log(movie)
        } catch (error) {
          console.error(error.message)
        }
      }


text:
Q: Propulsion methods of the sentinels in the matrix Whenever we see the sentinels in the matrix, they seem to be moving through pushing with their 'tentacles' like a squid, but how do they propel themselves, as they are obviously moving through air, as both sentinels and humans have been in the same environment, demanding air.

A: In terms of propulsion, there's no in-universe description of the method either within the film or comic canon. The Matrix Wikia suggests that the Sentinels are using some form of "internal pad" technology, a suggestion borne out by an examination of the concept art from George Hull, Senior Production Artist for the Matrix Trilogy;

As you can seen, underneath each Sentinel (and the "tow bombs" they throw) is a blue glow distinctly reminiscent of the glow seen under the Nebuchadnezzar's anti-gravity "hoverpads".

It's also notable that whenever a Sentinel is damaged beyond its capacity to fly, they experience a bright blue internal explosion that is basically identical in colour and brightness to that experienced by the Hammer whenever their hoverpads are destroyed.

A: It's a technology called the "Pad" short for hoverpad the machines invented it and distributed it to the humans and it is used in their ships. However the machines have vastly improved it and no longer need the external "pads" seen on the ships.


text:
Q: Designing a Kalaman filter I am working on a project to monitor a water tank for energy storage. I have a large water tank, to which 10 thermometers are attached. By measuring the temperature, I can estimate the energy stored in the tank. That is quite simple, but I want to add another feature.
By sampling the amount of energy in time, I want to determine the power that is currently flowing in or out of the tank. I am measuring the energy in the tank every minute and determining the current power by comparing it to the last measurement. The direct result is very noisy (for example jumping between 2-4 kW), so I need some kind of filtering.
I started simply with averaging, which works fine,(current power is the average from last 10 measurements) but I wanted to try something a bit fancier. So I wrote a simple Kalman filter, the one described in this video - https://www.youtube.com/watch?v=PZrFFg5_Sd0&list=PLX2gX-ftPVXU3oUFNATxGXY90AULiqnWT&index=5 The problem is, I guess, that this filter is designed for static measurements, and my measurement changes quite a bit. As an example, in this plot, there are 60 measurements (1 every minute) and the line is the output of the Kalman filter:
Image
Is it possible to modify the filter to follow the actual value more accurately? Or is this just not a suitable system to filter with this kind of filter and I should use something else?


text:
Q: Powershell won't run ps1 files Completely baffled by this.  Can't seem to run any ps1 files on powershell??  I know for sure it was working fine last week.
Here is the error I'm getting.  It suggests the file doesn't exist, so I proved it does by using Test-Path first...
PS C:\WINDOWS\system32> cd C:\Users\Public
if (Test-Path test.ps1) {
    ./test.ps1
}
./test.ps1 : The term './test.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:3 char:5
+     ./test.ps1
+     ~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (./test.ps1:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Any suggestions of what I could try?
Doesn't seem to be related to permissions.  I was originally running from a network drive, but same result from C drive.  Restarted the PC 2 times already.  I'm not aware of any changes made to my PC in the last week that could have caused this?
EDIT
As requested:
PS C:\Users\Public> dir .\test.ps1

    Directory C:\Users\Public

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----       01/11/2019     14:35            208 test.ps1

A: This is not a satisfactory answer as to why the following caused it; but scripts are now working again.  So here's what happened...
I've been working remotely from home the last 2 weeks using CAG (Critix Access Gateway).
I went back in the office today for the first time, and when I connected directly to the network, all my scripts where working again as normal.
It turns out IT have been releasing an alternative to CAG use called CheckPointVPN.  My user group was updated to support it earlier in the week (which may have been when my scripts stopped working?).
I got it fully installed while in the office, and now I'm back working remotely from home again, and all scripts are working well.
As I said, this isn't exactly a clear answer.  But maybe it'll help someone else who might be experenicing something similar


text:
Q: Calculadora em C (Iniciante) Estou com uma dúvida no seguinte exercício:

Elabore um programa que receba dois números inteiros e mostre o
  resultado da divisão dos números e seu resto. o programa devera
  perguntar se o usuário pretende repetir a operação ou encerrar o
  programa.

Não sei como fazer para que no final do programa se eu digitar 1, ele encerre, se digitar 2 recomece, segue abaixo meu programa:
int main()
{
    int var1, var2, Q, R;
    printf("Digite o dividendo: ");
    scanf("%d", &var1);
    printf("Digite o divisor: ");
    scanf("%d", &var2);
    Q = var1 / var2;
    R = var1 % var2;
    printf("Resultado: %d\n", Q);
    printf("Resto: %d\n", R);

    int decisao;
    printf("\nDeseja encerrar o programa? \n1 para sim e 2 para nao.");
    scanf("%d", &decisao);
}

A: Você pode utilizar um laço de repetição ou ao final do seu código, você pode adicionar um if para verificar se o valor contido na variável decisão é igual a dois, se o resultado da comparação for verdadeiro então você pode chamar o método main() novamente.
Exemplo com laço Do While:
int main()
{
    int var1, var2, Q, R, decisao = 2;

    do {
        printf("Digite o dividendo: ");
        scanf("%d", &var1);
        printf("Digite o divisor: ");
        scanf("%d", &var2);
        Q = var1 / var2;
        R = var1 % var2;
        printf("Resultado: %d\n", Q);
        printf("Resto: %d\n", R);

        printf("\n Caso deseje repetir a operacao digite 2 ou digite qualquer outro valor para encerrar.\n");
        scanf("%d", &decisao);

    } while(decisao == 2);

}

Exemplo com recursão:
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int var1, var2, Q, R;
    printf("Digite o dividendo: ");
    scanf("%d", &var1);
    printf("Digite o divisor: ");
    scanf("%d", &var2);
    Q = var1 / var2;
    R = var1 % var2;
    printf("Resultado: %d\n", Q);
    printf("Resto: %d\n", R);

    int decisao;
    printf("\n Caso deseje repetir a operacao digite 2 ou digite qualquer outro valor para encerrar.\n");
    scanf("%d", &decisao);

    if(decisao == 2)
        return main();

}

Observação, eu mudei a mensagem pois o programa encerrará para qualquer valor diferente de dois.


text:
Q: What is the concept of context in XPath or XML stuff I read the word context very often in the documents about XPath. I would like to get a conceptual idea about it and compare that with what I understand of it or its general meaning.
Currently, by context I think of a set of nodes creating a scope in the hierarchical structure of XML.
for example
<doc>
   <header>
   </header>
   <content>
      <section1>
           it is a good boy
      </section1>
      <section2>
          this good is for export
      </section2>
   </content>
   <footer>
   </footer>
</doc>

In my own terms, for example //content/section1//* is a context in which the meaning of "good" differs with its meaning in the context of //content/section2//*
I don't know how much it correspond to its meaning in the documents of XPath or XSLT,...

A: Per the docs:

Expression evaluation occurs with respect to a context. XSLT and XPointer specify how the context is determined for XPath expressions used in XSLT and XPointer respectively. The context consists of:

*

*a node (the context node)

*a pair of non-zero positive integers (the context position and the context size)

*a set of variable bindings

*a function library

*the set of namespace declarations in scope for the expression

The context position is always less than or equal to the context size.

A: It's very simple. Context is what predicates and location steps implicitly refer to.

*

*Predicates are the expressions square brackets.

*Location steps are, sloppily speaking, the bits that are separated by forward slashes.

*Here's a more thorough explanation of XPath terms: https://stackoverflow.com/a/2990317/18771
So, for example:

*

*//a selects any <a> element.

*

*Context for this expression is the root node. (note the technical discussion in the comments below)

*//a[@name = 'foo'] selects any <a> element whose @name attribute has a value of 'foo'.

*

*Context for the location step in this expression is again the root node.

*Context for the predicate is any selected <a>.

*Et cetera. Context is different for every sub-expression.
//a[@name = 'foo'] is equivalent to //a[./@name = 'foo'], where context is set explicitly via .. Implicit context allows you to skip writing ./ every time you want to refer to that node you mean.
.//a selects all nodes beneath the current node. The current node is a concept that exists in environments that host XPath, for example XSLT or any DOM API that supports XPath. The current node can be used as context for the initial step of the path.


text:
Q: Randomly generated password Rails 3.1 For the purpose of a new web app, I would need on my sign up page (which is administrator only) just only one email field.
The thing is that I'm totally new at rails and so even basics things like that are for me really difficult...
I created my authentification using Railscast #270 which uses has_secure_password method.
For now, everything works great except that I dont need all this bullcrap...
I also want to use Action Mailer to send the generated password to his email adress.
A hex(8) password would be perfect (I have seen SecureRandom but it seems to be depreciated)
Users_Controller:
class UsersController < ApplicationController
  skip_before_filter :is_connected?, :only => [:new, :create]

  def new
    @user = User.new
  end

  def create
    @user = User.new(params[:user])
    if @user.save
      # Tell the Mailer to send a welcome Email after save
      Mailer.confirm_email(@user).deliver

      redirect_to root_url, :notice => "Signed up!"
    else
      render "new"
    end
  end
end

User_model:
class User < ActiveRecord::Base
  attr_accessible :email
  has_secure_password
  validates_presence_of :password, :email, :on => :create
end

For now, in my view, I have 2 fields. But as I said earlier, I only want one.
I would like to keep using has_secure_password which seems to offer a pretty good security regarding hash/salt.

A: Here is one simple code for random password with lenth 8
rand_password=('0'..'z').to_a.shuffle.first(8).join

Hope it will help.

A: Rails provides ActiveSupport::SecureRandom which either (depending on the Ruby version) is just a bridge to Ruby's SecureRandom or reimplemented it on older versions of Ruby (if my memory is correct SecureRandom was added in 1.8.7)
Now that all of the versions of Ruby that Rails supports have SecureRandom built-in ActiveSupport::SecureRandom is no longer needed and has been deprecated. SecureRandom itself is going nowhere -
require 'securerandom'
SecureRandom.hex(8)

should do fine (you might want to consider SecureRandom.urlsafe_base64 for a more compact representation of the same amount of actual randomness)

A: Sometimes things from Rails are deprecated because they duplicate functionality that has been added to Ruby core, and SecureRandom seems to be one of those things.
You can use any of those random generator methods to produce a one-time-use password.

A: To Create Random and unique token/password
class User < ActiveRecord::Base

  before_create :generate_password

  def generate_password
    self.password = loop do
      random_token = SecureRandom.urlsafe_base64
      # If you are using FFaker gem then you can use it otherwise
      # SecureRandom is great choice
      # random_token = FFaker::Internet.password
      break random_token unless User.exists?(password: random_token)
    end
  end
end

The main object here is to generate random token and do not repeat that token in the database. It can be really useful for some cases like generating unique token, unique invoice number, etc


text:
Q: How to extract of sub-net of NetGraph correctly? net = NetGraph[{3, 5, 8}, {1 -> 2 -> 3}, "Input" -> 2]

Take[net, {1, 2}]

But net[[1 ;; 2]] gives Missing["NotPresent", {1 ;; 2}].
I find net//Normal is:

But {a, b, c}[[1 ;; 2]] == Take[{a, b, c}, {1, 2}] returns True.
And There is a more complicated net:
net = NetGraph[{EmbeddingLayer[32, "Input" -> NetEncoder[{"Class", Range[0, 500]}]],
          CatenateLayer[],64, Ramp, 43},
         {NetPort["EmbeddingLayerInput"] -> 1 -> 2,
          NetPort["Input2"] -> 2, 2 -> 3 -> 4 -> 5},
         "Input2" -> 12]

I want to extract the sub-net like this:
NetGraph[{CatenateLayer[], 64, Ramp, 43},
         {NetPort["Input"] -> 1,
         NetPort["Input2"] -> 1 -> 2 -> 3 -> 4},
         "Input2" -> 12, "Input" -> 32]

The way I can figure out is use this:
NetGraph[{CatenateLayer[], Take[net, {3, NetPort@"Output"}]},
         {NetPort["Input"] -> 1, NetPort["Input2"] -> 1 -> 2},
         "Input2" -> 12, "Input" -> 32]

So how to extract of sub-net of NetGraph correctly?

A: For now, part syntax [[]] is mostly synonymous with NetExtract. NetExtract does not support slice syntax. For what it is worth, we are going to make an actual NetTake function at some point that is nice and clearly documented, I don't like using Take to hide this 'surgery' functionality, which doesn't work exactly like ordinary Take.
The second thing should be possible easily, but seems not to be at the moment owing to a bug with CatenateLayer, which cannot be constructed purely from graph inputs. Here are two ways you would do it once the bug is fixed:
Take[net, {{2, NetPort[1, "Output"]}, 5}]
VertexDelete[net, 1]


text:
Q: How do I set a location for an event in iOS Calendar? A date and time is incomplete without a location. How do I tell the iOS Calendar app where my event occurs, especially if the event does not have a street address that is resolvable by Apple Maps?
More detail: Right now I am physically located in Amsterdam, but I want to add some Burning Man events to my calendar. There are two levels of location at play here: the "street address" of the event within Black Rock City (say, "Yurtopia, 9:30 & E") and the location (hence timezone) of Black Rock City itself (somewhere in the northern Nevada desert.)
What combination of Calendar settings, location field entry and anything else can I make while in Amsterdam that will remind me at half-past midday on Wednesday the 27th of August 2014, for the entry "Hexayurt Happy Hour, 1-4pm, Yurtopia, 9:30 & E, Black Rock City, Nevada", when I'm actually in Black Rock City?

A: I think this is how to do it.
First thing to do is enable time zone support within Calendar. Open Settings, select "Mail, Contacts and Calendars". Find "Time Zone Support" under Calendars and turn it on. It should automatically set the timezone to your current location, that's fine.
Then create your event in Calendar. The only important fields for scheduling the event correctly are the time and the timezone. Location for example doesn't affect it. Just enter the correct time (13:00 - 16:00) and set the timezone to a nearby city iOS will recognise like Las Vegas. Once you click Done you should see the event in your calendar with the time automatically converted to the time in your current time zone.
Then once you are in the US you need to remember to manually set the Calendar timezone under "Mail, Contacts and Calendars" to Las Vegas or another city in the Pacific Standard Time timezone.
Then your events should appear with the correct time.


text:
Q: Azure DataLake gen2 Powershell Limits i'm getting a limitation with cmdlet of Azure Datalake gen2:
https://learn.microsoft.com/en-us/azure/storage/blobs/data-lake-storage-directory-file-acl-powershell
I'm using this cmdlet:
Get-AzDataLakeGen2ChildItem -Context $ctx -FileSystem $filesystemName -Path $dirname -Recurse -FetchProperty

to get all file and folder ACL from root but it has 5000 object limitation and it show this message when i run it to a folder with more than 5000 object:

basically, with that token i can continue from the last extracted(manually is crazy to do becouse maybe we have million file on datalake).
Is possible to avoid it or to loop in some way?
Here the script that i'm using(it works fine, i don't report all file ma only folder from root):
    $dir = Get-AzDataLakeGen2ChildItem -Context $ctx -FileSystem "datalake" -Recurse -FetchProperty

$FileOutdtk = "C:\Temp\file.csv"
Clear-Content $FileOutdtk

Add-Content $FileOutdtk ('"Path"^"IsDirectory"^"Owner"^"DisplayName Owner"^"Owner Permissions"^"Group"^"DefaultScope"^"AccessControlType"^"EntityId"^"DisplayName Gruppo"^"PermissionsACL"')

foreach ($directory in $dir) {

           if($directory.IsDirectory -eq $true){
            if($directory.Owner -imatch "superuser"){

           foreach ($ACLs in $directory.ACL){

                    if($ACLs.EntityId -eq $null ){

                    Add-Content $FileOutdtk ('"' + $directory.Path + '^' + $directory.IsDirectory + '^' + $directory.Owner + '^' + "" +  '^' + $directory.Permissions.Owner + '^' + $directory.Group + '^' + $ACLs.DefaultScope + '^' + $ACLs.accesscontroltype + '^' + $ACLs.EntityId + '^' + "" + '^' + $ACLs.Permissions + '"')

                    }
                    else{
                    $GruppiEntityId = Get-AzureADGroup -ObjectId $ACLs.EntityId

                    Add-Content $FileOutdtk ('"' + $directory.Path + '^' + $directory.IsDirectory + '^' + $directory.Owner + '^' + "" + '^' + $directory.Permissions.Owner + '^' + $directory.Group + '^' + $ACLs.DefaultScope + '^' + $ACLs.accesscontroltype + '^' + $ACLs.EntityId + '^' + $GruppiEntityId.displayname + '^' + $ACLs.Permissions + '"')

             }

        }

How i can loop that cmdlet to get up to 5000 object?
Thanks a lot

A: If you want to list all items in one Azure data lake gen2 folder, please refer to the following script
$storageAccount = Get-AzStorageAccount -ResourceGroupName "<>" -AccountName "<>"
$ctx = $storageAccount.Context

$fileSystem="test"
$dirName="testFolder"
$Token = $Null
$Max=2000
do{
  $items=Get-AzDataLakeGen2ChildItem -Context $ctx -FileSystem $fileSystem  -Path $dirName -Recurse -FetchProperty  -ContinuationToken $Token -MaxCount $Max
  $items
  if($items.Length -le 0) { Break;}
  $Token = $items[$items.Count -1].ContinuationToken;

}
While ($Token -ne $Null)


text:
Q: How do I insert values for a column that has multiple values? In a university database, I have a self referencing relationship for a subject and a pre-requisite.
Meaning that a subject can have 0 or more pre-requisites.
So I declared it in a table for subjects
 subject_code VARCHAR(7) NOT NULL CONSTRAINT subject_pk PRIMARY KEY,
 subject_name VARCHAR(50) NOT NULL,
 pre_requisite VARCHAR(7) NULL CONSTRAINT unit_pre_code FOREIGN KEY
               REFERENCES subject(subject_code),

So I am just wondering if I am right heading this way or should there be another table that deals with pre-requisites.
If I am in the right track, how do I insert a data that has a pre-requisite for the subject?
for example
C++(C12345) subject is a prerequisite to Operating Systems(C34512) or something.
I am still really new to this and I'm having a hard time looking for good and simple references for SQL. Any recommendations would be great too!

A: Your relationship is one to many i.e. 1 subject can have many prerequisites, you should therefore be using another table. e.g.
CREATE TABLE SubjectPrerequisite
(       Primary_Subject_Code        VARCHAR(7) NOT NULL,
        Prerequisite_Subject_Code   VARCHAR(7) NOT NULL,
    CONSTRAINT PK_SubjectPrerequisite PRIMARY KEY (Primary_Subject_Code, Prerequisite_Subject_Code),
    CONSTRAINT FK_SubjectPrerequisite_Primary_Subject_Code FOREIGN KEY (Primary_Subject_Code) REFERENCES Subject (Subject_Code),
    CONSTRAINT FK_SubjectPrerequisite_Prerequisite_Subject_Code FOREIGN KEY (Prerequisite_Subject_Code) REFERENCES Subject (Subject_Code)
)

This will still maintain your referential integrity by having all the correct keys, but will make querying the database much easier where 1 subject has multiple prerequisites. e.g.
-- WILL RETURN ALL SUBJECTS AVAILABLE GIVEN A CERTAIN PERSONS
-- COMPLETED SUBJECTS.
SELECT  DISTINCT s.*
FROM    Subject s
        INNER JOIN SubjectPrerequisite sp
            ON s.Subject_Code = sp.Primary_Subject_Code
WHERE   sp.Prerequisite_Subject_Code IN ('C12345', 'C12346')

-- WILL RETURN ALL PRERQUISITE SUBJECTS FOR ANY GIVEN SUBJECT
SELECT  s.*
FROM    SubjectPrerequisite sp
        INNER JOIN Subject s
            ON s.Subject_Code = sp.Prerequisite_Subject_Code
WHERE   sp.Primary_Subject_Code = 'C34512'


text:
Q: What does it mean an $\bf{isolated \; point}$ for a map defined on a manifold? Let $M$ be a smooth manifold and $f : M \to M$ a $C^k$ diffeomorphism.
1) What does it mean an $\bf{isolated \; point}$ for $f$?
2) Why are the transverse fixed points isolated?
Thank you!

A: Let $M$ be a smooth manifold, $f:M \to M$ a $C^{k}$ difeomorphism.

*

*A fixed point $p$ of $f$ is isolated if there exists a neighborhood $U$ of $p$ such that $p$ is the only fixed point of $f$ in $U$.

*A fixed point $p$ of $f$ is transverse if the graph of $f$ in $M \times M$ is transverse to the diagonal
$$
\Delta = \{(p, q) \in M \times M : p = q\},
$$
namely if $df(p) - I$ is non-singular. In this event, there exists a neighborhood $U$ of $p$ such that in $U \times U$, the graph of $f$ intersects the diagonal of $f$ precisely at $(p, p)$; that is, $p$ is the unique fixed point of $f$ in $U$.


text:
Q: What does $C_n(X)$ in a simplicial complex really mean? My Algebraic Topology textbook says:

Let $X$ be a simplicial complex. The group $C_n(X)$ of oriented $n$-chains of $X$ is the free abelian group generated by the oriented $n$-simplexes of $X$.

For example, an element of $C_2(S)$ would be $9P_2P_3P_4-4P_1P_3P_4-5P_1P_2P_3$.
What does $9P_2P_3P_4-4P_1P_3P_4-5P_1P_2P_3$ even mean?? What does it mean to multiply a 2-simplex with a scalar? Do we expand the area of the simplex by $9$ times? Is area even defined in a simplicial complex?
Thanks in advance!

A: When they write $5\cdot S$ where $S$ is a simplex they do not mean to actually do anything with the simplex $S$, it is just a formal expression with which you can calculate.
$S$ becomes nothing but an abstract symbol for symbolic calculation. So $5\cdot S+3\cdot S=8\cdot S$, for example. This is not a way of writing, $5$ times the area of $S$ plus $3$ times the area of $S$ is $8$ times the area of $S$. Instead, it just means $5$ times of an object called $S$ plus $3$ times an object called $S$ makes $8$ times an object called $S$.
Given any set whatsoever, you can form a free abelian group on it just looking at formal linear combinations of its elements.
Example:
Suppose your set of simplices is $X=\{A,B,C\}$. Then the free abelian group over $X$ is the set given by all the linear combinations
$$x_1A+x_2B+x_3C$$
The $+$'s in this expression do not mean any transformation to be done with the simplices. Imagine the $A,B,C$ being the basis of a vector space of dimension $3$. You can just as well write the vector $x_1A+x_2B+x_3C$ in the form $(x_1,x_2,x_3)$.
Now you make this into a group by saying that addition is defined componentwise:
$$(x_1A\color{red}{+}x_2B\color{red}{+}x_3C)\color{red}{+}(y_1A\color{red}{+}y_2B\color{red}{+}y_3C):=(x_1+y_1)A\color{red}{+}(x_2+y_2)B\color{red}{+}(x_3+y_3)C$$
This makes the set of these combinations into an abelian group. To avoid confusion, I drew the $+$'s between elements of the free group in red and the $+$'s of integers in black.
Entirely equivalently, if we had decided to denote the elements of our free abelian group as $(x_1,x_2,x_3)$ instead, the definition of addition would look like
$$(x_1,x_2,x_3)+(y_1,y_2,y_3)=(x_1+y_1,x_2+y_2,x_3+y_3)$$
We can connect these notations by defining $A:=(1,0,0)$, $B:=(0,1,0)$ and $C:=(0,0,1)$. Indeed, then
$$x_1A+x_2B+x_3C=(x_1,x_2,x_3)$$
So whenever we make the free abelian group over a set with $k$ elements, say, then that means we are taking all the $k$-tuples of integers with componentwise addition. Naturally this also works with infinitely large sets, but then we consider only finite linear combinations.
As always in algebra, what matters is not how you name your elements or where they come from, the point is only what you do with them. The structure of the algebraic operations is important and nothing else.


text:
Q: Unable to query a local variable in pandas 0.14.0 I can query an explicit value:
fills.query('Symbol=="BUD US"')

Now I want to query a variable:
In [40]: my_symbol
Out[40]: 'BUD US'

In pandas 0.13.1, I could simply use:
fills.query('Symbol==my_symbol')

This is no longer permitted in pandas 0.14.0 because local variables must be referred to explicitly. So I tried
fills.query('Symbol==@my_symbol')

but this returned an error
KeyError: '__pd_eval_local_my_symbol'

I was able to change some of my other code to use explicit local variables, but this one just will not take. Any thoughts? The dtype is object, if that helps.

A: The above answer is pretty much right on, but wanted to mention another workaround that I've used in this situation. Basically, just treat the query string like you would any other string where you'd want to insert a variable.
my_symbol = 'BUD US'
fills.query("Symbol=='{0}'".format(my_symbol))

edit: fixed per your comment

A: Seems a bug in 0.14, specifically with strings (works eg with ints). I filed an issue here: https://github.com/pydata/pandas/issues/7300.
As a workaround for now, you can wrap it in a list:
In [40]: fills
Out[40]:
    Price  Symbol
0  109.70  BUD US
1  109.72  BUD US
2  183.30  IBM US
3  183.35  IBM US

In [41]: my_symbol = ['BUD US']

In [42]: fills.query('Symbol==@my_symbol')
Out[42]:
    Price  Symbol
0  109.70  BUD US
1  109.72  BUD US


text:
Q: How to play notification sound from local file     sound = Uri.parse("file://" + audioFilePath.getAbsolutePath());
    /*sound = Uri.fromFile(audioFilePath);*/
    NotificationCompat.Builder mBuilder =
                    new NotificationCompat.Builder(this);
            mBuilder
                    .setSmallIcon(R.drawable.notification_icon)
                    .setContentTitle(title)
                    .setContentText(description)
                    .setContentIntent(resultPendingIntent)
                    .setSound(sound);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                mBuilder.setPriority(Notification.PRIORITY_HIGH);
            }
            NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            mNotificationManager.notify(1, mBuilder.build());

The sound file is present in local storage. Notification working properly but sound doesn't play. I tried both way to parse Uri from file path.

A: If you put your sound in your resource folder (which you should do anyway for notification sounds) and use Notification.Builder instead of NotificationCompat.Builder, you should be able to access it like this:
Uri soundUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
                       getPackageName() + "/" + R.raw.name_of_sound);
Notification.Builder mBuilder =
                new Notification.Builder(this);
        mBuilder
                .setSmallIcon(R.drawable.notification_icon)
                .setContentTitle(title)
                .setContentText(description)
                .setContentIntent(resultPendingIntent)
                .setSound(sound);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            mBuilder.setPriority(Notification.PRIORITY_HIGH);
        }
        NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        mNotificationManager.notify(1, mBuilder.build());

Source


text:
Q: Using 3D designs in java I am currently trying to practice 3D program designs in java, but unfortunately when I try to import the following packages, it gives says that the package does not exist.
import com.sun.j3d.utils.geometry.ColorCube;

import javax.media.j3d.BranchGroup;

import com.sun.j3d.utils.universe.SimpleUniverse;

Could anyone help me to resolve this problem?

A: The 3D API is not part of the standard API. You'll need to download and install it before using classes from it in your code.
See: http://java.sun.com/javase/technologies/desktop/java3d/index.jsp


text:
Q: redux saga deleting functionality I am working on React/Redux application, I have to delete user address, I am using redux saga as a middleware, the functionality is working fine, but the issue is after deleting address the request is not entering deleteAddressByBuyerIdAddressIdSuccess(in saga.js file), it is entering only deleteAddressByBuyerIdAddressId and deleteAddressByBuyerIdAddressIdFailure(have checked in redux developer tools), can any one help me to sort out this issue,
My all functionality and screenshot of redux developer tools is given below
Action File
/* Delete an address for a buyer */
const deleteAddressByBuyerIdAddressId =
    (buyerId: string, addressId: string, address: Object, params: string) => ({
        type: Types.DELETE_ADDRESS_BY_BUYER_ID_ADDRESS_ID,
        buyerId,
        addressId,
        address,
        params,
    });

const deleteAddressByBuyerIdAddressIdSuccess =
    (buyerId: string, addressId: string, address: Object, params: string) => ({
        type: Types.DELETE_ADDRESS_BY_BUYER_ID_ADDRESS_ID_SUCCESS,
        buyerId,
        addressId,
        address,
        params,
    });

const deleteAddressByBuyerIdAddressIdFailure =
    (errorMessage: Object) => ({
        type: Types.DELETE_ADDRESS_BY_BUYER_ID_ADDRESS_ID_FAILURE,
        errorMessage,
    });

Saga file
/* Delete Buyers address */
function* deleteAddressByBuyerIdAddressId(action) {
    try {
        const response = yield call(
          api.account.deleteAddressByBuyerIdAddressId,
          action.buyerId,
          action.addressId,
          action.address,
          action.params
        );
        if (response.ok && response.data  && {}.hasOwnProperty.call(response.data, 'data')) {
            yield put(
          Actions.deleteAddressByBuyerIdAddressIdSuccess(
              action.buyerId,
              action.addressId,
              response.data,
              action.address,
              action.params
          )
      );
        } else {
            yield put(Actions.deleteAddressByBuyerIdAddressIdFailure(response.errorMessage));
        }
    } catch (error) {
        yield put(Actions.deleteAddressByBuyerIdAddressIdFailure(error));
    }
}
function* watchDeleteAddressByBuyerIdAddressId(): Generator<void, void, void> {
    yield takeLatest(Types.DELETE_ADDRESS_BY_BUYER_ID_ADDRESS_ID, deleteAddressByBuyerIdAddressId);
}

Reducers
export const deleteAddressByBuyerIdAddressId = (state: Object = INITIAL_STATE) => ({
    ...state,
    isLoading: true,
    successMessage: null,
    errorMessage: null,
});

export const deleteAddressByBuyerIdAddressIdSuccess = (state: Object = INITIAL_STATE, action: Object) => {
     const successMessage = I18n.getText('account.address-deleted', {}, 'Address deleted!');
     return {
        ...state,
        address: action.address,
        successMessage: successMessage,
      }
};

export const deleteAddressByBuyerIdAddressIdFailure = (state: Object = INITIAL_STATE, action: Object) => ({
    ...state,
    errorMessage: action.errorMessage,
    isLoading: false,
});

redux developer tools view

A: You don't need that if, else part. Instead if the request is successful, merely call the success action within the try block itself. Otherwise inside your catch block invoke the failure action. That would do the job for you. Here's the sample code.
/* Delete Buyers address */
function* deleteAddressByBuyerIdAddressId(action) {
    try {
        const response = yield call(
          api.account.deleteAddressByBuyerIdAddressId,
          action.buyerId,
          action.addressId,
          action.address,
          action.params
        );
            yield put(
          Actions.deleteAddressByBuyerIdAddressIdSuccess(
              action.buyerId,
              action.addressId,
              response.data,
              action.address,
              action.params
          )
      );
    } catch (error) {
        yield put(Actions.deleteAddressByBuyerIdAddressIdFailure(error));
    }
}
function* watchDeleteAddressByBuyerIdAddressId(): Generator<void, void, void> {
    yield takeLatest(Types.DELETE_ADDRESS_BY_BUYER_ID_ADDRESS_ID, deleteAddressByBuyerIdAddressId);
}


text:
Q: Magento 2.3.1 - Checkout dropdown cart image aspect ratio is incorrect Adding a product where it's image is wide (landscape), gets squeezed into a portrait sized place holder.
As below.

How can I get the image to fit into the cart image placeholder and maintain its aspect ratio?

A: You can modify your mini_cart_product_thumbnail image dimensions.

YOUR_MAGENTO_THEME_DIRECTORY > etc > view.xml

<media>
    <images module="Magento_Catalog">
        <image id="mini_cart_product_thumbnail" type="thumbnail">
            <width>75</width>
            <height>75</height>
        </image>
     </images>
</media>


text:
Q: Console Error in $element, while using $mdDialog of AngularJS Material I'm trying to solve this error that shows in the console, it only occurs on the server, in my localhost the modal works correctly. Here's the error (click to open its link):

I have a view with the controller:
.when('/aseguradora', {
    templateUrl: 'views/insuranceagentdashboard.html',
    controller: 'InsuranceagentdashboardCtrl'
})

This is the controller:
angular.module('virtualApp').controller('InsuranceagentdashboardCtrl', ['$http', '$scope', 'pager', 'Dialogs', function($http, $scope, pager, Dialogs) {..

Inside the controller I have a function that executes the modal, (Dialogs is a service):
$scope.showCosignerFormDialog = function(insuranceRequest) {
    Dialogs.cosignerFormdialog(insuranceRequest);
}

In HTML I have an md-button with an ng-click
<md-button class="md-color-green" ng-click="showCosignerFormDialog(insuranceRequest)">VER SOLICITUD</md-button>

This is the Dialog service that executes the modal:
dialogs.cosignerFormdialog = function(insuranceRequest) {
    return $mdDialog.show({
        templateUrl: 'views/cosignerformdialog.html',
        autoWrap: false,
        controller: 'IdentityVerificationWizardCtrl',
        locals: {
            listing: insuranceRequest
        },
        preserveScope: true,
        escapeToClose: false,
        fullscreen: true,
        clickOutsideToClose: true
    });
};

I do not know why this error can occur in the console being in the URL of the server, if I am in my localhost I do not get this error ...
THIS IS CONTROLLER identityverificationwizard.js:
angular.module('virtualApp').controller('IdentityVerificationWizardCtrl', ['$scope', 'upload', '$http', 'listing', '$routeParams', '$location', 'Dialogs', '$element', function($scope, upload, $http, listing, $routeParams, $location, Dialogs, $element) {
    $scope.propertyListing = listing;
    $scope.insuranceStudyContactInfo = {};
    $scope.insuranceStudyJobInfo = {};
    $scope.insuranceStudyFinancialInfo = {};
    $scope.insuranceStudyAssets = {};
    $scope.identityInfo = {
        date : moment('01/01/2000', 'DD/MM/YYYY').toDate()
    };
    $scope.virtualSignatureInfo = {};
    $scope.isCorporation = 'false';
    $scope.insuranceStudyJobInfo.publicOfficer = false;
    $scope.insuranceStudyJobInfo.managesPublicFunds = false;
    $scope.insuranceStudyJobInfo.linkedToRenownedPeople = false;
    $scope.insuranceStudyJobInfo.vatResponsible = false;
    $scope.insuranceStudyJobInfo.greatContributor = false;

    $scope.insuranceStudyFinancialInfo.doImport = false;
    $scope.insuranceStudyFinancialInfo.doExport = false;
    $scope.insuranceStudyFinancialInfo.doInvest = false;
    $scope.insuranceStudyFinancialInfo.doCurrencyExchange = false;
    $scope.insuranceStudyFinancialInfo.doPayServices = false;
    $scope.insuranceStudyFinancialInfo.doPayLoans = false;
    $scope.insuranceStudyFinancialInfo.doTransactions = false;

    $scope.rentProcessId = $scope.propertyListing.rentProcessId;
    $scope.cosignerKey = $location.search().cosignerKey;

    if ($scope.rentProcessId || $scope.cosignerKey) {
        $scope.readOnly = false;
    } else {
        $scope.readOnly = true;
    }

    $scope.setTabIndex = function(index) {
        $scope.tabIndex = index;
    }

    $scope.fileChanged = function(kind, file) {

        var reader = new FileReader();
        reader.onload = function(e) {
            if (kind == 'front') {
                $scope.frontIdFile = file;
                $scope.frontIdImage = e.target.result;
                $scope.$apply();
            } else {
                $scope.backIdFile = file;
                $scope.backIdImage = e.target.result;
                $scope.$apply();
            }
        };
        reader.readAsDataURL(file.files[0]);
        $scope.$apply();
    }

    $scope.uploadForm = function() {
        var params = {};

        if ($scope.insuranceStudyContactInfo.city) {
            $scope.insuranceStudyContactInfo.cityCode = $scope.insuranceStudyContactInfo.city.cityCode;
        }

        if ($scope.insuranceStudyJobInfo.city) {
            $scope.insuranceStudyJobInfo.cityCode = $scope.insuranceStudyJobInfo.city.cityCode;
        }
        if ($scope.insuranceStudyAssets.hasProperties) {
            if ($scope.insuranceStudyAssets.property1 && $scope.insuranceStudyAssets.property1.city) {
                $scope.insuranceStudyAssets.property1.cityCode = $scope.insuranceStudyAssets.property1.city.cityCode || null;
            } else {
                delete $scope.insuranceStudyAssets.property1;
            }

            if ($scope.insuranceStudyAssets.property2 && $scope.insuranceStudyAssets.property2.city) {
                $scope.insuranceStudyAssets.property2.cityCode = $scope.insuranceStudyAssets.property2.city.cityCode || null;
            } else {
                delete $scope.insuranceStudyAssets.property2;
            }
        } else {
            delete $scope.insuranceStudyAssets.property1;
            delete $scope.insuranceStudyAssets.property2;
        }

        if ($scope.propertyListing.rentProcessId) {
            params.rentProcessId = $scope.propertyListing.rentProcessId;
        }

        if ($location.search().cosignerKey) {
            params.cosignerKey = $location.search().cosignerKey;
        }

        if ($scope.identityInfo.date) {
            $scope.identityInfo.birthDate = formatedDate($scope.identityInfo.date, 'DD/MM/YYYY');
        }
        $scope.insuranceStudyFinancialInfo.doImport = $scope.insuranceStudyFinancialInfo.doImport || false;
        $scope.insuranceStudyFinancialInfo.doExport = $scope.insuranceStudyFinancialInfo.doExport || false;
        $scope.insuranceStudyFinancialInfo.doInvest = $scope.insuranceStudyFinancialInfo.doInvest || false;
        $scope.insuranceStudyFinancialInfo.doCurrencyExchange = $scope.insuranceStudyFinancialInfo.doCurrencyExchange || false;
        $scope.insuranceStudyFinancialInfo.doPayServices = $scope.insuranceStudyFinancialInfo.doPayServices || false;
        $scope.insuranceStudyFinancialInfo.doPayLoans = $scope.insuranceStudyFinancialInfo.doPayLoans || false;
        $scope.insuranceStudyFinancialInfo.doTransactions = $scope.insuranceStudyFinancialInfo.doTransactions || false;

        params.isCorporation = $scope.isCorporation;
        params.contactInfo = JSON.stringify($scope.insuranceStudyContactInfo);
        params.jobInfo = JSON.stringify($scope.insuranceStudyJobInfo);
        params.financialInfo = JSON.stringify($scope.insuranceStudyFinancialInfo);
        params.assets = JSON.stringify($scope.insuranceStudyAssets);
        params.virtualSignatureInfo = JSON.stringify($scope.virtualSignatureInfo);
        params.identityInfo = JSON.stringify($scope.identityInfo);

    $scope.isReadOnly = function() {
        if ($scope.readOnly) {
            $http.get(root + "Insurance/s/getInsuranceRequest", {
                params: {
                    insuranceRequestId: $scope.propertyListing.insuranceRequestId
                }
            }).then(function(res) {
                $scope.code = res.data.code;
                $scope.type = res.data.type;
                $scope.datetime = res.data.datetime;
                $scope.status = res.data.status;
                $scope.listingCode = res.data.listingCode;
                $scope.isCorporation = res.data.corporation + "";
                $scope.identityInfo.documentTypeCode = res.data.identityInfo.documentTypeCode;
                $scope.identityInfo.documentNumber = res.data.identityInfo.documentNumber;
                $scope.identityInfo.names = res.data.identityInfo.names;
                $scope.identityInfo.lastNames = res.data.identityInfo.lastNames;
                $scope.identityInfo.date = res.data.identityInfo.birthDate;
                $scope.insuranceStudyContactInfo = res.data.contactInfo;
                $scope.insuranceStudyJobInfo = res.data.jobInfo;
                $scope.insuranceStudyFinancialInfo = res.data.financialInfo;

                if ($scope.insuranceStudyFinancialInfo.foreignAccountBank) {
                    $scope.insuranceStudyFinancialInfo.doForeignAccount = true;
                }
                if ($scope.insuranceStudyFinancialInfo.foreignAccount) {
                    $scope.insuranceStudyFinancialInfo.doForeignAccount = true;
                }
                if ($scope.insuranceStudyFinancialInfo.foreignAccountCurrency) {
                    $scope.insuranceStudyFinancialInfo.doForeignAccount = true;
                }
                if ($scope.insuranceStudyFinancialInfo.foreignAccountCountry) {
                    $scope.insuranceStudyFinancialInfo.doForeignAccount = true;
                }
                if ($scope.insuranceStudyFinancialInfo.foreignAccountCity) {
                    $scope.insuranceStudyFinancialInfo.doForeignAccount = true;
                }
                if ($scope.insuranceStudyFinancialInfo.doImport) {
                    $scope.insuranceStudyFinancialInfo.doInternationalOperations = true;
                }
                if ($scope.insuranceStudyFinancialInfo.doExport) {
                    $scope.insuranceStudyFinancialInfo.doInternationalOperations = true;
                }
                if ($scope.insuranceStudyFinancialInfo.doInvest) {
                    $scope.insuranceStudyFinancialInfo.doInternationalOperations = true;
                }
                if ($scope.insuranceStudyFinancialInfo.doCurrencyExchange) {
                    $scope.insuranceStudyFinancialInfo.doInternationalOperations = true;
                }
                if ($scope.insuranceStudyFinancialInfo.doPayServices) {
                    $scope.insuranceStudyFinancialInfo.doInternationalOperations = true;
                }
                if ($scope.insuranceStudyFinancialInfo.doPayLoans) {
                    $scope.insuranceStudyFinancialInfo.doInternationalOperations = true;
                }
                if ($scope.insuranceStudyFinancialInfo.doTransactions) {
                    $scope.insuranceStudyFinancialInfo.doInternationalOperations = true;
                }

                $scope.insuranceStudyAssets = res.data.assets;

                if ($scope.insuranceStudyAssets.property1 || $scope.insuranceStudyAssets.property2) {
                    $scope.insuranceStudyAssets.hasProperties = true;
                }

                if ($scope.insuranceStudyAssets.vehicle1 || $scope.insuranceStudyAssets.vehicle2) {
                    $scope.insuranceStudyAssets.hasCars = true;
                }

                $scope.availableActions = res.data.availableActions;
            });
        }
    }
    $scope.isReadOnly();
}]);

A: That error says your are using an unknown dependency in your controller.
Here, the error says that the "unknown dependency" is a provider called $element.
! There are 3 types of providers in angularjs: service, factory or provider
2 reasons why you can have this problem:
1) If you don't have any providers (service, factory or provider) called $element in your project you shouldn't have a dependency for it.
In IdentityVerificationWizardCtrl
Instead of:
.controller('IdentityVerificationWizardCtrl', ['$scope', 'upload', '$http', 'listing', '$routeParams', '$location', 'Dialogs', '$element', function($scope, upload, $http, listing, $routeParams, $location, Dialogs, $element)

Write:
.controller('IdentityVerificationWizardCtrl', ['$scope', 'upload', '$http', 'listing', '$routeParams', '$location', 'Dialogs', function($scope, upload, $http, listing, $routeParams, $location, Dialog)

2) if you have a provider called $element , maybe you didn't call it into your index.html
PS: In angularjs, $element is a parametter used into the link function and refer to the DOM element. So IMO opinion your error is because of reason 1


text:
Q: Is $\int_0^\infty x^{a-1} (1-x)^{b-1} e^{t-cx} dx$ integrable? I am trying to evaluate the  integral below. Is it even integrable? (Online integral solvers  e.g. WolframAlpha could not solve the indefinite or the definite integral.)
$$\int_0^\infty x^{a-1} (1-x)^{b-1} \, e^{t-cx} dx$$
where $a > 0$, $b > 0$, $c > 0$, and $t$ is any real number.

A: Mathematica found an answer as:
$$\left.e^t \left(-(-1)^b c^{-a-b+1} \Gamma (a+b-1) \, _1F_1(1-b;-a-b+2;-c)+\frac{\Gamma (a) \Gamma (b) \, _1F_1(a;a+b;-c)}{\Gamma (a+b)}-\frac{(-1)^b \Gamma (b) \Gamma (-a-b+1) \, _1F_1(a;a+b;-c)}{\Gamma (1-a)}\right),\\\Re(b)>0\land \Re(c)>0\land \Re(a)>0\right]$$
Which doesn't look too "closed" to me but may be a starting point for others.

A: $\int_0^\infty x^{a-1}(1-x)^{b-1}e^{t-cx}~dx$
$=e^t\int_0^\infty x^{a-1}(1-x)^{b-1}e^{-cx}~dx$
$=e^t\int_0^1x^{a-1}(1-x)^{b-1}e^{-cx}~dx+e^t\int_1^\infty x^{a-1}(1-x)^{b-1}e^{-cx}~dx$
$=e^t\int_0^1x^{a-1}(1-x)^{b-1}e^{-cx}~dx-(-1)^be^t\int_1^\infty x^{a-1}(x-1)^{b-1}e^{-cx}~dx$
$=e^t\int_0^1x^{a-1}(1-x)^{b-1}e^{-cx}~dx-(-1)^be^t\int_0^\infty(x+1)^{a-1}x^{b-1}e^{-c(x+1)}~d(x+1)$
$=e^t\int_0^1x^{a-1}(1-x)^{b-1}e^{-cx}~dx-(-1)^be^{t-c}\int_0^\infty x^{b-1}(x+1)^{a-1}e^{-cx}~dx$
$=\dfrac{e^t\Gamma(a)\Gamma(b)M(a,a+b,-c)}{\Gamma(a+b)}-(-1)^be^{t-c}\Gamma(b)U(b,a+b,c)$ (according to http://en.wikipedia.org/wiki/Confluent_hypergeometric_function#Integral_representations)

A: You've asked about
$$\int_0^\infty x^{a-1} (1-x)^{b-1} e^{t-cx} \: dx$$
And if $b$ is an integer,
$$ e^t \int_0^\infty x^{a-1} \left (\sum_{k=0}^{b-1} (-1)^k {b-1 \choose k} x^k \right) e^{-cx} \: dx$$
by applying the binomial theorem to $(1-x)^{b-1}$.  After a bit of rearrangement this becomes
$$ e^t \sum_{k=0}^{b-1} (-1)^k {b-1 \choose k} \int_0^\infty  e^{-cx} x^{a+k-1} \: dx$$
and this last integral can be written in terms of the gamma function.  This gives a formula for your function as a sum of $b$ terms.