text:
Q: BufferedReader blocking when reading from process.getErrorStream() When I run this code and the call graph is really large, the program prints to the last line that opt outputs and is blocked at readLine, even though there is nothing left. Anyone know what the problem is? opt -print-callgraph file sends the call graph to the error stream. I tried executing opt -print-callgraph file 2> callgraph so that I can read from a file instead but it complains that there are too many positional arguments.
Oddly enough, the code runs fine for call graphs that are small in size.
I tried using ProcessBuilder as well but I get the same problem.
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec("opt -print-callgraph " + file);
BufferedReader in = new BufferedReader(new InputStreamReader(process.getErrorStream()));
String s = null;
try {
    // Gets stuck at readLine after printing out the last line.
    while ((s = in.readLine()) != null) {
        System.out.println(s);
    }
} catch (Exception e) {
    e.printStackTrace();
} finally {
    in.close();
}

A: You need to read both streams, in separate threads, or else merge them so you're reading them both at the same time. Otherwise the process can block if output is unconsumed. In this case there must be unconsumed output in stdout which is blocking the process, which means it won't finish, which means it won't close stderr, which means reading stderr will block.


text:
Q: My python function won't return or update the value def getMove(win,playerX,playerY):

    #Define variables.
    movePos = 75
    moveNeg = -75
    running = 1

    #Run while loop constantly to update mouse's coordinates.
    while(running):

        mouseCoord = win.getMouse()
        mouseX = mouseCoord.getX()
        mouseY = mouseCoord.getY()
        print "Mouse X = ", mouseX
        print "Mouse Y = ", mouseY

        if mouseX >= playerX:
            playerX = movePos + playerX
            running = 0
        elif mouseX <= playerX:
            playerX = moveNeg + playerX
            running = 0
        elif mouseY >= playerY:
            playerY = movePos + playerY
            running = 0
        elif mouseY <= playerY:
            playerY = moveNeg + playerY
            running = 0
    return playerX,playerY

def main():

    #Create game window.
    win = GraphWin("Python Game", 500, 500)
    drawBoard(win)

    #Define variables.
    playerX = 75
    playerY = 125
    keyX = 325
    keyY = 375
    running = 1

    #Create Key and Player objects, draw the key, but don't draw the player yet.
    key = Text(Point(keyX,keyY),"KEY")
    key.draw(win)

    while(running):
        print "player X = ", playerX
        print "Player Y = ", playerY
        drawBoard(win)
        getMove(win,playerX,playerY)
        player = Circle(Point(playerX,playerY),22)
        player.setFill('yellow')
        player.draw(win)
main()

I am using a graphics library to create a game. My player and key are drawn in the correct places. However, when calling the getMove function, my playerX and playerY do not update. I have added debug print statements to find their values while running the game and it is always 75 and 125. Help!

A: In python, integers are immutable - when you assign a new integer value to a variable, you are just making the variable point to a new integer, not changing what the old integer it pointed to's value was.
(An example of a mutable object in python is the list, which you can modify and all variables pointing to that list will notice the change - since the LIST has changed.)
Similarly, when you pass a variable into a method in python and then alter what the variable points to in that method, you do not alter what the variable points to outside of that method because it is a new variable.
To fix this, assigned the returned playerX,playerY to your variables outside the method:
playerX, playerY = getMove(win,playerX,playerY)

A: You should explicitly reassign these variables when you call getMove():
playerX, playerY = getMove(win, playerX, playerY)

Hope this helps!

A: As has been mentioned, the solution is that you're not using the returned values to update your playerX, playerY which can be fixed with the mentioned
playerX, playerY = getMove(win,playerX,playerY)

What I want to address is the logic in your if statements. The way you've constructed your if statements will lead to only an X OR Y being updated, not both. For example, if mouseX, mouseY were both greater than playerX, playerY repectively, you'd get to the first line of your if statement and it would be evaluated as True and update playerX accordingly, BUT because the first statement has been executed, none of the other elif statements will execute, leading to you only updating the playerX variable.
What you want to do is split the if statement into two separate statements (one for X and one for Y) so that the adjustments of X,Y are independent of each other. Something similar to
    if mouseX >= playerX:
        playerX = movePos + playerX
        running = 0
    elif mouseX <= playerX:
        playerX = moveNeg + playerX
        running = 0

    #By having the second if, it allows you to check Y even if X has changed
    if mouseY >= playerY:
        playerY = movePos + playerY
        running = 0
    elif mouseY <= playerY:
        playerY = moveNeg + playerY
        running = 0

redpajama_set_name: RedPajamaStackExchange


text:
Q: An Inconsistency in Numerical Approximation Consider the expression
$$
10^5 - \frac{10^{10}}{1+10^5}.
$$
Using the elementary properties of fractions we can evaluate the expression as
$$
10^5 - \frac{10^{10}}{1+10^5} = \frac{10^5 + 10^{10} - 10^{10}}{1+10^5} = \frac{10^5}{1+10^5}\approx 1.
$$
Note that the approximation $10^5+1 \approx 10^5$ is used in the last step. Now suppose we use the same approximation, but apply it before we perform the subtraction. We get
$$
10^5 - \frac{10^{10}}{1+10^5} \approx 10^5 - \frac{10^{10}}{10^5} = 0.
$$
The same logic works for
$$
10^p - \frac{10^{2p}}{1+10^p}
$$
for arbitrary large $p$, so it cannot be simply an issue with the accuracy of the approximation.
Is there an easy explanation of what's going on here?

A: It is simply an issue of accuracy of approximation.  Let me write $x = 10^p$.  Then your expression is
$$ x - \frac{x^2}{1+x}$$
Note that $$\frac{x^2}{1+x} = \frac{x}{1/x + 1} = x (1 - 1/x + O(1/x^2)) = x - 1 + O(1/x)$$
so that
$$ x - \frac{x^2}{1+x} = x - (x - 1 + O(1/x)) = 1 + O(1/x)$$
In your second calculation you only evaluated $x^2/(1+x)$ to within $O(1)$, not $O(1/x)$, so naturally you have an error at the end that is $O(1)$.

A: The first approximation is fine. The second on is not, because, $10^5$ and $\dfrac{10^{10}}{1+10^5}$ are large numbers with approximately the same size. You are saying that since $10\,001$ is close to $10\,000$, then $1$ is close to $0$.

A: There is no paradox.
When you approximate $$\frac{10^5}{1+10^5}=1-0.000099999000\cdots$$ with $1$, the error is on the order of $10^{-5}$.
But in the second case, the same error is multiplied by $10^5$, so that it is no more negligible.


text:
Q: chrony time synchronization problems We have a cluster where exact time synchronization is very important. We use Ubuntu 20.04 servers and and chrony. Unfortunately there are always problems with time synchronization. No other known time synchronization service is running. I can also provide the Chrony logs It would be very nice if someone can help me.

