array_sum PHP wrong result
Is floating point math broken?
What determines color -- wavelength or frequency? How do I use jpnevulator to capture and log the serial traffic between an application and hardware serial port? OK, I've been googling for hours so I obviously have not been able to understand the answers to the various questions that have already been asked about this subject.  I am hoping that, by asking the question again in a more specific way, I will be able to get an answer I can understand.  I have some application running in linux that communicates with an external device attached to a serial port.  I want be able to capture and log the data sent in both directions between the application and the device, with timestamps at the beginning of each line in the file.  As a test case, I am using minicom as the application I want to monitor, connected via a null modem cable to another computer also running minicom.  I have already confirmed that, if I type characters on either of the computers, characters appear in the other computer's terminal.  So far, so good.  I then found this question:    In the answer to this question, the program jpnevulator is suggested.  However, when reviewing the man page, I could not figure out the right way to use jpnevulator to get what I want.  Here is what I tried to do:  First, I opened a terminal window and typed the following command:  $jpnevulator --tty=/dev/ttyS0 --pty --pass --read --ascii --timing-print --file=serial.log   I saw the output:     jpnevulator: slave pts device is /dev/pts/18  I then opened another terminal window and typed the following command:  minicom -D/dev/pts/18 -b115200   Minicom opened without complaint.  However, when I typed characters in either terminal (local and remote), nothing appeared in either terminal.  jpnevulator only logged the data written to /dev/pts/18.  My expectation is that jpnevulator :   reads data from /dev/pts/18 and "passes" this data on to /dev/ttyS0 while also writing this data to the specified file. reads data from /dev/ttyS0 and "passes" this data on to /dev/pts/18 while also writing this data to the specified file.   I am aware of the remark in the faq that says "Jpnevulator was never built to sit in between the kernel and your application. I'm sorry."  However the very same faq states in the second paragraph down: "Now with a little bit of luck some good news: A little while ago Eric Shattow suggested to use pseudo-terminal devices to sit in between the kernel and your application."  That is the approach I am trying to take but I am having no success.  What am I missing?  Thanks to all in advance.  Cheers, Allan  p.s. I was successfully able to capture the back and forth traffic using the socat method mentioned in the existing question I referenced but this method did not offer any way of timestamping the traffic.  I was hoping that jpnevulator would have provided this for me. I am new to pythontex. I could run simple python code. However, I get error with slightly complex things.  The error I get is following:  This is PythonTeX 0.16  ----  Messages for py:default:default  ---- * PythonTeX stderr - error on line 211:     File "&lt;outputdir&gt;\py_default_default.py", line 62       MW= 18e-3 u.kilogram/ u.mole                 ^   SyntaxError: invalid syntax  -------------------------------------------------- PythonTeX:  notes - 1 error(s), 0 warning(s)  C:\texlive\2018\bin\win32\runscript.tlu:803: command failed with exit code 1: python.exe c:\texlive\2018\texmf-dist\scripts\pythontex\pythontex.py notes.tex   Part of the code that has error is :  \begin{pycode} import math from pint import UnitRegistry u = UnitRegistry() alpha = 0.04 sigmaW = 72.86e-3 * u.newton / u.meter mu    = 8.9e-4 * u.pascal * u.second densityW = 1000 * u.kilogram / (u.meter ** 3) densityIPA = 1000 * u.kilogram / (u.meter ** 3) densityEtoh = 1000 * u.kilogram / (u.meter ** 3) H = 1e-6 * u.meter W = 28e-6 * u.meter L= 32e-6 * u.meter MW= 18e-3 u.kilogram/ u.mole MIPA= 60.1e-3 u.kilogram/ u.mole MEtoh= 46.07e-3 u.kilogram/ u.mole R0=8.31446 u.joule / (u.mole * u.kelvin) T0= 298 u.kelvin N= 10 D0=2.4e-5 (u.meter ** 2)/(u.second) C0=17.08e-3 u.kilogram/(u.meter ** 3) tauevW=(densityW * N * R0 * T0 * (W **3))/(6* math.pi * D0 * C0 * sigmaW * MW) \end{pycode}   Does anyone know how to solve this issue? Can't format / delete locked partition from GParted? How to increase JAVA Heap Size? The  that is defined as $Y_{t} = Y_{t-1} + e_t$, where $e_t$ is white noise. Denotes that the current position is the sum of the previous position + an unpredicted term. You can prove that the mean function $\mu_t = 0 $, since $$E(Y_{t}) = E(e_1+ e_2+ ... +e_t) = E(e_1) + E(e_2) +... +E(e_t) = 0 + 0 + \cdots + 0$$ But why is it that the variance increases linearly with time? Does this have something to do with it's not “pure” random, since the new position is very correlated with the previous one? EDIT: Now I have a much better understanding by visualizing a big sample of random walks, and here we can easily observe that the overall variance does increase over time,  and the mean is as expected around zero. Maybe this was trivial after all, since in the very early stages of the time series (compare time = 10 with time = 100) the random walkers have not had yet the time to explore as much. How does one manually restart graphics drivers? I'm suffering from the dreaded . The problem is intermittent and can be "solved" by putting the computer to sleep or restarting it. I hope simply restarting the graphics drivers will remove the symptoms of the problem.  would seem to indicate that restarting the graphics drivers is possible in Windows 7. My question is: how? How to avoid getting shocked by static electricity? sometimes I get "charged" and the next thing I touch something that conducts electricity such as a person, a car, a motal door, etc I get shocked by .  I'm trying to avoid this so if I suspect being "charged" I try to touch something that does not conduct electricity (such as a wooden table) as soon as possible, in the belief that this will "uncharge me".   Is it true that touching wood will uncharge you? How and when do I get charged? I noticed that it happens only in parts of the years, and after I get out of the car... How to search by key=>value in a multidimensional array in PHP Show that $E(X)=\int_{0}^{\infty}P(X\ge x)\,dx$ for non-negative random variable $X$ Show that for a non-negative random variable $X$,   $$\mathbb E(X)=\int_0^\infty \mathbb P(X\ge x) \, dx.$$   I started with  $$\mathbb E(X)=\int_0^\infty x \, dF(x)=\int_0^\infty \int_0^x dt\,dF(x).$$ This is my try. How to check which package created a user? It is suspected that some packages have scripts run at install time which create user accounts in /etc/passwd. How can I check which package created a specific user? Windows 8 Setting an image on the login screen In Windows 8.1 when you log in there's the prelogin screen that has an image you can change, but then there's also the login (password entry) screen that as far as I can see is just a solid color.  How could I replace that with an actual picture? (ie, if I wanted a company logo to be displayed in the large space underneath the password entry box. Account not acting as an administrator correctly My account, david, is in the Administrators group on a Windows 7 machine.  I am still having problems with programs that I should be able to use, such as SQL Server. Specifically, my account seems to not have correct permissions when I am working.  I know with an Administrator account I should have full access. How can I force my account (david) to act like an admin account and have full access to everything? best way to pick a random subset from a collection? I have a set of objects in a Vector from which I'd like to select a random subset (e.g. 100 items coming back; pick 5 randomly). In my first (very hasty) pass I did an extremely simple and perhaps overly clever solution:  Vector itemsVector = getItems();  Collections.shuffle(itemsVector); itemsVector.setSize(5);   While this has the advantage of being nice and simple, I suspect it's not going to scale very well, i.e. Collections.shuffle() must be O(n) at least. My less clever alternative is  Vector itemsVector = getItems();  Random rand = new Random(System.currentTimeMillis()); // would make this static to the class      List subsetList = new ArrayList(5); for (int i = 0; i &lt; 5; i++) {      // be sure to use Vector.remove() or you may get the same item twice      subsetList.add(itemsVector.remove(rand.nextInt(itemsVector.size()))); }   Any suggestions on better ways to draw out a random subset from a Collection? This is what I see:  GNU GRUB version 2.02~beta2-9ubuntu1  Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists possible device or file completions.  grub&gt; _   What should I do now? Why is that when I open up my file in blender, the reference picture is gone When you are using a reference picture in blender, do you have to keep it? Do the pictures have to stay in your computer? I sometimes delete my reference images, because I'm on my mother's computer and any file I download has to go away. When opening my blender file the pictures are gone. How can I get my reference images to stay in my blender file even if the original file is deleted? New phone: How to transfer game progress? I'm planning to buy a new Android phone and I'd like to be able to transfer the progress I have made at several games to the new device, so I won't have to play all the levels again from scratch.  I currently have an HTC Desire and will buy an HTC Evo 3D.  There's probably no simple/general solution to this.  But I was wondering if anyone did something similar and could provide some advice (e.g. where to look for files that might hold game progress information). GNOME: supend on laptop lid close no longer works since 19.10 upgrade I'm quite positive that this used to work flawlessly in 19.04 (and past releases) but no longer does after a release-upgrade to 19.10 (kernel 5.3.0-24, ThinkPad X1 Carbon gen 5 in case this matters).  I have the corresponding switch set in GNOME-Tweaks and have also attempted to manually edit /etc/systemd/logind.conf as suggested , namely uncomment and adjust the following lines, followed by a reboot:  $ grep -v '^#' /etc/systemd/logind.conf [Login] HandleLidSwitch=suspend HandleLidSwitchExternalPower=suspend HandleLidSwitchDocked=suspend LidSwitchIgnoreInhibited=yes   (strictly speaking, only the first one ought to be required but, just in case, I also added lines 2 &amp; 3, as well as #4 for good measure...  Looking at the output of systemctl status systemd-logind, I see the following:  Dec 17 17:56:50 x1c5 systemd-logind[8959]: Lid closed. Dec 17 17:57:03 x1c5 systemd-logind[8959]: Lid opened.   So the lid events are correctly detected.  To rule out any issue with the suspend process itself, I have also set my power button to suspend in Settings->Power->Suspend &amp; Power Button, for testing purposes.  Pressing the power button now results in this in the output of systemctl status systemd-logind (after a successful suspend-resume cycle):  Dec 17 18:13:58 x1c5 systemd-logind[8959]: Power key pressed. Dec 17 18:14:28 x1c5 systemd-logind[8959]: Delay lock is active (UID 121/gdm, PID 9215/gsd-power) but inhibitor timeout is reached. Dec 17 18:14:39 x1c5 systemd-logind[8959]: Operation 'sleep' finished.   Bottom line: lid events are detected correctly and suspend works flawlessly - but not on lid close...  Any idea how I can get the suspend on lid-close feature back to life?  I can of course use the workaround with the power button but it's a little too easy to forget and result in laptop overheating in bag etc...  --- edited to add ---  Got a little further courtesy of , although the issue isn't the exactly as described.  Here's a smoking gun:  $ systemd-inhibit --list --mode=block WHO       UID  USER      PID  COMM           WHAT                                                     WHY                                                         MODE  gdm       121  gdm       2231 gsd-power      handle-lid-switch                                        External monitor attached or configuration changed recently block gdm       121  gdm       2252 gsd-media-keys handle-power-key:handle-suspend-key:handle-hibernate-key GNOME handling keypresses                                   block user      1000 user      3017 gsd-media-keys handle-power-key:handle-suspend-key:handle-hibernate-key GNOME handling keypresses                                   block   This suggests that the lid close action is being blocked because "External monitor attached or configuration changed recently".  I do connect my laptop to a monitor using a USB-C cable but as I write this, it's been undocked and running on batteries for nearly 3 hours (GNOME settings only shows my laptop display as available).  However it looks like systemd or whichever component is responsible for this still incorrectly believes the external display is attached and - per the ticket - suspend isn't supported by GNOME in such scenarios...  Interestingly the gsd-power process (PID 2231) is owned by gdm rather than my UID.  Killing it restores the suspend-on-lid-close functionality.  Need to figure out why this process exists... When actually connected to external display, systemd-inhibit --list --mode=block reports a 2nd gsd-power process owned by the interactive user; which appears correct and sufficient. I'm stuck on a question which asks to prove that any continuous integer-valued function of a real variable is constant. In my lecture notes we are told that a map is continuous if the preimage of any open set is open.  How do I use this to answer the question? A full answer would be greatly appreciated as I can't seem to figure out how to solve it in my  notes, in analysis books or anywhere online. How do I stop orca from starting up on login? Orca keeps starting up after system starting, and I'm not able to find it in "Startup Applications".  How to stop it?