host1-mstr01 ntpq environment: line 7: ntpq: command not found
ntpstat environment: line 10: ntpstat: command not found
● systemd-timesyncd.service
Loaded: masked (Reason: Unit systemd-timesyncd.service is masked.)
Active: inactive (dead)
timedatectl
Local time: Tue 2020-12-22 09:43:50 CET
Universal time: Tue 2020-12-22 08:43:50 UTC
RTC time: Tue 2020-12-22 08:43:50
Time zone: Europe/Berlin (CET, +0100) System clock synchronized: yes
NTP service: active
RTC in local TZ: no
chronyc tracking Reference ID    : 0A0010FE (host1-timeserver) Stratum
: 3 Ref time (UTC)  : Tue Dec 22 08:43:41 2020 System time     :
0.000016022 seconds slow of NTP time Last offset     : -0.000016416 seconds RMS offset      : 0.000014285 seconds Frequency       : 34.582
ppm slow Residual freq   : +0.002 ppm Skew            : 0.042 ppm Root
delay      : 0.004369508 seconds Root dispersion : 0.016251557 seconds
Update interval : 514.3 seconds Leap status     : Normal
chronyc sources 210 Number of sources = 1 MS Name/IP address
Stratum Poll Reach LastRx Last sample
=============================================================================== ^* host1-timeserver      2   8   377     9  -7039ns[  -23us] +/-
34ms
host2-mstr01 ntpq environment: line 7: ntpq: command not found
environment: line 10: ntpstat: command not found
ntpstat
● systemd-timesyncd.service
Loaded: masked (Reason: Unit systemd-timesyncd.service is masked.)
Active: inactive (dead) since Tue 2020-09-29 17:46:17 CEST; 2 months 22 days ago    Main PID: 12619 (code=exited, status=0/SUCCESS)
Status: "Shutting down..."
Aug 11 13:31:33 host2-mstr01 systemd[1]: Started Network Time
Synchronization. Aug 11 13:31:33 host2-mstr01
systemd-timesyncd[12619]: Initial synchronization to time server
10.0.16.254:123 (host1-NTP01). Sep 17 10:44:52 host2-mstr01 systemd-timesyncd[12619]: Timed out waiting for reply from
10.0.16.254:123 (host1-NTP01). Sep 17 13:00:51 host2-mstr01 systemd-timesyncd[12619]: Initial synchronization to time server
10.0.16.254:123 (host1-NTP01). Sep 21 04:03:23 host2-mstr01 systemd-timesyncd[12619]: Initial synchronization to time server
10.0.16.254:123 (host1-NTP01). Sep 26 10:58:27 host2-mstr01 systemd-timesyncd[12619]: Initial synchronization to time server
10.0.16.254:123 (host1-NTP01). Sep 27 02:49:01 host2-mstr01 systemd-timesyncd[12619]: Initial synchronization to time server
10.0.16.254:123 (host1-NTP01). Sep 29 17:46:17 host2-mstr01 systemd[1]: Stopping Network Time Synchronization... Sep 29 17:46:17
host2-mstr01 systemd[1]: systemd-timesyncd.service: Succeeded. Sep 29
17:46:17 host2-mstr01 systemd[1]: Stopped Network Time
Synchronization.
timedatectl
Local time: Tue 2020-12-22 09:43:51 CET
Universal time: Tue 2020-12-22 08:43:51 UTC
RTC time: Tue 2020-12-22 08:43:51
Time zone: Europe/Berlin (CET, +0100) System clock synchronized: yes
NTP service: active
RTC in local TZ: no
chronyc tracking Reference ID    : 0A0010FE (host1-timeserver) Stratum
: 3 Ref time (UTC)  : Tue Dec 22 08:33:06 2020 System time     :
0.000032089 seconds fast of NTP time Last offset     : +0.000019423 seconds RMS offset      : 0.000798126 seconds Frequency       : 2.984
ppm slow Residual freq   : +0.000 ppm Skew            : 0.036 ppm Root
delay      : 0.018379021 seconds Root dispersion : 0.010704475 seconds
Update interval : 1040.9 seconds Leap status     : Normal
chronyc sources 210 Number of sources = 1 MS Name/IP address
Stratum Poll Reach LastRx Last sample
=============================================================================== ^* host1-timeserver      2  10   377   644    +78us[  +97us] +/-
32ms environment: line 7: ntpq: command not found
host1-node01 ntpq
ntpstat environment: line 10: ntpstat: command not found
● systemd-timesyncd.service
Loaded: masked (Reason: Unit systemd-timesyncd.service is masked.)
Active: inactive (dead)
timedatectl
Local time: Tue 2020-12-22 09:43:52 CET
Universal time: Tue 2020-12-22 08:43:52 UTC
RTC time: Tue 2020-12-22 08:43:52
Time zone: Europe/Berlin (CET, +0100) System clock synchronized: yes
NTP service: active
RTC in local TZ: no
chronyc tracking Reference ID    : 0A0010FE (host1-timeserver) Stratum
: 3 Ref time (UTC)  : Tue Dec 22 08:42:25 2020 System time     :
0.000003835 seconds fast of NTP time Last offset     : +0.000009851 seconds RMS offset      : 0.000719458 seconds Frequency       : 34.179
ppm slow Residual freq   : +0.014 ppm Skew            : 0.088 ppm Root
delay      : 0.004465697 seconds Root dispersion : 0.021002445 seconds
Update interval : 128.5 seconds Leap status     : Normal
chronyc sources 210 Number of sources = 1 MS Name/IP address
Stratum Poll Reach LastRx Last sample
=============================================================================== ^* host1-timeserver      2   7   377    86    +14us[  +24us] +/-
33ms environment: line 7: ntpq: command not found
host1-node02 ntpq environment: line 10: ntpstat: command not found
ntpstat
● systemd-timesyncd.service
Loaded: masked (Reason: Unit systemd-timesyncd.service is masked.)
Active: inactive (dead)
timedatectl
Local time: Tue 2020-12-22 09:43:53 CET
Universal time: Tue 2020-12-22 08:43:53 UTC
RTC time: Tue 2020-12-22 08:43:53
Time zone: Europe/Berlin (CET, +0100) System clock synchronized: yes
NTP service: active
RTC in local TZ: no
chronyc tracking Reference ID    : 0A0010FE (host1-timeserver) Stratum
: 3 Ref time (UTC)  : Tue Dec 22 08:42:28 2020 System time     :
0.000008563 seconds slow of NTP time Last offset     : -0.000016512 seconds RMS offset      : 0.002114891 seconds Frequency       : 32.695
ppm slow Residual freq   : -0.029 ppm Skew            : 0.250 ppm Root
delay      : 0.004427484 seconds Root dispersion : 0.021170758 seconds
Update interval : 130.4 seconds Leap status     : Normal
chronyc sources 210 Number of sources = 1 MS Name/IP address
Stratum Poll Reach LastRx Last sample
=============================================================================== ^* host1-timeserver      2   7   377    84    -16us[  -32us] +/-
33ms environment: line 7: ntpq: command not found
host1-node03 ntpq
ntpstat environment: line 10: ntpstat: command not found
● systemd-timesyncd.service
Loaded: masked (Reason: Unit systemd-timesyncd.service is masked.)
Active: inactive (dead)
timedatectl
Local time: Tue 2020-12-22 09:43:55 CET
Universal time: Tue 2020-12-22 08:43:55 UTC
RTC time: Tue 2020-12-22 08:43:55
Time zone: Europe/Berlin (CET, +0100) System clock synchronized: yes
NTP service: active
RTC in local TZ: no
chronyc tracking Reference ID    : 0A0010FE (host1-timeserver) Stratum
: 3 Ref time (UTC)  : Tue Dec 22 08:42:16 2020 System time     :
0.000002321 seconds fast of NTP time Last offset     : -0.000001159 seconds RMS offset      : 0.000047930 seconds Frequency       : 34.080
ppm slow Residual freq   : +0.001 ppm Skew            : 0.060 ppm Root
delay      : 0.006130085 seconds Root dispersion : 0.017225547 seconds
Update interval : 519.0 seconds Leap status     : Normal
chronyc sources 210 Number of sources = 1 MS Name/IP address
Stratum Poll Reach LastRx Last sample
=============================================================================== ^* host1-timeserver      2   9   377    99  -3398ns[-4557ns] +/-
33ms
host2-node01 ntpq environment: line 7: ntpq: command not found
ntpstat environment: line 10: ntpstat: command not found
● systemd-timesyncd.service
Loaded: masked (Reason: Unit systemd-timesyncd.service is masked.)
Active: inactive (dead)
timedatectl
Local time: Tue 2020-12-22 09:43:56 CET
Universal time: Tue 2020-12-22 08:43:56 UTC
RTC time: Tue 2020-12-22 08:43:56
Time zone: Europe/Berlin (CET, +0100) System clock synchronized: yes
NTP service: active
RTC in local TZ: no
chronyc tracking Reference ID    : 0A0010FE (host1-timeserver) Stratum
: 3 Ref time (UTC)  : Tue Dec 22 08:29:07 2020 System time     :
0.000026769 seconds fast of NTP time Last offset     : +0.000061154 seconds RMS offset      : 0.000095979 seconds Frequency       : 1.427
ppm slow Residual freq   : +0.001 ppm Skew            : 0.021 ppm Root
delay      : 0.017465375 seconds Root dispersion : 0.011619666 seconds
Update interval : 1044.3 seconds Leap status     : Normal
chronyc sources 210 Number of sources = 1 MS Name/IP address
Stratum Poll Reach LastRx Last sample
=============================================================================== ^* host1-timeserver      2  10   377   889   +380us[ +441us] +/-
27ms environment: line 7: ntpq: command not found
host2-node02 ntpq environment: line 10: ntpstat: command not found
ntpstat
● systemd-timesyncd.service
Loaded: masked (Reason: Unit systemd-timesyncd.service is masked.)
Active: inactive (dead)
timedatectl
Local time: Tue 2020-12-22 09:43:57 CET
Universal time: Tue 2020-12-22 08:43:57 UTC
RTC time: Tue 2020-12-22 08:43:57
Time zone: Europe/Berlin (CET, +0100) System clock synchronized: yes
NTP service: active
RTC in local TZ: no
chronyc tracking Reference ID    : 0A0010FE (host1-timeserver) Stratum
: 3 Ref time (UTC)  : Tue Dec 22 08:31:51 2020 System time     :
0.000060706 seconds fast of NTP time Last offset     : +0.000152064 seconds RMS offset      : 0.000274430 seconds Frequency       : 1.858
ppm slow Residual freq   : +0.005 ppm Skew            : 0.116 ppm Root
delay      : 0.019006269 seconds Root dispersion : 0.018152438 seconds
Update interval : 1030.5 seconds Leap status     : Normal
chronyc sources 210 Number of sources = 1 MS Name/IP address
Stratum Poll Reach LastRx Last sample
=============================================================================== ^* host1-timeserver      2  10   377   726   +297us[ +449us] +/-
30ms environment: line 7: ntpq: command not found
host2-node03 ntpq
ntpstat environment: line 10: ntpstat: command not found
● systemd-timesyncd.service
Loaded: masked (Reason: Unit systemd-timesyncd.service is masked.)
Active: inactive (dead)
timedatectl
Local time: Tue 2020-12-22 09:43:59 CET
Universal time: Tue 2020-12-22 08:43:59 UTC
RTC time: Tue 2020-12-22 08:43:59
Time zone: Europe/Berlin (CET, +0100) System clock synchronized: yes
NTP service: active
RTC in local TZ: no
chronyc tracking Reference ID    : 0A0010FE (host1-timeserver) Stratum
: 3 Ref time (UTC)  : Tue Dec 22 08:38:06 2020 System time     :
0.000103265 seconds fast of NTP time Last offset     : +0.000101621 seconds RMS offset      : 0.000754228 seconds Frequency       : 2.710
ppm slow Residual freq   : +0.002 ppm Skew            : 0.065 ppm Root
delay      : 0.018792789 seconds Root dispersion : 0.015140322 seconds
Update interval : 1035.0 seconds Leap status     : Normal
chronyc sources 210 Number of sources = 1 MS Name/IP address
Stratum Poll Reach LastRx Last sample
=============================================================================== ^* host1-timeserver      2  10   377   353   +342us[ +443us] +/-
36ms

A: I set up an extra time server for the cluster. The clients in the cluster now synchronize with the time server every second. The problem has not occurred since then. I guess the problem is solved.
server clustertimeserver minpoll 0 maxpoll 0
(using one second polling interval)


text:
Q: What ways to make data accessible via mobile borwser? I have built a website with asp.net/c# ,jquery,SQL Server 2008.
The website and data are hosted inside a hosting company.
I want to build a mobile version of the website.how can i make the data(that are now in SQL Server 2008)  accessible for mobile?
Should i migrate the data to a cloud such as Windows Azure?

A: Well a mobile phone accesses the web just like a PC just with a smaller screen and different browser (at times), so making a different theme for your website that would show only for mobile devices would be sufficient, unless you are talking about a downloadable app that runs on the device itself and not in the browser.
If it's browser based. Use this to make it work better with mobile devices
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta names="apple-mobile-web-app-status-bar-style" content="black-translucent" />

A: You can host multiple versions of a website in one host. Some sites use media queries to create two different presentations of the same website. This is a good, simple way to do things but it will not be the best experience for mobile users. It's very hard to create content that is equally useful for mobile and desktop browsers.
Another approach is to create a second copy of your site with a theme and navigation optimized for mobile. For example, your site may look for the string "mobile" in the user agent string and send the user to m.yoursite.com. This gives you a better chance of optimizing content for mobile users. Hosting sites commonly give you the ability to host multiple domains off one account.
If you'd prefer to make a native app (I don't recommend this) then you'd want to expose your APIs so that a native version can query your API to get the data it needs.


text:
Q: Automatically enable 'Throttle Javascript timers in background' with Selenium I'm working on a Selenium project, and I need to open Chrome Canary with Throttle Javascript timers in background = Enable imediattely
I tried a lot of options, I searched in a lot of website, but couldn't find good solution.
This is what I tried:
ChromeOptions canaryOptions = new ChromeOptions
{
        UnhandledPromptBehavior = UnhandledPromptBehavior.Ignore
};
canaryOptions.AddArgument("start-maximized");
canaryOptions.AddArgument("enable-intensive-wake-up-throttling");

canaryOptions.AddArgument("--intensive-wake-up-throttling-enabled");
canaryOptions.AddArgument("--intensive-wake-up-throttling-enable");
canaryOptions.AddArgument("intensive-wake-up-throttling-enabled");
canaryOptions.AddArgument("intensive-wake-up-throttling-policy=1");
canaryOptions.AddArgument("--intensive-wake-up-throttling-policy=1");
canaryOptions.AddArgument("intensive-wake-up-throttling=1");
canaryOptions.AddArgument("--intensive-wake-up-throttling=1");
canaryOptions.AddArgument("IntensiveWakeUpThrottlingEnabled=1");
canaryOptions.AddArgument("--IntensiveWakeUpThrottlingEnabled=1");
canaryOptions.AddArgument("--show-autofill-signatures");

I tried to set this option with Seleniu, but after relaunch, a Chrome console is opened, and browser loose the focus, and webdriver can't work on that new instance of Chrome Canary.
So, any idea how I can open Canary with Throttle Javascript timers in background = Enable  imediattely ... ?
Thank you!


text:
Q: at parameter for hclust plot with non-equal distances in the x axis? (R) I would like to make the following plot (for one dimensional x), but to have it so that we would have the observations located in their correct location in the x axis (and not in their rank location):
x <- c(1,2,  7, 9)
names(x) <- x
plot(hclust(dist(x)), hang= -1)
axis(1)

I suspect there is no ready-made function to do this in R. Any suggestions on how to go about writing such a function?


text:
Q: CodeKit / JADE escape HTML snippet I'm writing a documentation for a CSS framework and I want to include HTML snippets on the page.
I have tried several filters, but they does not seem to work with CodeKit out of the box:
:markdown
    ```
    hello<b>world</b>
    ```

(custom markdown parser required)
:escape
    helloworld

(unknown filter :escape)
:plain
    helloworld

(unknown filter :plain)
What managed to somewhat work:
pre
    ='helloworld'

but it's still not straightforward. Is there a standard way to include and escape a perforated HTML block form inside JADE template without hacking around standard CodeKit distribution?


text:
Q: Suboptions for gcc optimization level 1 I have been getting "virtual memory exhausted: Cannot allocate memory" error in one of my project's modules with gcc's -O optimization option. The error go away if I remove -O from the command line.
I checked gcc spec and found that the following options are enabled with -O
      -fauto-inc-dec
      -fcompare-elim
      -fcprop-registers
      -fdce
      -fdefer-pop
      -fdelayed-branch
      -fdse
      -fguess-branch-probability
      -fif-conversion2
      -fif-conversion
      -fipa-pure-const
      -fipa-profile
      -fipa-reference
      -fmerge-constants
      -fsplit-wide-types
      -ftree-bit-ccp
      -ftree-builtin-call-dce
      -ftree-ccp
      -ftree-ch
      -ftree-copyrename
      -ftree-dce
      -ftree-dominator-opts
      -ftree-dse
      -ftree-forwprop
      -ftree-fre
      -ftree-phiprop
      -ftree-slsr
      -ftree-sra
      -ftree-pta
      -ftree-ter
      -funit-at-a-time

My new command line has now the following options added
-fauto-inc-dec -fdce -fdefer-pop  -fdse -fguess-branch-probability -fif-conversion2 -fif-conversion -fipa-pure-const  -fipa-reference -fmerge-constants -fsplit-wide-types  -ftree-builtin-call-dce -ftree-ccp -ftree-ch -ftree-copyrename -ftree-dce -ftree-dominator-opts -ftree-dse -ftree-forwprop -ftree-fre -ftree-phiprop -ftree-sra -ftree-pta -ftree-ter -funit-at-a-time -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector -fno-var-tracking -fno-var-tracking-assignments but I am unable to reproduce the issue.
Some of the options are unrecognised by the gcc version that I am using (I have removed them from the command line)
gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i686-redhat-linux/4.5.1/lto-wrapper
Target: i686-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,lto --enable-plugin --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch=i686 --build=i686-redhat-linux
Thread model: posix
gcc version 4.5.1 20100924 (Red Hat 4.5.1-4) (GCC)

Can anyone give an idea as to what might be going wrong?
P.S: The code that I am trying to compile has loads of STL stuffs present.

A: You may want to get a list of the exact optimization options that are being used by your specific compiler.  They can vary from compiler to compiler as well as from target to target.
Using the -Q and the --help=optimizers can help you here.  For example, let's say you use the following command to compile (and it creates broken code):
gcc -march=armv7-a -mfloat-abi=softfp -mthumb -std=c++11 -FPIC -DNDEBUG -I. -g -c myfile.cpp

And if this command creates working code:
gcc -march=armv7-a -mfloat-abi=softfp -mthumb -std=c++11 -FPIC -DNDEBUG -O -I. -g -c myfile.cpp

You can get the different options by adding in -Q at the beginning of the command and --help=optimizers at the end.  For the broken command:
gcc -Q -march=armv7-a -mfloat-abi=softfp -mthumb -std=c++11 -FPIC -DNDEBUG -I. -g -c myfile.cpp --help=optimizers > broken-opts

and the working one:
gcc -Q -march=armv7-a -mfloat-abi=softfp -mthumb -std=c++11 -FPIC -DNDEBUG -O -I. -g -c myfile.cpp --help=optimizers > working-opts

Look for options that are marked as "[enabled]" in the broken-opts file but are "[disabled]" in the working-opts file:
diff broken-opts working-opts | grep '<'

Then, you can either a) compile using -O and disabling the options one-at-a-time (i.e. -fno-option-name for an option called -foption-name) until you find the right one to disable, or you can b) compile without any optimization flags and add the options in one-at-a-time until you find the "broken" option.
I use "broken" option with quotes - because in every case I have ever dealt with, it's actually been a problem with MY code, and not a problem with the compiler or optimizer itself.  However, this process has helped me a lot of times to figure out where in my code the problem is (i.e. if the "broken" option has something to do with the stack, or something to do with virtual functions, you can narrow down your search of the offending code).


text:
Q: What caused sendmail permission be modified? My OS is CentOS 6.2, I have installed sendmail for about 2 years. It always runs well and I have changed nothing. But I am not sure why today I find sendmail has already down for 5 days. in maillog, a ton of lines with NOQUEUE: SYSERR(apache): can not chdir(/var/spool/clientmqueue/): Permission denied (I am very confuse)
After a rescue work,
chown root.smmsp /usr/sbin/sendmail.sendmail
chmod g+s /usr/sbin/sendmail.sendmail
chown smmsp.smmsp /var/spool/clientmqueue
service sendmail restart

Now sendmail works again. But in the past 5 days, I lost a lot of mails. Are they stored in database or any logs? How to re-send these mails?
And What caused sendmail permission be modified?
Thanks.

A: Is your application running on Apache?
If yes, the solution was to change the permissions of /var/spool/mclientqueue like so:
chmod 1777 /var/spool/clientmqueue

Apache does not allow setgid, hence the failure when sendmail client tries to send a mail.
Also you can try disabling Selinux, as this will conflict the permission usage.


text:
Q: C# winform create columns in datagridview with observableCollection I used a simple dataTable to load my data before is this way:
DataTable dt = new DataTable("grid");
//split array to width X height dataTable

// create columns
for (int i = 0; i < width; i++)
{
    dt.Columns.Add();
}

for (int i = 0; i < height; i++)
{
    // create a DataRow using .NewRow()
    DataRow row = dt.NewRow();
    // iterate over all columns to fill the row
    for (int j = 0; j < width; j++)
    {
        row[j] = grid.Cells[j + (width * i)].State.ToString();
    }
    // add the current row to the DataTable
    dt.Rows.Add(row);
}
dataGridView1.DataSource = dt;

And that worked, but not good enough because i want to update 100x100 matrix of colors fast so i thought about an observable collection.
I have now this code:
ObservableCollection<String> data = new ObservableCollection<String>();
dataGridView1.DataSource = new BindingSource { DataSource = data };

for (int i = 0; i < grid.Cells.Length; i++)
{
   data[i] = grid.Cells[i].State.ToString();
}

(grid is my model)
this seems to load all the data but i have no representation to the columns so i have only rows.
How do i specify the amount of columns?
And am i in the right direction?

A: I used my first lines of code, just added:
            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;

And now it works just fine.


text:
Q: list not displaying in angular binding? I am trying my first angular js list example. Having issues displaying the list, there are no errors in the console:(
html

    <form ng-submit="addtask()">total nr of tasks: {{myvar.length}}

remaining: {{remaining()}}
        <input type="text" ng-model="newtask" />

                <input type="checkbox" ng-model="myvardone" /> {{var.text}}

        <button type="submit">add</button>
    </form>

script:
   function mycontroller($scope) {
       $scope.myvar = [{
           text: 'bert',
           done: false
       }, {
           text: 'ed',
           done: true
       }, {
           text: 'pet',
           done: false
       }];

       $scope.addtask = function () {
           $scope.myvar.push({
               text: $scope.newtask,
               done: false
           });
       }

       $scope.remaining = function () {
           var count = 0;
           angular.forEach($scope.myvar, function (t) {
               if (t.done) {
                   count++
               } else {
                   count += 0;
               }
           });
           return count;
       }
   }

jsfiddle:http://jsfiddle.net/dingen2010/vc2bC/3/

A: simple demo can be like
xxxxx

don't forget "ng-app"

A: Darn, Awakening beat me to it... :/ But yeah, just simply move the ng-controller tag to a containing  and put a ng-app tag on the html tag. Here:
enter code herehttp://jsfiddle.net/vc2bC/8/

A: Several things
One. missed ng-app
Two. You should not repeating ul, but li

   <input type="checkbox" ng-model="var.done" />
   {{var.text}}

Three. when you add, you need to have task name entered.
Four, you don't need remaining function. use filter
{{ (myvar | filter:{done:true}).length }}

http://jsfiddle.net/vc2bC/10/


text:
Q: How to move Git repo to Atlassian Stash over HTTPS My firm has been using Git for over a year now but we been using SSH and Gitolite.  We are moving to Atassin Stash over HTTPS.  Can someone please tell me the steps I have to take on moving a repo and also how to use it over https
I think I need to clone it using ssh but then how to a move it with using https?

A: to migrate your existing repo to the new server, it's probably best to do a fresh clone, and then push the entire clone to the new server:
 git clone ssh://my.old.server/git/foo.git
 cd foo
 git remote set-url origin https://bla.blo.bli/git/foo.git
 git push --all

once the new server has been synched, the clients can be switched simply by changing the URL of your primary remote:
git remote set-url origin https://bla.blo.bli/git/foo.git

and continue to work.
that's all :-)


text:
Q: Query string not bringing back results when URL parameter includes '20' I have a query in a search result web part that is grabbing an event title from the URL parameter as follows:
Event1OWSTEXT={QueryString.eventTitle}
However, whenever there is a "20" in the event title, the query doesn't bring back any results. I assume it has something to do with the fact that spaces are encoded as %20 and it's confusing SharePoint, but I can't figure out a way to get around it. The business unit places the date in the title, and the year is 2020, so we will definitely be encountering this!
Any suggestions?


text:
Q: How to add "Cancel" button to "login" control of asp.net? Just as the title says, I have this model pop up box (using ajax ModalPopupExtender) that opens up when user clicks "Login", but the problem is that it can only be dismissed by Logging in. So I'd like to allow a "Cancel" button to this "Login" control so that if user clicks it, the dialog is dismissed.
I can handle the click event of that "Cancel" button and dismiss the dialog, but the problem is how do I add one?
I couldn't find any setting in Visual studio?
Any help?
edit: please read the comment, if you wanna suggest making a custom control.

A: Given that you don't want to use a template, I'd suggest that your best bet is going to be to subclass the login control and add your own extensions to it's markup.
You might want to look at the following:
http://forums.asp.net/t/1035097.aspx/1
http://www.dotnetspark.com/Forum/239-cancel-button-login-control.aspx


text:
Q: Soldering techniques for PCB modules where all pads are on bottom I am prototyping a board that uses one of two modules (that is another PCB with components already on it). One module - all pads on that module are underneath (not exposed and not castellated), rather small and tightly packed:

Another module is less problematic as most pads are castellated holes and only a few pads are underneath (bigger and more dispersed compared to first module):

While 1st module is more complex, it is most preferable to be used as it is more reliable one as far as I know. And even with 2nd one I still would need access to those hidden pads. I only have 1 of each module for prototype, so I would highly prefer not to screw this up.
Tools I have access to:

*

*Simple soldering iron with a few different tips

*Quite good hot air station

*Solder wire with rosin core

*Syringe of solder paste (low temp ~130 C) and syringe of flux

I am thinking I should be able to solder it with the hot air using low temperature solder paste. However I will have no way to verify that solder has melted and created reliable joints.
Another concern is that during the pre-heating flux in the paste drops in viscosity and spreads solder balls all around the area where it has been applied. On open joints the surface tension usually brings melted balls together into a nice and clean joint, but with this being sandwiched between two surfaces I am very concerned about making bridges.
I guess my question is what techniques I could use for increased chances of a good quality soldering of those hidden pads?
PS: as a workaround for bridges I was thinking to prime the pads with paste and melt it using hot air, then apply extra flux from syringe, put module atop and reflow this using hot air. Would that work, is there any issues with this approach?

A: Personally I would have a framed stainless-steel stencil made, apply low temperature Sn 42 Bi 58 fine 138°C solder paste (if necessary repeat to get it perfect under the microscope) and then bake the board in an inexpensive benchtop T962 SMT oven. That's not much equipment but it does cost more than zero.
Those pads are pretty tiny, you might also want to consider having someone do it for you.


text:
Q: looking for a norm inequality I want an inequality of the form
 : $\Vert a - b \Vert^2 \leq k.(\Vert a\Vert^2 + \Vert b\Vert^2)$ ? where k is a constant.
The norm in consideration is the euclidean norm, and $a$ and $b$ are vectors in $\mathbb{R}
^p$.
As a few people have replied below, its pretty straightforward with k = 2. But I was wondering if there is something tighter than that? Clearly k = 1 if a and b are independent (if random) or orthogonal.

A: No.  Let $a \neq 0$ and $b = -a$.  The left hand side is $4\|a\|^2$ and the right hand side is $2\|a\|^2$.


text:
Q: Crontab not working in Lubuntu 18.04.2 https://pasteboard.co/I6ohPOy.png
Double clicking on working.sh works.
Typing /home/paul/Desktop/working.sh works.
Rebooting does NOT make it work.
And also, what is the current way of making that command work from a keyboard combination shortcut, like ctrl+alt+9?


text:
Q: Update a widget if the screen is selected I try to build a widget with the following behavior: Only update if the widget is shown.
Let me explain a little bit more about it. Assume that the smartphone have maybe 3 home screens, one, two and three. The widget will placed on screen 3, if you activate your smartphone it will start on screen 1. So, I only want to update the widget if the screen is changed to screen 3 by the user, I want to react on this event. Is there any chance in android to do this?
As far as I see there is unfortunately no way to do this, there is no change to get informed about a visibility change or something similar. I look for hours with Google but don't find any interesting stuff. Does someone have other information? I'm glad to any hint; hope you can help me out.

A: You can try with dispatchTouchEvent (Hope you can get the x,y coordinates of the view to be checked.)
Steps :

*

*let containerView be the view which contains your view.

*set an ontouchlistener for your view.

*When the screen changes or at the time you need to check whether the view is visible, initiate a dispatchTouchEvent call with MotionEvent containing the coordinates of your view.

*if your view is there in that coordinate area, the touch event for your view will get called.

For example :
    containerView = LayoutInflater.from(this).inflate(
            R.layout.activity_main, null);
    setContentView(containerView);
            yourView = containerView.findViewById(R.id.yourView);
            yourView .setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            Toast.makeText(MainActivity.this, "View visible",
                    Toast.LENGTH_SHORT).show();
            return false;
        }
    });

When you need to check, do following code :
public void doCheck() {
    long downTime = SystemClock.uptimeMillis();
    long eventTime = SystemClock.uptimeMillis() + 100;
    float x = 100f; //yourView x coordinate
    float y = 100f; //yourView y coordinate
    int metaState = 0;
    MotionEvent motionEvent = MotionEvent.obtain(downTime, eventTime,
            MotionEvent.ACTION_DOWN, x, y, metaState);
    containerView.dispatchTouchEvent(motionEvent);
}

hope this will help.


text:
Q: Center Align Submit button I have a form with a textarea and submit button.
I floated textarea to left and submit button to right.
This is how it is displayed in Firefox.

This is how it is displayed in IE.

This is the html code i have written.

  <form method="post" action="google.php">
   <textarea rows="3" cols="40"  style="width: 300px; float: left;"></textarea>
   <input type="submit" style="width: 100px; float: right;" />
  </form>

This is the CSS Code:
#form {
 overflow: auto;
 border: 1px solid black;
 width: 600px;
 padding-left: 10px;
 padding-right: 10px;
}

How to align the submit button vertically in center with respect to the textarea.?
ANSWER :
I modified the code to meet my requirements.
This is the CSS code :
#form {
  overflow: auto;
  border: 1px solid black;
  width: 600px;
  padding-left: 10px;
 padding-right: 10px;
  }
 #form  textarea {
   vertical-align: middle;
  }
 #form span{
   display: inline-block;
   vertical-align: middle;
  margin-left: 40px;
}

HTML Code:

    <form method="post" action="google.php">
    <textarea rows="3" cols="40"  style="width: 300px; "></textarea>
    <input type="submit" value="Comment"  /> </form>

A: You could use position: absolute on the submit button, and set it 50% from the top, minus half the height of the button in margin-top.  See this fiddle:
http://jsfiddle.net/cXSbX/

A: You can make use of display:table and display:table-cell, property. But in this case you have to remove floats and give specific width.
HTML

  <form method="post" action="google.php">

   <textarea rows="3" cols="40"></textarea>

<input type="submit"/>

  </form>

CSS
#form{
 overflow: auto;
 border: 1px solid black;
 width: 600px;
 padding-left: 10px;
 padding-right: 10px;
 display:table;
}

div.wrap,
div.wrap_2 {
    float: none;
    display: table-cell;
    vertical-align: middle;
}

div.wrap {
    width:500px
}

FIDDLE:
http://jsfiddle.net/7gnMu/

A: you can give margin-left or margin-right property.
ex:
margin-left:135px;

A: Wrap the input with some element and text center align the input.

  <form method="post" action="google.php">
   <textarea rows="3" cols="40"  style="width: 300px; float: left;"></textarea>
      <input type="submit" display:inline-block; />
  </form>

http://jsfiddle.net/UuFg2/

A: Try the Js fiddle
http://jsfiddle.net/wZs2F/
#form {
 overflow: auto;
 border: 1px solid black;
 width: 600px;
 padding-left: 10px;
 padding-right: 10px;
}
.txtinput
{
 margin-left:100px;
}

  <form method="post" action="google.php">
   <textarea rows="3" cols="40"  style="width: 300px; "></textarea>

   <input type="submit" style="width: 100px;"  />

  </form>

A: In this case vertical-align: bottom will not work. Instead height and line-height will make your button to align vertically centered.
Included following styles for input:
height: 80px;
line-height: 70px

Have a look at working demo here: Demo


text:
Q: How to identify what application is using this port (lsof / fuser not helping)? How do I find what process/application is running an http server on a machine? All the Usual tools (netstat, lsof, fuser, ss aren't helping in this instance)
vinayb@carbon ~ $ sudo fuser 80/tcp
vinayb@carbon ~ $ sudo ss -pt state listening 'sport = :80'
Recv-Q    Send-Q       Local Address:Port       Peer Address:Port    Process
vinayb@carbon ~ $ curl http://localhost:80
404 page not found
vinayb@carbon ~ $ curl -vv http://localhost:80
*   Trying 127.0.0.1:80...
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET / HTTP/1.1
> Host: localhost
> User-Agent: curl/7.73.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 404 Not Found
< Content-Type: text/plain; charset=utf-8
< Vary: Accept-Encoding
< X-Content-Type-Options: nosniff
< Date: Sat, 27 Feb 2021 12:45:05 GMT
< Content-Length: 19
<

A: Using netstat usually helps in this case, ie. netstat -tupan.
Best executed as root, that will give you a nice list, such as:
tom:~/ $ sudo netstat -tupan
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1450/master
tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN      1764/smbd
tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN      1764/smbd
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1106/sshd
...


text:
Q: Supersized - loading images dynamically Ok, I have a js script on the page that calls this:
     function loadTheseimages(slideList) {

                jQuery(function($){

                    var slideIterate = [];
                    var slidesObj = new Object;

                    slideIterate = slideList.split(',');

                    $.each(slideIterate, function(key, value) {

                            slidesObj += '{image: "' + value + '"}';

                    });

                    $.supersized({

                        // Functionality
                        slide_interval          :   3000,       // Length between transitions
                        transition              :   1,          // 0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
                        transition_speed        :   700,        // Speed of transition

                        // Components
                        slide_links             :   'blank',    // Individual links for each slide (Options: false, 'num', 'name', 'blank')
                        slides                  :   [           // Slideshow Images
                                                            slidesObj
                                                    ]

                    });
                });
            }

The Script calling the above function passes
    "http://cliffside.ca/wp-content/uploads/2012/06/cliff-side-nightsky.jpeg, http://cliffside.ca/wp-content/uploads/2012/05/Sunset.jpg, http://cliffside.ca/wp-content/uploads/2012/05/Relaxing-Room.jpg"

Why is it not working?
http://Cliffside.ca/

A: Just to clarify, the object that has to be passed to supersized must be built like this:
    var slidesObj = new Array;
    $.each( data, function( key, value ) {
        var slide = new Object;
        slide = {image:value };
        slidesObj.push(slide);
    });

And the just put the following when calling supersized:
slides                  :   slidesObj,


text:
Q: grunt serve:dist or grunt build causing MIME error for some bower_components OK I've tried to make sure this question hasn't be already asked, and I couldn't find it...so hopefully this is a first time for this question. My issue deals with using angular-fullstack generator and the grunt build or grunt serve:dist command. Both seem to have the same issue, they are copying over the bower_component files but then some of them seem to be having issues accessing them after the files are minified.
So here are the errors that come up from running grunt build. (note I'm suing spring-boot:run and have Maven execute the grunt tasks...but that seems to be working perfectly as far as I can tell):
Resource interpreted as Font but transferred with MIME type text/plain:    "http://localhost:8080/bower_components/bootstrap-sass-official/assets/fonts/bootstrap/glyphicons-halflings-regular.woff". 5b26ecfc.vendor.js:2
Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:8080/". 5b26ecfc.vendor.js:20
Refused to execute script from 'http://localhost:8080/' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled. (index):1
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:8080/". 5b26ecfc.vendor.js:20
Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:8080/". 5b26ecfc.vendor.js:20
Refused to execute script from 'http://localhost:8080/' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled. (index):1
Uncaught TypeError: Cannot set property 'dir' of undefined

I limited the main errors down to bootstrap's font use, and ckeditor. I discover someone else had a similar problem and addressed it by doing the following (at least for ckeditor): ckeditor fix But I'm not completely happy with the solution as it would mean I would have to take similar steps with all of my bower_components that have other dependencies besides their js files. Here's my grunt file so you can see how it work:
'use strict';

module.exports = function (grunt) {

    // Configurable paths for the application
    var appConfig = {
        app: require('./bower.json').appPath || 'client',
        dist: 'src/main/webapp'
    };

    // Load grunt tasks automatically, when needed
    require('jit-grunt')(grunt, {
        useminPrepare: 'grunt-usemin',
        ngtemplates: 'grunt-angular-templates',
        cdnify: 'grunt-google-cdn',
        protractor: 'grunt-protractor-runner',
        injector: 'grunt-asset-injector'
    });

//    require('load-grunt-tasks')(grunt);

    // Time how long tasks take. Can help when optimizing build times
    require('time-grunt')(grunt);

    // Define the configuration for all the tasks
    grunt.initConfig({

        // Project settings
        pkg: grunt.file.readJSON('package.json'),
        yeoman: {
            // configurable paths
            client: require('./bower.json').appPath || 'client',
            dist: 'src/main/webapp'
        },
        watch: {
            bower: {
                files: ['bower.json'],
                tasks: ['wiredep']
            },
            injectJS: {
                files: [
                    '<%= yeoman.client %>/{app,components}/**/*.js',
                    '!<%= yeoman.client %>/{app,components}/**/*.spec.js',
                    '!<%= yeoman.client %>/{app,components}/**/*.mock.js',
                    '!<%= yeoman.client %>/app/app.js'],
                tasks: ['injector:scripts']
            },
            injectCss: {
                files: [
                    '<%= yeoman.client %>/{app,components}/**/*.css'
                ],
                tasks: ['injector:css']
            },
            jsTest: {
                files: [
                    '<%= yeoman.client %>/{app,components}/**/*.spec.js',
                    '<%= yeoman.client %>/{app,components}/**/*.mock.js'
                ],
                tasks: ['newer:jshint:all', 'karma']
            },
            injectSass: {
                files: [
                    '<%= yeoman.client %>/{app,components}/**/*.{scss,sass}'],
                tasks: ['injector:sass']
            },
            sass: {
                files: [
                    '<%= yeoman.client %>/{app,components}/**/*.{scss,sass}'],
                tasks: ['sass', 'autoprefixer']
            },
            gruntfile: {
                files: ['Gruntfile.js']
            },
            livereload: {
                files: [
                    '{.tmp,<%= yeoman.client %>}/{app,components}/**/*.css',
                    '{.tmp,<%= yeoman.client %>}/{app,components}/**/*.html',
                    '{.tmp,<%= yeoman.client %>}/{app,components}/**/*.js',
                    '!{.tmp,<%= yeoman.client %>}{app,components}/**/*.spec.js',
                    '!{.tmp,<%= yeoman.client %>}/{app,components}/**/*.mock.js',
                    '<%= yeoman.client %>/assets/images/{,*//*}*.{png,jpg,jpeg,gif,webp,svg}'
                ],
                options: {
                    livereload: true
                }
            }
        },

        // The actual grunt server settings
        connect: {
            options: {
                port: 9000,
                // Change this to '0.0.0.0' to access the server from outside.
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    open: true,
                    middleware: function (connect) {
                        return [
                            connect.static('.tmp'),
                            connect().use(
                                '/client/bower_components',
                                connect.static('./client/bower_components')
                            ),
                            connect.static(appConfig.app)
                        ];
                    }
                }
            },
            test: {
                options: {
                    port: 9001,
                    middleware: function (connect) {
                        return [
                            connect.static('.tmp'),
                            connect.static('test'),
                            connect().use(
                                '/client/bower_components',
                                connect.static('./client/bower_components')
                            ),
                            connect.static(appConfig.app)
                        ];
                    }
                }
            },
            dist: {
                options: {
                    open: true,
                    base: '<%= yeoman.dist %>'
                }
            }
        },

        // Make sure code styles are up to par and there are no obvious mistakes
        jshint: {
            options: {
                jshintrc: '<%= yeoman.client %>/.jshintrc',
                reporter: require('jshint-stylish')
            },
            all: [
                '<%= yeoman.client %>/{app,components}/**/*.js',
                '!<%= yeoman.client %>/{app,components}/**/*.spec.js',
                '!<%= yeoman.client %>/{app,components}/**/*.mock.js'
            ],
            test: {
                src: [
                    '<%= yeoman.client %>/{app,components}/**/*.spec.js',
                    '<%= yeoman.client %>/{app,components}/**/*.mock.js'
                ]
            }
        },

        // Empties folders to start fresh
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '.tmp',
                        '<%= yeoman.dist %>/*',
                        '!<%= yeoman.dist %>/.git*',
                        '!<%= yeoman.dist %>/.openshift',
                        '!<%= yeoman.dist %>/Procfile'
                    ]
                }]
            },
            server: '.tmp'
        },

        // Add vendor prefixed styles
        autoprefixer: {
            options: {
                browsers: ['last 1 version']
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: '.tmp/',
                    src: '{,*/}*.css',
                    dest: '.tmp/'
                }]
            }
        },

        // Automatically inject Bower components into the app
        wiredep: {
            target: {
                src: '<%= yeoman.client %>/index.html',
                ignorePath: '<%= yeoman.client %>/',
                exclude: [/bootstrap-sass-official/, /bootstrap.js/, '/json3/', '/es5-shim/', /bootstrap.css/, /font-awesome.css/ ]
            }
        },

        // Renames files for browser caching purposes
        rev: {
            dist: {
                files: {
                    src: [
                        '<%= yeoman.dist %>/public/{,*/}*.js',
                        '<%= yeoman.dist %>/public/{,*/}*.css',
                        '<%= yeoman.dist %>/public/assets/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
                        '<%= yeoman.dist %>/public/assets/fonts/*'
                    ]
                }
            }
        },

        // Reads HTML for usemin blocks to enable smart builds that automatically
        // concat, minify and revision files. Creates configurations in memory so
        // additional tasks can operate on them
        useminPrepare: {
            html: ['<%= yeoman.client %>/index.html'],
            options: {
                dest: '<%= yeoman.dist %>/public',
                flow: {
                    html: {
                        steps: {
                            js: ['concat', 'uglifyjs'],
                            css: ['cssmin']
                        },
                        post: {}
                    }
                }
            }
        },
        cssmin: {
            options: {
                root: 'client'
            }
        },
        // Performs rewrites based on rev and the useminPrepare configuration
        usemin: {
            html: ['<%= yeoman.dist %>/public/{,*/}*.html'],
            css: ['<%= yeoman.dist %>/public/{,*/}*.css'],
            js: ['<%= yeoman.dist %>/public/{,*/}*.js'],
            options: {
                assetsDirs: [
                    '<%= yeoman.dist %>/public',
                    '<%= yeoman.dist %>/public/assets/images'
                ],
                // This is so we update image references in our ng-templates
                patterns: {
                    js: [
                        [/(assets\/images\/.*?\.(?:gif|jpeg|jpg|png|webp|svg))/gm, 'Update the JS to reference our revved images']
                    ]
                }
            }
        },

        // The following *-min tasks produce minified files in the dist folder
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.client %>/assets/images',
                    src: '{,*/}*.{png,jpg,jpeg,gif}',
                    dest: '<%= yeoman.dist %>/public/assets/images'
                }]
            }
        },

//        htmlmin: {
//            dist: {
//                options: {
//                    collapseWhitespace: true,
//                    conservativeCollapse: true,
//                    collapseBooleanAttributes: true,
//                    removeCommentsFromCDATA: true,
//                    removeOptionalTags: true
//                },
//                files: [{
//                    expand: true,
//                    cwd: '<%= yeoman.dist %>',
//                    src: ['*.html', 'app/**/*.html'],
//                    dest: '<%= yeoman.dist %>'
//                }]
//            }
//        },
//        uglify: {
//           dist: {
//             files: {
//               '<%= yeoman.dist %>/scripts/scripts.js': [
//                 '<%= yeoman.dist %>/scripts/scripts.js'
//               ]
//             }
//           }
//        },

        svgmin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.client %>/assets/images',
                    src: '{,*/}*.svg',
                    dest: '<%= yeoman.dist %>/public/assets/images'
                }]
            }
        },

        // Allow the use of non-minsafe AngularJS files. Automatically makes it
        // minsafe compatible so Uglify does not destroy the ng references
        ngAnnotate: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '.tmp/concat',
                    src: '*/**.js',
                    dest: '.tmp/concat'
                }]
            }
        },

        // Package all the html partials into a single javascript payload
        ngtemplates: {
            options: {
                // This should be the name of your apps angular module
                module: 'napiRest',
                htmlmin: {
                    collapseBooleanAttributes: true,
                    collapseWhitespace: true,
                    removeAttributeQuotes: true,
                    removeEmptyAttributes: true,
                    removeRedundantAttributes: true,
                    removeScriptTypeAttributes: true,
                    removeStyleLinkTypeAttributes: true
                },
                usemin: 'app/app.js'
            },
            main: {
                cwd: '<%= yeoman.client %>',
                src: ['{app,components}/**/*.html'],
                dest: '.tmp/templates.js'
            },
            tmp: {
                cwd: '.tmp',
                src: ['{app,components}/**/*.html'],
                dest: '.tmp/tmp-templates.js'
            }
        },

        // Replace Google CDN references
        cdnify: {
            dist: {
                html: ['<%= yeoman.dist %>/public/*.html']
            }
        },

        // Copies remaining files to places other tasks can use
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.client %>',
                    dest: '<%= yeoman.dist %>/public',
                    src: [
                        '*.{ico,png,txt}',
                        '.htaccess',
                        'bower_components/**/*',
                        'assets/images/{,*/}*.{webp}',
                        'assets/fonts/**/*',
                        'index.html'
                    ]
                }, {
                    expand: true,
                    cwd: '.tmp/images',
                    dest: '<%= yeoman.dist %>/public/assets/images',
                    src: ['generated/*']
                }, {
                    expand: true,
                    dest: '<%= yeoman.dist %>',
                    src: [
                        'package.json'
                    ]
                }]
            },
            styles: {
                expand: true,
                cwd: '<%= yeoman.client %>',
                dest: '.tmp/',
                src: ['{app,components}/**/*.css']
            }
        },

        // Run some tasks in parallel to speed up the build process
        concurrent: {
            server: [
                'sass'
            ],
            test: [
                'sass'
            ],
            dist: [
                'sass',
                'imagemin',
                'svgmin'
            ]
        },

        // Test settings
        karma: {
            unit: {
                configFile: 'karma.conf.js',
                singleRun: true
            }
        },

        mochaTest: {
            options: {
                reporter: 'spec'
            },
            src: ['server/**/*.spec.js']
        },

        protractor: {
            options: {
                configFile: 'protractor.conf.js'
            },
            chrome: {
                options: {
                    args: {
                        browser: 'chrome'
                    }
                }
            }
        },

        // Compiles Sass to CSS
        sass: {
            server: {
                options: {
                    loadPath: [
                        '<%= yeoman.client %>/bower_components',
                        '<%= yeoman.client %>/app',
                        '<%= yeoman.client %>/components'
                    ],
                    compass: false
                },
                files: {
                    '.tmp/app/app.css' : '<%= yeoman.client %>/app/app.scss'
                }
            }
        },

        injector: {
            options: {

            },
            // Inject application script files into index.html (doesn't include bower)
            scripts: {
                options: {
                    transform: function(filePath) {
                        filePath = filePath.replace('/client/', '');
                        filePath = filePath.replace('/.tmp/', '');
                        return '<script src="' + filePath + '"></script>';
                    },
                    starttag: '<!-- injector:js -->',
                    endtag: '<!-- endinjector -->'
                },
                files: {
                    '<%= yeoman.client %>/index.html': [
                        ['{.tmp,<%= yeoman.client %>}/{app,components}/**/*.js',
                            '!{.tmp,<%= yeoman.client %>}/app/app.js',
                            '!{.tmp,<%= yeoman.client %>}/{app,components}/**/*.spec.js',
                            '!{.tmp,<%= yeoman.client %>}/{app,components}/**/*.mock.js']
                    ]
                }
            },

            // Inject component scss into app.scss
            sass: {
                options: {
                    transform: function(filePath) {
                        filePath = filePath.replace('/client/app/', '');
                        filePath = filePath.replace('/client/components/', '');
                        return '@import \'' + filePath + '\';';
                    },
                    starttag: '// injector',
                    endtag: '// endinjector'
                },
                files: {
                    '<%= yeoman.client %>/app/app.scss': [
                        '<%= yeoman.client %>/{app,components}/**/*.{scss,sass}',
                        '!<%= yeoman.client %>/app/app.{scss,sass}'
                    ]
                }
            },

            // Inject component css into index.html
            css: {
                options: {
                    transform: function(filePath) {
                        filePath = filePath.replace('/client/', '');
                        filePath = filePath.replace('/.tmp/', '');
                        return '<link rel="stylesheet" href="' + filePath + '">';
                    },
                    starttag: '<!-- injector:css -->',
                    endtag: '<!-- endinjector -->'
                },
                files: {
                    '<%= yeoman.client %>/index.html': [
                        '<%= yeoman.client %>/{app,components}/**/*.css'
                    ]
                }
            }
        }
    });

    // Used for delaying livereload until after server has restarted
    grunt.registerTask('wait', function () {
        grunt.log.ok('Waiting for server reload...');

        var done = this.async();

        setTimeout(function () {
            grunt.log.writeln('Done waiting!');
            done();
        }, 3000);
    });

    grunt.registerTask('serve', function (target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'wait', 'connect:dist:keepalive']);
        }

        grunt.task.run([
            'clean:server',
            'injector:sass',
            'concurrent:server',
            'injector',
            'wiredep',
            'autoprefixer',
            'connect:livereload',
            'wait',
            'watch'
        ]);
    });

    grunt.registerTask('server', function () {
        grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
        grunt.task.run(['serve']);
    });

    grunt.registerTask('test', function(target) {
        if (target === 'client') {
            return grunt.task.run([
                'clean:server',
                'injector:sass',
                'concurrent:test',
                'injector',
                'autoprefixer',
                'karma'
            ]);
        }

        else if (target === 'e2e') {
            return grunt.task.run([
                'clean:server',
                'injector:sass',
                'concurrent:test',
                'injector',
                'wiredep',
                'autoprefixer',
                'connect:test',
                'protractor'
            ]);
        }

        else grunt.task.run([
                'test:client'
            ]);
    });

    grunt.registerTask('build', [
        'clean:dist',
        'injector:sass',
        'concurrent:dist',
        'injector',
        'wiredep',
        'useminPrepare',
        'autoprefixer',
        'ngtemplates',
        'concat',
        'ngAnnotate',
        'copy:dist',
        'cdnify',
        'cssmin',
        'uglify',
        'rev',
        'usemin'
    ]);

    grunt.registerTask('default', [
        'newer:jshint',
        'test',
        'build'
    ]);
};

I'd be extremely happy if someone else out there found a way around this issue.


text:
Q: Merging Duplicate Rows and apply Pivot_wider I have the following dataset format:
structure(list(ï..Date = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
2L), .Label = c("1/1/2019", "1/2/2019"), class = "factor"), ID = structure(c(1L,
1L, 1L, 2L, 2L, 2L, 2L), .Label = c("AAA001", "BBB002"), class = "factor"),
    Gender = structure(c(2L, 2L, 2L, 1L, 1L, 1L, 1L), .Label = c("FEMALE",
    "MALE"), class = "factor"), Measure = structure(c(1L, 2L,
    4L, 3L, 3L, 3L, 4L), .Label = c("Mental Status", "Motor Function",
    "No. 1", "Score"), class = "factor"), Value = structure(c(6L,
    6L, 5L, 1L, 2L, 3L, 4L), .Label = c("1.", "2/2/2020", "3811: Satisfactory",
    "4", "7", "Normal"), class = "factor")), class = "data.frame", row.names = c(NA,
-7L))

Output:
 df
  ï..Date     ID Gender        Measure              Value
1 1/1/2019 AAA001   MALE  Mental Status             Normal
2 1/1/2019 AAA001   MALE Motor Function             Normal
3 1/1/2019 AAA001   MALE          Score                  7
4 1/1/2019 BBB002 FEMALE          No. 1                 1.
5 1/1/2019 BBB002 FEMALE          No. 1           2/2/2020
6 1/1/2019 BBB002 FEMALE          No. 1 3811: Satisfactory
7 1/2/2019 BBB002 FEMALE          Score                  4
>

I tried the following but encountered errors, which came out with almost 7000 duplicates, mainly due to the duplicate rows of Measures for the same ID:
df %>%
+         distinct() %>%
+         pivot_wider(names_from = 'Measure', values_from = 'Value')
# A tibble: 3 x 7
  ï..Date  ID     Gender `Mental Status` `Motor Function`       Score     `No. 1`
  <fct>    <fct>  <fct>      <list<fct>>      <list<fct>> <list<fct>> <list<fct>>
1 1/1/2019 AAA001 MALE               [1]              [1]         [1]         [0]
2 1/1/2019 BBB002 FEMALE             [0]              [0]         [0]         [3]
3 1/2/2019 BBB002 FEMALE             [0]              [0]         [1]         [0]
Warning message:
Values in `Value` are not uniquely identified; output will contain list-cols.
* Use `values_fn = list(Value = list)` to suppress this warning.
* Use `values_fn = list(Value = length)` to identify where the duplicates arise
* Use `values_fn = list(Value = summary_fun)` to summarise duplicates

The expected output should be like the following:
      Date     ID Gender Mental.Status Motor.Function                            No.1 Score
1 1/1/2019 AAA001   MALE        Normal         Normal                                     7
2 1/1/2019 BBB002 FEMALE                              1. 2/2/2020, 3811: Satisfactory     4

Appreciate for your help in advance!

A: One approach is to use summarize to paste the values together:
library(dplyr)
library(tidyr)
df %>%
  group_by(`ï..Date`,`ID`,`Measure`) %>%
  summarize(Value = paste(Value, collapse = ", ")) %>%
  ungroup %>%
  pivot_wider(names_from = 'Measure', values_from = 'Value')
## A tibble: 3 x 6
#  ï..Date  ID     `Mental Status` `Motor Function` Score `No. 1`
#  <fct>    <fct>  <chr>           <chr>            <chr> <chr>
#1 1/1/2019 AAA001 Normal          Normal           7     NA
#2 1/1/2019 BBB002 NA              NA               NA    1., 2/2/2020, 3811: Satisfactory
#3 1/2/2019 BBB002 NA              NA               4     NA


text:
Q: PHP to Python TCP Socket refused connection I am trying to set up a basic TCP socket between two applications on the same hardware. I already have a working socket between another laptop (acting as a server) and the python script but can't seem to get the other one working.
The background is that I need to run a user interface on a laptop that is linked via a wired LAN (no internet required) to a Rpi running the network (this is where the python script and html code for the user interface live). I need to access user input from the user interface in the python script so I am going to use a socket between the two scripts (PHP and Python) to send data.
The Rpi is already acting as a client to a separate system and data happily comes in via its socket.I was going to create the new socket in the PHP script (which I guess then becomes a server) and read from this socket as a client in the Python script. Unfortunately it is not working and I keep getting:
Traceback (most recent call last):
File "/var/www/Pipe_Sock_v3.py",line 33, in <module>
  tcpConfigSock.connect(ADDRCONFIG)
File "/usr/lib/python2.7/socket.py", line 224, in meth
  return getattr(self._sock,name)(*args)
error: [Errno 111] Connection refused

The PHP socket create code is as follows:
$host = 'aaa.aaa.aaa.aaa'   #both PHP and python script at same IP address on Rpi
$port = 8000;
$sock = socket_create(AF_INET,SOCK_STREAM,0);
socket_bind($sock,$host,$port);
socket_listen($sock);
socket_accept($sock);

Python code (existing socket code is also included):
HOST = 'bbb.bbb.bbb.bbb'    #IP address of system I am already getting data from.
HOSTCONFUG = 'aaa.aaa.aaa.aaa'  #Rpi IP Address
PORTCONFIG = 8000           #PHP socket port
BUFSIZCONFIG = 4092
ADDRCONFIG = (HOSTCONFIG,PORTCONFIG)   #PHP script link
PORTSYS = 6000              #existing system port
BUFSIZSYS = 4092
ADDRSYS = (HOST, PORTSYS)   #existing system link

tcpSysSock = socket(AF_INET, SOCK_STREAM)    #existing system socket
tcpConfigSock = socket(AF_INET, SOCK_STREAM) #non functioning PHP socket
tcpSysSock.connect(ADDRSYS)
tcpConfigSock.connect(ADDRCONFIG)

I have checked out many other posts, books and trawled the net but I can't seem to spot where I am going wrong. As I understand it TCP networks can function with a server and client on the same system as long as separate sockets are provided for each.
Any help would be appreciated, been stuck on this for some time now.

A: Your PHP code is missing call to socket_accept:
socket_accept($sock);

Without socket_accept, php script will exit after socket_listen without waiting for client connection.


text:
Q: PostgreSQL ALTER VIEW Rewrite Changes AND / OR Meaning We have a big view in PostgreSQL that is supposed to include this join (names changed to protect the innocent):
LEFT JOIN table1 ON
table4.a = table1.a AND
(regexp_split_to_array(table2.code::text, '_'::text))[1:2] = (regexp_split_to_array(table1.code::text, '_'::text))[1:2] AND
(
    table3.b = table1.b OR
    (table3.b IS NULL AND table1.b IS NULL) OR
    (table3.b = 1 AND table1.b IS NULL) OR
    (table3.b IS NULL AND table1.b = 1)
) AND
(
    table3.c = table1.c OR
    (table3.c IS NULL AND table1.c IS NULL) OR
    (table3.c = 1 AND table1.c IS NULL) OR
    (table3.c IS NULL AND table1.c = 1)
)

However, when we save the view definition using CREATE OR REPLACE VIEW ... AS, it rewrites it and removes a bunch of the parenthesis, which substantially changes the meaning of the ANDs / ORs:
LEFT JOIN table1 ON
table4.a = table1.a AND
(regexp_split_to_array(table2.code::text, '_'::text))[1:2] = (regexp_split_to_array(table1.code::text, '_'::text))[1:2] AND
(
    table3.b = table1.b OR
    table3.b IS NULL AND
    table1.b IS NULL OR
    table3.b = 1 AND
    table1.b IS NULL OR
    table3.b IS NULL AND
    table1.b = 1
) AND
(
    table3.c = table1.c OR
    table3.c IS NULL AND
    table1.c IS NULL OR
    table3.c = 1 AND
    table1.c IS NULL OR
    table3.c IS NULL AND
    table1.c = 1
)

Those queries don't yield the same results.
(The data is from a 3rd party where tables get joined based on the numbers in a, b, and c, but if the ID is a 1 sometimes it's NULL, so 1 should match on NULL and vice-versa; it's messed up, but we don't want to change the data)
So in essence the rewrite is changing the meaning of the view and effectively breaking it.
Due to legacy software conflicts we're stuck on 9.4.26, so I'm not sure if the problem still exists.
Is there any way to prevent PostgreSQL from breaking the view during the rewrite (which I think is unavoidable)?
Thanks

A: I don't know about messing with how Postgres handles the view, but the path of least resistance may be rewriting your query to just use ANDs and so avoid any sort of parentheses shenanigans. Something like:
LEFT JOIN table1 ON
table4.a = table1.a
AND (regexp_split_to_array(table2.code::text, '_'::text))[1:2] = (regexp_split_to_array(table1.code::text, '_'::text))[1:2]
 AND   coalesce(table3.b, 1) = coalesce(table1.b, 1)
 AND   coalesce(table3.c, 1) = coalesce(table1.c, 1)

A: PostgreSQL doesn't store the view definition as a string, but it parses it into a "node tree" and stores it that way. This has the advantages that the view doesn't have to parsed each time, that it is immune to renaming of the underlying objects and that dependencies on those objects can be tracked.
Your parentheses may make the statement more readable, but they are syntactically irrelevant, so when PostgreSQL deparses the node tree into an SQL expression, it omits them.


text:
Q: Trigger second function in toggle() Is there a way I can call the second function in  toggle(function(){},function(){})

A: You could skip the toggle to the next function, if you really wanted to I suppose, for example:
$("div").toggle(function() {
    alert("First");
}, function() {
    alert("Second");
});

Then you can manually advance the .toggle() function array (without calling the first function), like this:
$("div").data('lastToggle' + $("div").data().events.click[0].handler.guid, 1);

Then just click the element or $("div").click(), etc, and it'll fire the second function.
You can give it a try here, note that this only works in jQuery 1.4+ and is really just to show it's possible.  You should however either bind them in reverse order, or give the second argument a named function as the other answers suggest.

A: how about
toggle(function(){ callFunctionOne(); callFunctionTwo(); });

A: I suggest such solution:
toggle(function(){},secondFunction);

function secondFunction() {}

And now you can call it how you want :)


text:
Q: Obtaining GoogleCredentials from One Tap Signin I'm trying to upload a file to Google Drive and let the user choose which Google account is used for the upload.
I'm following this guide:
https://developers.google.com/drive/api/guides/manage-uploads
As indicated, it demands some OAuth credentials to connect to the Drive API:

// Load pre-authorized user credentials from the environment.
// TODO(developer) - See https://developers.google.com/identity for
// guides on implementing OAuth2 for your application.

I've managed to get a SignInCredential object from the One Tap client, but now I'm trying to convert it to a GoogleCredentials object for Google Drive API.
Using the code inside the guide
GoogleCredentials.getApplicationDefault()
        .createScoped(Arrays.asList(DriveScopes.DRIVE_FILE))

...ends up in a crash:

The Application Default Credentials are not available.

And if I try to create the credentials on my own
    val accessToken = AccessToken(token, Date(0L))
    val credentials: GoogleCredentials = GoogleCredentials.create(accessToken)

I also ends up in a crash:

java.lang.IllegalStateException: OAuth2Credentials instance does not
support refreshing the access token. An instance with a new access
token should be used, or a derived type that supports refreshing.

What are we supposed to do here?

A: Well, I was trying to do the exact same thing and it was quite the journey to get this working. Several separate pieces of documentation are necessary, in completely different places, sometimes disagreeing with each other, sometimes horrendously out of date, linking to deprecated or lost resources and with aged code and dependencies.
If you just want to see the code, here you go.
The following is my best effort to piece this together - in a minimal sample, with modern code - but I know that authentication and authorization are delicate subjects so I urge any readers to please comment any security flaws I have in this code below
1. Setup Google Cloud
Generally we'll be following this tutorial first, we'll need other links from time to time.

*

*Setup a project in the Google Cloud console

*

*For me, project type was "external"

*Only "App name", "user support email" and "developer contact email" were mandatory. I will always mention only the bare minimum I needed to make this work

*For the next page, "Scopes", we'll need this documentation, in which you can find out which scope you need. I used https://www.googleapis.com/auth/drive.appdata, make sure to match your choice to the code later on. Note that this documentation also helps with this, especially if you need to edit later

*As a test user I added only myself. Note that all this works with unpublished and un-reviewed projects

*The tutorial recommends setting up the legal docs on the OAuth Consent screen now but it is not necessary for now

*Now follow the credential setup to the letter, create an Android Client ID (you can get the SHA-1 signature via gradle signingReport, make sure to get the debug key, not the debugAndroidTest key, and be aware that this will authenticate your debug app, if you want to make a release build later you will have to add another Client ID to the Google Cloud console for that one as well) and a WebClient ID

2. Setup the code
Now we follow this documenation in combination with this and this

*

*Add these dependencies to your app

implementation 'com.google.auth:google-auth-library-oauth2-http:1.16.0'
implementation 'com.google.android.gms:play-services-auth:20.4.1'
implementation 'com.google.http-client:google-http-client-gson:1.42.3'
implementation('com.google.api-client:google-api-client-android:2.2.0') {
    exclude group: 'org.apache.httpcomponents'
}
implementation ('com.google.apis:google-api-services-drive:v3-rev20230212-2.0.0') {
    exclude group: 'org.apache.httpcomponents'
}

I combined One-Tap and Google Drive dependencies here. These are up-to-date at the time of writing. Don't take the versions from this documentation, they are out of date and don't even compile with each other. Also we need an Android API client, not  the Java "Jetty" setup

*

*Setup the oneTapClient and the request like in the tutorial, make sure to use your WebClientId and do not replace hypens with em-dashes in the strings.xml as Lint recommends. Check my Github code startOneTapSignIn-method for a more modern implementation with an ActivityResultContract instead of startActivityForResult handling

*Now we need a android.accounts.Account to be able to use the method you mentioned above, to get a GoogleAccountCredential (which is just a fancy HttpRequestInitializer which we can use later for the Drive Service).

val credentials = GoogleAccountCredential.usingOAuth2(context,
    Collections.singleton(DriveScopes.DRIVE_APPDATA)
).setSelectedAccount(account)

*

*This is where I got stuck and what brought me to this question. The legacy login - which is used in all the Google drive samples - provides this out of the box via

GoogleSignIn.getSignedInAccountFromIntent(data)
   .addOnSuccessListener { googleAccount: GoogleSignInAccount ->

*

*But we can solve this. This Stackoverflow answer nudged me in the right direction, we can create an account instance ourselves! After some trial and error I found out that Google requires the user email, we can find that in the oneTapCredential.id
val oneTapCredential: SignInCredential = oneTapClient.getSignInCredentialFromIntent(data)
Log.d(TAG, "Signed in as " + oneTapCredential.displayName)
saveLoginSuccess(this, Account(oneTapCredential.id, packageName))

*

*That's it, now you can use this in combination with this and this to setup the Google Drive Service like so

@WorkerThread
fun download(credentials: HttpRequestInitializer): String? {
    val service =
        Drive.Builder(
            NetHttpTransport(),
            GsonFactory.getDefaultInstance(),
            credentials
        ).setApplicationName("OneTapDrive")
            .build()

For a full example of upload and download, again, see the Github


text:
Q: how can i find tripled values based on 2 columns I have a database called "Delivered" with several fields such as:
ID - Carrier - Date - Activated - Total Weight
I would like to obtain a result in which if the Total Weight was a tripled value of the same carrier and if it was activated = 1
ID      Carrier                                         Activated   Total Weight
324197  Filipa Carlos Alves - Pavimentos Unipessoal, AAA.   0           420
324204  Filipa Carlos Alves - Pavimentos Unipessoal, AAA.   0           820
324704  Francisca José Vieira Oliveira                      0            40
325152  FINIS - Respduos Industriais Unipessoal, AAA.       1           360
325464  FINIS - Respduos Industriais Unipessoal, AAA.       1           260
325531  Francisco José Vieira Oliveira                      0           200
326152  FINIS - Respduos Industriais Unipessoal, AAA.       1            20
326157  FINIS - Respduos Industriais Unipessoal, AAA.       1           120
326293  Francisca José Vieira Oliveira                      0           100
326325  F. P. & Pinto, Lda.                                 0           700
326563  FINIS - Respduos Industriais Unipessoal, AAA.       1           240
326564  FINIS - Respduos Industriais Unipessoal, AAA.       1           120
326914  FINIS - Respduos Industriais Unipessoal, AAA.       1            80
326921  FINIS - Respduos Industriais Unipessoal, AAA.       1           120

and the result should be
ID      Carrier                                         Activated   Total Weight
326157  FINIS - Respduos Industriais Unipessoal, AAA.       1           120
326564  FINIS - Respduos Industriais Unipessoal, AAA.       1           120
326921  FINIS - Respduos Industriais Unipessoal, AAA.       1           120

What is the best way to do it

A: You can use COUNT() as a window function to find the repeated rows. For example:
select *
from (
  select t.*, count() over(partition by carrier, total_weight) as cnt
  from delivered t
  where activated = 1
) x
where cnt = 3

A: Mentioning what RDBMS you use is important, but hopefully you can work off of this example.
WITH calculated_duplicates AS (
 SELECT
  [ID],
  [Carrier],
  [Activated],
  [Total Weight],
  COUNT(DISTINCT [Total Weight]) OVER (PARTITION BY [Carrier]) as number_of_duplicate_weights_per_carrier
 FROM [your_table]
 WHERE [Activated] = 1)

SELECT
  [ID],
  [Carrier],
  [Activated],
  [Total Weight]
FROM calculated_duplicates
WHERE number_of_duplicate_weights_per_carrier = 3

A: I believe you just need a correlated exists check:
select *
from Delivered d
where d.Activated = 1 and exists (
  select * from Delivered d2
  where d2.carrier = d.carrier
    and d2.Activated = 1
    and d2."Total Weight" = d."Total Weight" * 3
);


text:
Q: Phpmyadmin not storing correct decimal number I am facing an issue with stoing decimal(10,7) numbers which are coordenates, i have a form which i use to insert data in a table, in 2 of the input fiels i have an autofill with the following code.
navigator.geolocation.getCurrentPosition(GetLocation);
function GetLocation(location) {
document.getElementById("latitude").value = (location.coords.latitude);
document.getElementById("longitude").value = (location.coords.longitude);}

the problem is that in my table the inserted value shows the INT number and all the decilmals are represented by 0's like wise 57.0000000 and the same for longitude can someone please help on this as i am startin with php.
Many thanks.


text:
Q: Cordova ios error building Images.xcassets I've spent a lot of time trying to work this out to no avail.
I udpated cordova and since el capitan my mac now has issues with NPM and cordova.
I got it to install but I have to use sudo for cordova now.
I tried the following:
sudo cordova platform remove ios
sudo cordova platform add ios
sudo cordova build ios

And this gives me the following output:
** BUILD FAILED **

The following build commands failed:
    CompileAssetCatalog build/emulator/<AppName>.app <AppName>/Images.xcassets
(1 failure)
ERROR building one of the platforms: Error code 65 for command: xcodebuild with args: -xcconfig,/Users/MacUserName/Desktop/<AppName>/<AppName>/platforms/ios/cordova/build-debug.xcconfig,-project,<AppName>.xcodeproj,ARCHS=i386,-target,<AppName>,-configuration,Debug,-sdk,iphonesimulator,build,VALID_ARCHS=i386,CONFIGURATION_BUILD_DIR=/Users/MacUserName/Desktop/<AppName>/<AppName>/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/MacUserName/Desktop/<AppName>/<AppName>/platforms/ios/build/sharedpch
You may not have the required environment or OS to build this project
Error: Error code 65 for command: xcodebuild with args: -xcconfig,/Users/MacUserName/Desktop/<AppName>/<AppName>/platforms/ios/cordova/build-debug.xcconfig,-project,<AppName>.xcodeproj,ARCHS=i386,-target,<AppName>,-configuration,Debug,-sdk,iphonesimulator,build,VALID_ARCHS=i386,CONFIGURATION_BUILD_DIR=/Users/MacUserName/Desktop/<AppName>/<AppName>/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/MacUserName/Desktop/<AppName>/<AppName>/platforms/ios/build/sharedpch

Cordova version
sudo cordova -v
6.0.0

Update:  I'm now running 6.1.1, still the same issue
Cordova iOS platform version
sudo cordova platform ios -v
6.1.1

Mac Version: 10.11.3
XCode Version:7.2.1

A: *

*Rename Platform/ios

*on terminal type: cordova  platform add ios

*cordova build ios.

worked at my case

A: For a solo icon.png file, the image must be 1024x1024 to get working with a solo <icon src="icon.png"/> in the config.xml.
I have to this with cordova-cli 6.5.0, cordova-ios 4.5.1 and xcodebuild 9.0.

A: I managed to fix this issue by:

*

*removing any icon or splash screen references in the config.xml file;

*put a splash.png and/or icon.png files in the www/resources folder of your cordova project; then,

*run the ionic cordova resources --icon or ionic cordova resources --splash command

this will create all the correct splash/icon files for you and add them to the config.xml file.  That warning then goes away.
Hope this works!

A: I got this error when I was using cordova-icon but my icon.png image was not square.
Changing the icon.png to a square image and re-doing cordova-icon meant that cordova build ios now works for me.

A: Ths simple solution that I have tried is to add the correct size of the image 1024x1024
   <platform name="ios">
        <icon src="res/icon-1024.png" />
    </platform>

A: I would recommend using the cordova-icon and cordova-splash npm packages.  This is because you can just put two images in your root, then the commands will work out the rest for you.  They are written by cordova, and you can install using:
npm install -g cordova-icon
npm install -g cordova-splash

Then just put a 1024x1024 version of your logo as "icon.png" in the project root.  And:

"The splash screen image should be 2208x2208 px with a center square of
  about 1200x1200 px. The image may be cropped around the center square."
https://www.npmjs.com/package/cordova-splash

Just put an image matching that description in the project root as "splash.png"
Remove any lines in config.xml that specify the images to use for ios, cordova-icon/splash will automatically put them in the correct place with the right names so that xcode will recognize them.
Once you've got that setup, just execute these commands:
cordova platform remove ios
cordova platform add ios
cordova-icon
cordova-splash

Then run your build command.  For me it is:
cordova build ios --build-config

But you may not have a build config, or need additional params.  If the build fails (make sure you run the command even if you think it will fail - it will set things up) just open the generated workspace in platforms/ios in xcode, clean the project, and build.  That should work.

A: After digging into cordova_lib I think it's clear (to me) that cordova is not supposed to resize the icon for you but only copy them if they exist and have the right dimensions.
See this code in cordova-lib\src\cordova\metadata\ios_parser.js:
// See https://developer.apple.com/library/ios/documentation/userexperience/conceptual/mobilehig/LaunchImages.html
// for launch images sizes reference.
var platformIcons = [
    {dest: 'icon-60.png', width: 60, height: 60},
    {dest: 'icon-60@2x.png', width: 120, height: 120},
    {dest: 'icon-60@3x.png', width: 180, height: 180},
    {dest: 'icon-76.png', width: 76, height: 76},
    {dest: 'icon-76@2x.png', width: 152, height: 152},
    {dest: 'icon-small.png', width: 29, height: 29},
    {dest: 'icon-small@2x.png', width: 58, height: 58},
    {dest: 'icon-40.png', width: 40, height: 40},
    {dest: 'icon-40@2x.png', width: 80, height: 80},
    {dest: 'icon.png', width: 57, height: 57},
    {dest: 'icon@2x.png', width: 114, height: 114},
    {dest: 'icon-72.png', width: 72, height: 72},
    {dest: 'icon-72@2x.png', width: 144, height: 144},
    {dest: 'icon-50.png', width: 50, height: 50},
    {dest: 'icon-50@2x.png', width: 100, height: 100}
];

var destIconsFolder, destSplashFolder;
var xcassetsExists = folderExists(path.join(platformRoot, 'Images.xcassets/'));

if (xcassetsExists) {
    destIconsFolder = 'Images.xcassets/AppIcon.appiconset/';
} else {
    destIconsFolder = 'Resources/icons/';
}

platformIcons.forEach(function (item) {
    var icon = icons.getBySize(item.width, item.height) || icons.getDefault();
    if (icon){
        var src = path.join(appRoot, icon.src),
            dest = path.join(platformRoot, destIconsFolder, item.dest);
        events.emit('verbose', 'Copying icon from ' + src + ' to ' + dest);
        shell.cp('-f', src, dest);
    }
});

The best option seems to be using a plugin which does the resizing for you with hooks. Check out Generating iOS and Android icons in Cordova / PhoneGap or https://github.com/disusered/cordova-icon-gm for a new more futureproof version of the same plugin (hooks in directories are deprecated in 6.x).

A: I managed to solve this issue by removing the non-storyboard splash references in config.xml, the newest version of cordova seems to be only using the storyboard ones:
So removed:
    <splash src="res/ios/splash/Default~iphone.png" width="320" height="480"/>
    <splash src="res/ios/splash/Default@2x~iphone.png" width="640" height="960"/>
    <splash src="res/ios/splash/Default-Portrait~ipad.png" width="768" height="1024"/>
    <splash src="res/ios/splash/Default-Portrait@2x~ipad.png" width="1536" height="2048"/>
    <splash src="res/ios/splash/Default-Landscape~ipad.png" width="1024" height="768"/>
    <splash src="res/ios/splash/Default-Landscape@2x~ipad.png" width="2048" height="1536"/>
    <splash src="res/ios/splash/Default-568h@2x~iphone.png" width="640" height="1136"/>
    <splash src="res/ios/splash/Default-667h.png" width="750" height="1334"/>
    <splash src="res/ios/splash/Default-736h.png" width="1242" height="2208"/>
    <splash src="res/ios/splash/Default-Landscape-736h.png" width="2208" height="1242"/>

And kept only these:
        <splash src="res/ios/splash/Default@2x~iphone~anyany.png" />
        <splash src="res/ios/splash/Default@2x~iphone~comany.png" />
        <splash src="res/ios/splash/Default@2x~iphone~comcom.png" />
        <splash src="res/ios/splash/Default@3x~iphone~anyany.png" />
        <splash src="res/ios/splash/Default@3x~iphone~anycom.png" />
        <splash src="res/ios/splash/Default@3x~iphone~comany.png" />
        <splash src="res/ios/splash/Default@2x~ipad~anyany.png" />
        <splash src="res/ios/splash/Default@2x~ipad~comany.png" />

A: This is not a difficult error.Only thing has to do is remove all lines with

Images.xcastsets

from

platform/ios/.xcodeproject

Then remove platform ionic cordova platform rm ios,
Add platform again and build.

ionic cordova platform add ios
ionic cordova build ios

A: I had the same problem as the OP and whilst the accepted answer was correct and helpful there is now an updated (and maintained) resource generator on npm called cordova-res, which replaces cordova-icon and cordova-splash. Also, the required splash screen dimensions have increased. All the details you need are on the npmjs cordova-res page, from which I have taken the following info.
Install with:
npm install -g cordova-res

You'll need your icon.png and splash.png (the website says JPEG or PNG) images ready. These need to have the following dimensions:
icon.(png|jpg) must be at least 1024 × 1024px
splash.(png|jpg) must be at least 2732 × 2732px (note the increased size)
Just a little side note about the splash screen. Your image needs to be in the centre of the splash screen so that different rectangular device sized images are generated without cropping your splash screen image. As the accepted answer says, the size of this centre image needs to be about 1200 x 1200px.
Place these images in a resources folder in your project:
resources/
├── icon.png
└── splash.png

Before you generate the resources it might be worth removing and adding your ios platform (and others if you're building them too) to start with a clean platform folder. I don't know for sure if this is necessary.
cordova platform remove ios
cordova platform add ios

Run the following to generate the resources:
$ cordova-res

Then you can build your platform:
cordova build ios

Now all should be OK and hopefully resolved your xcassets error, as it did for me.


text:
Q: Probability of Various Combinations of Weather There's a 10% chance it will rain today. There's a 15% chance it will snow today.
What percentage chance is it that it will:

*

*Both rain and snow (it can both rain and snow at the same time)?

*Neither rain nor snow?
-

Raining and snowing are independent of each other.
EDIT: (ADDED)

*

*Rain or snow but not both?

A: Assuming (unreasonably $\dagger$) that "raining" $R$ and "snowing" $S$ are independent events,

*

*the probability of (rain and snow) = $$P(R \cap S) = P(R)\times P(S) = (0.1)\times(0.15) = 0.015 = 1.5\%$$

*The probability that it does not rain and it does not snow = $$P(\bar{R}\cap \bar S) = (1 - 0.1)\times (1 - 0.15) = (0.9)\times(0.85) = 0.765 = 76.5\%$$

$(\dagger)$ As a resident of Wisconsin, I know all too well that rain and snow are not, in reality, independent events. In "early spring" and "later fall" it is very likely that rain in the day turns to snow in the evening, so when one event happens it is very likely the other event will happen too. In short rain and snow, in the real world, are hardly independent! But for the purpose of this assignment, if it is to be answerable given the little information we have, we have assumed independence!

A: Short explanation:
Let $A$ : probability of snow ($A=0.15$);
Let $B$ : probability of rain ($B=0.10$);
There are $4$ possible events:
1) No snow, no rain:  $P_1 = (1-A)(1-B) = 0.85\cdot 0.90 = 0.765$;
2) Snow, but no rain:  $P_2 = A(1-B) = 0.15\cdot 0.90 = 0.135$;
3) No snow, but rain:  $P_3 = (1-A)B = 0.85\cdot 0.10 = 0.085$;
4) Snow with rain:  $P_4 = AB = 0.15\cdot 0.10 = 0.015$.
Note that $P_1+P_2+P_3+P_4=1$.

*

*Both rain and snow: $0.015 \ \ (1.5\%)$;

*Neither rain nor snow: $0.765 \ \ (76.5\%);$

*Either raining or snowing: $0.135+0.085 = 0.22 \ \ (22\%)$.

Illustration (Euler diagram):

Other illustration:

A: A variant of this question got deleted as a duplicate of this one, so I'm pasting a variant of my answer to that one here:
$$
\begin{align}
\Pr(\text{rain or snow (or both)}) & = 1 - \Pr(\text{neither rain nor snow}) \\[10pt]
& = 1 - \Pr(\text{not rain AND not snow}) \\[10pt]
& = 1 - \Pr(\text{not rain})\cdot\Pr(\text{ not snow}).
\end{align}
$$
You need independent events with the word "and" between them.  Then you can just multiply probabilities.
Now, then:
$$
\Pr(\text{rain or snow but not both}) + \Pr(\text{both}) = \Pr(\text{rain or snow or both}),
$$
and that last probability was found above.  The probability $\Pr(\text{both})$ can be found simply by multiplying.