Is algorithm performance dependent on the programming language used?

Question: I have studied complexity of algorithms that how long an algorithm will take to execute completely, then why it is said that certain programming languages are faster than others such as C++ is faster than python.
Answer: First of all, programming language can have an effect on the time complexity of algorithms. For example, many algorithms rely on mutating an element in an array in O(1) time. So any language that doesn't have mutable arrays (and it's not hard to imagine e.g. a dialect of Haskell that doesn't have them) will have worse time complexity for many algorithms.
But that's not the case here. While there are many differences between C++ and Python, their core capabilities are similar enough that for any algorithm you can write in one of them, you can also write it in the other one, with the same time complexity.
But time complexity is not the same thing as performance. If I know that the complexity of some algorithm is O(1), I still don't know how long executing an implementation of that algorithm for some input will actually take: it could be 1 nanosecond, 100 years, or anything in between. And because of the way the two languages are designed and implemented, a program in C++ will almost always have better performance than an equivalent program in Python. Which is why it's said that C++ is faster than Python.
Comment: @Giorgio The question specifically asked about the complexity of *algorithms*, not complexity of *problems*, so I think my answer still stands.
Comment: This is a very good answer to an otherwise broad question
Comment: "For example, many algorithms rely on mutating an element in an array in O(1) time.": To be pedantic, for each such algorithm there could exist another algorithm that performs the same task, does not need mutation, and still has the same or better complexity. So, yes, you cannot implement the same algorithm efficiently without mutation, but there could be an efficient solution to the same problem that does not require mutation.


Ssh and other services over openvpn are slow

Question: I use openvpn to access my workplace network.  When I ssh into a server(Ubuntu) over openvpn, as I type into the shell prompt the characters and letters appear slowly. So I should wait a little to see on the screen what I type. If I ssh directly (not via openvpn) then there is no delay at all. All other services also respond slowly: for e.g. accessing intranet web-pages, ftp or router configuration GUI, almost everything shows delay. I use 2 Mbps down and 800 Kbps up ADSL connection at home. And at work place I have 4 Mbps up and down ethernet based internet connection.
Answer: nix, make sure you are using UDP mode in OpenVPN. TCP will have to do fragment reassembly for one, and that will just get worse the lower quality the link is.
Comment: I think this may hit the nail on the head.  I agree with others above who are sceptical about the size overhead of encryption, but tunneling TCP in TCP is known to cause horrendous performance problems over congested or erratic lines, as the backoff and retransmit algorithms for the tunnel traffic and tunneled traffic step on each other's feet.  See eg "The server is configured to use UDP packets since TCP over TCP can lead to poor performance" in http://www.dd-wrt.com/wiki/index.php/OpenVPN .
Comment: When I set it up, UDP had been selected by default, and I have left it as it is.
Answer: Any encryption mechanism will add an overhead to your connection, have in mind that overheads for some encryption are enormous.
OpenVPN by average will add a 40% to 50% overhead to your connection, on top of that ssh will also add a 40% overhead average.
All this can very easily explain why your connection over openvpn+ssh is so slow, you can do some things to make the connection lighter but it'll sacrifice a bit of security.

Use crypto signatures of 1024 bytes top (don't go 2048 or 4096 unless you really need to)
Use SSH1 or SSH2 with RSA instead of DSA (a bit less overhead)
Use SSH compression by default

All this will help make the tunnel lighter and faster, also if you have direct SSH access try using SSH tunnels to your application instead of OpenVPN, will remove one encryption layer and will also help speed wise.
I've replied to your question because I find it interesting but have in mind that if you don't accept your answers (the 17% accept rate indicates that), the community will be a lot less willing to help you out, this site is all about community and that accept rate is showing you as a not community player, which will hinder your results in the future.
Just take it as my 2¢, no criticisim!
Comment: What!?!?!  do you really believe that crypto makes data 40% bigger?  that's _so_ wrong!
Comment: public keys only get sent periodically with SSH and OpenVPN, so your 128 bytes of savings (1024 vs 2048) is mostly speculation. Agreed with Javier, encryption adds very little in payload size. Try it.. 'gpg --compress-algo none -c /etc/hosts' .. mine only grew from 340 bytes to 382 bytes. 12%, and thats likely because it was small and so didn't fit well in the blocks of CAST5.
Comment: IT is not a believe Javier, it's based on real bandwidth usage calculations that need to be done in order to expense a new line to the datancenter ;)
Comment: Lynxman, how to have crypto signatures of 1024 bytes. I already have dh dh1024.pem. Is it what you are referring to?
Comment: Yeah nixnotwin, exactly, 1024 bytes signatures will result in a smaller footprint
Answer: I had kind of the same problem. But the strange thing was that it worked fine to connect to the vpn-server through Tunnelblick on my macbook, but it was damn slow from ubuntu.
I did change from tcp to udp, and then it worked fine again. Except from Netbeans, which is still slow.


Is making something "atomic" essentially just a lock mechanism?

Question: From the OpenMP summary pdf: "operation ensures that a specific storage location is updated atomically". This brough up the question for me what "atomic" is and wheter it is just a lock mechanism. So if I remember correctly "atomic" means that some hardware support is built in to prevent anything else from changing the value. So is making something "atomic" essentially just implementing a lock mechanism or is it something more?
Answer: I think there might be some confusion around "atomicity" vs "isolation". They're similar concepts, but there is a subtle difference between them. Atomicity means that an operation either completes entirely, or not at all. Isolation guarantees that operations that happen concurrently result in a state that could have been caused by them executing serially.
For example, if the operation is "add 1 to x, then multiply x by 2", and x starts as 3, the result will be 3 if there is any sort of failure, or 8 if there is not. Even if the power cuts out right after 1 is added, the result when you reboot is guaranteed to be 3.
Now consider what happens if this operation is performed twice, concurrently. Both could fail, resulting in x=3. One could fail, x=8. Both could succeed, x=18. If we are guaranteed isolation, these are the only outcomes. But, if we are only given atomicity, not isolation, a fourth outcome could happen, wherein the individual parts are interleaved as "add 1, add 1, multiply by 2, multiply by 2", resulting in x=20!
If you're guaranteed only isolation, but not atomicity, you could end up with x=3, 4, 5, 8, 10, or 18.
With all that said, this is a common misconception, and often when people say "atomicity" they mean both. That's my suspicion of what they mean in the OpenMP documentation.
Answer: Updating a value stored in memory is a three-step process.  First the value is fetched from memory and brought to one of the CPU's registers.  Then, the value in the register is changed in some way (say incremented).  Finally, the new value is written back to memory so that it can be used again.
Doing this (or any other) operation atomically simply means that all three of those steps happen, or none of them does.
It only becomes interesting or important when you have another thread or process that also needs to use that same memory value.  Suppose both want to increment the value, which is initially zero.  Without atomic operations, the second thread might read the original value (0) from memory even as the first thread is incrementing it in a register.  Effectively both threads may see the value 0, increment it to 1, and return it to memory.  At the end of this sequence, the value in memory would be 1 despite having been incremented twice.
With an atomic increment operation, there is no way that that sequence can occur.  Once the first thread enters the atomic sequence, there is no way the second thread can read the value in memory before the first thread has incremented it and written it back to memory.  You'll always get the correct value (2).
So, to answer your question, it's almost like a lock mechanism.  In particular, it's like a lock mechanism exists around whatever the original operation was.  Atomic operations themselves are frequently used in the implementation of other locking mechanisms, such as mutexes and semaphores.


Can a single PostgreSQL query use multiple cores?

Question: In recent versions of PostgreSQL (as of Dec 2013), can we share a query between two or more cores to get a performance boost? Or should we get faster cores?
Answer: No, for versions of PostgreSQL prior to v9.6. Please see the PostgreSQL FAQ: How does PostgreSQL use CPU resources?

The PostgreSQL server is process-based (not threaded). Each database session connects to a single PostgreSQL operating system (OS) process. Multiple sessions are automatically spread across all available CPUs by the OS. The OS also uses CPUs to handle disk I/O and run other non-database tasks. Client applications can use threads, each of which connects to a separate database process.
Since version 9.6, portions of some queries can be run in parallel, in separate OS processes, allowing use of multiple CPU cores. Parallel queries are enabled by default in version 10 (max_parallel_workers_per_gather), with additional parallelism expected in future releases.
Comment: Cant believe in this modern age a design would favor heavy load process context switching to implement multitasking instead of using light weight high performance multi-threading. Thank you for the clarification. This explains why our systems suffer under load now when we switched to Postgres based upon some apparently bad advice.
Comment: Multithreading is harder to write and reason about, shared memory and locking between threads can be troublesome.  I don't think multithreading is necessarily inherently better.
Answer: PostgreSQL 9.6+ onwards, would start to see Parallel-Query finally coming to PostgreSQL.
For e.g. Concepts like Parallel Scan / Parallel Join / Parallel Aggregates are now already baked in, with more to come soon.
What's really exciting is that there are reports confirming near-linear speed-up in some cases, which is pretty impressive!
Answer: No, but there is a workaround. :)
I found parsel (parallel select) PL/pgSQL function, which splits your query based on the primary key, then connects to the database via the dblink extension and waits for all subqueries.
The author also wrote an article about this function.
Comment: @LuisLimas I've reuploaded functions to the new gist.
Comment: Both links are broken :/
Answer: No. Each connections spawn a separate process on server.
You can "emulate" some parallelism using a threaded procedural language like pljava.
Create a java procedure(function) that launches several threads and create the output result using several workers.
The backend is syncronized so each worker can update the output asynchronous.
Java has good support for thread coordination/cooperation.
As examples, this would be nice for CPU intensive operations or network length operations.


How to install JRE on FreeBSD 8?

Question: I'm newbie on FreeBSD.
How to install JRE on FreeBSD 8.x?
Comment: If you know any other way instead of pkg_add, please let me know.
Comment: Similar: [*Install Java 9, 10, 11, or 12 on FreeBSD 11.1*](https://serverfault.com/q/942101/142214)
Answer: You can't (yet).
If you look at http://www.FreeBSDFoundation.org/downloads/java.shtml you'll see that the FreeBSD Foundation has packages for FreeBSD 6 and 7, but not for 8.
There may be another way, or someone else may even have created packages, but if they have, I don't know about it.
Answer: Java 8, 11, & 12 available
Work has recently resumed to keep up-to-date the Ports & Packages tree on FreeBSD for the latest and greatest Java versions.
These versions are based on the OpenJDK project (a consortium of Oracle, IBM, Apple, and others).

OpenJDK 8 (JDK, JRE)
OpenJDK 11
OpenJDK 12

To install:
sudo pkg install openjdk12

You will find OpenJDK installed in /usr/local/openjdk12/.
You may want to set some environment variables to point to your OpenJDK installation. For example, in my .zshrc configuration file for zsh, I add this line:
path+=/usr/local/openjdk12/bin

Note that there is no longer any JRE for later versions of Java. With Applets and Java Web Start being phased out, there is no longer a need for end-users to install a Java runtime. Desktop and console apps are expected to be built with a Java runtime bundled inside. The Java Platform Module System and related tools such as jlink make this easier than ever, with a smaller runtime that includes only the libraries actually used by your particular app. For more info and links, see my Answer on sister site Stack Overflow.
In the future, you may also find releases of OpenJDK for FreeBSD on the AdoptOpenJDK web site. AdoptOpenJDK is a cooperative effort of some folks in the Java community to regularly publish binary builds of OpenJDK.
Be aware of the new Java release cadence. Java 8 and Java 11 are the current Long-term support (LTS) releases.
If you want to follow the progress on porting Java to FreeBSD, or perhaps assist, see this mailing list.

How to install JRE on FreeBSD 8?


How could a human doctor save a poisoned Kosh, given that Vorlon biology is totally different from human?

Question: When Kosh was poisoned, Dr Benjamin Kyle saved him. How could a human doctor be able to save a Vorlon when the Vorlon biology is so different from humans'? In fact, the Vorlon had no physical form and seemed to exist in some kind of floating gaseous form like a ghost. How can that be even treatable in the first place by a human doctor?
Comment: There are human doctors very able to deal with different biologies: veterinarians.
Comment: Seems very dupey. The other question addresses the nature of the poison. Presumably a competent doctor would know how to nullify a poisonous agent and we know that the Vorlons have a (sort of) physical component to their biology.
Comment: I don't think it's a dupe at all. Especially as that questions asks about poison administration, and the accepted answer basically posits the fact that the assassin was Minbari, and therefore more aware of Vorlon physiology. Dr Kyle wasn't Minbari so lacks this knowledge, and treating poison is very different to administering it.
Answer: Not easily, but clearly it was done.

Both doctors on the show are specialists in xenobiology, which means they have quite a bit of experience in figuring out how other species work.  Admittedly, Dr. Kyle was working from scratch, given the lack of info on the Vorlons, but thats likely to be a situation he's handled before.
The majority of Dr. Kyle's work involved not figuring out the entirety of Kosh's biology, but identifying the location and type of the poison.  Once he had that, he neutralized it.  There's little indication he could do a lot more, besides provide an optimal environment, and Kosh may have been able to recover at that point on his own.
Vorlon do have a physical aspect, although that doesn't necessarily mean things like walls pose much of a barrier.  There are glimpses of Dr. Kyle's medical screens that mention things like crystalline structures, so he was clearly trying to learn and cram as much as he could.
Kosh still appears to have some form of consciousness even while affected.  His suit opens after he senses Kyle's intents, and Lyta is sent directly to the information she is seeking as soon as she makes contact.  Kosh could have been subtly helping him all along, nudging or highlighting ideas that would put him closer to helpful actions.


Will capital gains from one state offset capital losses from another state?

Question: I moved in the middle of the year. I made capital gains from stock sale while living in NYC and then had capital loss from stock sale after I moved to NJ. Usually I could offset capital gains with capital losses but given I moved, do I still need to pay capital gains tax to New York given there was no loss during my NY residency?
Answer: The capital losses will not offset, so you'll still have to pay capital gains tax to NY. A rough formula for NY part-year resident tax is:
<code>tax on total income x (NY income / total income)
</code>
Your NY income will be unaffected by the capital losses. Your total income will go down, which means the tax on the left will go down, but the fraction on the right will go up. Hard to predict the overall effect, but it almost certainly won't be as favorable as if you could include the capital losses in your NY income.
Usually this would pretty much even out, as you'll pay more tax to the old state but less tax to the new state. However, NJ doesn't allow net capital losses (i.e. you can't offset regular income) and it doesn't allow carryover losses to offset capital gains realized in NJ in future years. So unfortunately the capital losses will only help with your federal income tax.


Why "normal subgroups occur as kernels of homomorphisms" is a big deal?

Question: I already knew that normal subgroups where important because they allow for quotient space to have a group structure.
But I was told that normal subgroups are also important in particular because they are the only subgroups that can occur as kernels of goup homomorphisms. Why is this property a big deal in algebra?
Comment: Well, because kernels are a big deal, I guess ;)
Comment: Because essentially there is a severe poverty of big deals in Algebra, so you get what can.
Comment: Normal subgroups are also a "big deal", because groups without non-trivial normal subgroups are so important. Being kernel of a group homomorphism is just equivalent to being normal, so nothing new.
Comment: Practically the same issue. Quotient spaces correspond one to one with the kernels of the natural maps that are involved.
Comment: Associated with a group $G$ we often get (or can cook up) its action on some set $X$. This means that we have a non-trivial homomorphism from $G$ to $Sym(X)$. When cardinality considerations dictate that the said homomorphism cannot be injective, we can conclude that $G$ has a non-trivial normal subgroup. This theme recurs when proving that a group of certain order cannot be simple.
Comment: I tried to touch the philosophy of quotient groups [in this old answer](https://math.stackexchange.com/a/69063/11619). Because normal subgroups and quotient groups come hand-in-hand, some of the ideas carry over.
Comment: @uniquesolution But there are many ideals in Algebra, which is pretty close
Answer: I suppose this is more of opinion-based question. If I interpret your question as "Why is it a big deal that the subgroup determined by the kernel of a homomorphism must be normal?", then the answer is "It's not really a big deal. That's trivial." Instead, if I interpret your question as "Why is it a big a deal that normal subgroups arise as kernels of homomorphisms?" then that's another story.
There are many situations where you can prove something interesting about (normal) subgroups by being clever with kernels of homomorphisms. Here are two simple examples.
Fact 1: If $G$ is a group and $H$ is a subgroup of index $n$. Then $H$ contains a normal subgroup $K$ of $G$ with index at most $n!$.
Proof: Let $X$ be the set of left cosets of $H$. Then any element of $g$ determines a permutation of $X$ in which each coset is multiplied on the left by $g$. Define the function $f:G\to S_{X}$ sending $g$ to its associated permutation. (Here $S_{X}$ is the group of permutations of $X$.) It is easily checked that $f$ is a homomorphism. Let $K$ be the kernel. Then $K$ is a normal subgroup of index at most $|S_{X}|=n!$, and it is easy to check that $K$ is contained in $H$.
In the previous proof, the definition of $f$ implies that $K$ is the intersection of all conjugates of $H$. So $K$ is the "largest" normal subgroup of $G$ that is contained in $H$.
Comment (added later). Continuing from the last sentence, set $K=\bigcap_{g\in G}gHg^{-1}$. So $K$ is the largest normal subgroup of $G$ that is contained in $H$. And the proof above shows that it has index at most $n!$. But one my try the following more direct approach. Choose left coset representatives $g_{1},\ldots,g_{n}$ for $H$. It is not hard to see that $K=\bigcap_{t=1}^{n}g_{t} Hg_{t}^{-1}$. Also, any conjugate of $H$ still has index $n$. So $K$ is an intersection of $n$ subgroups of $G$ each of index $n$. Now the general formula $[G:H_1\cap H_2]=[G:H_1]\cdot [G:H_2]$ tells us that $K$ has index at most $n^n$. So this proves the Fact without using homomorphisms but with a worse bound on the index.
Fact 2: Suppose $G$ has order $2n$ where $n$ is odd. Then $G$ has a normal subgroup of size $n$.
Proof: Any element of $g$ determines a permutation of $G$ via multiplication on the left. So we get a map $\varphi:G\to S_{G}$ which is a homomorphism. Let $\psi:S_G\to C_2$ be the map that sends a permutation in $S_G$ to $0$ if and only if it is even. (Here $C_2$ is the cyclic group of size $2$.) Compose these to get a homomorphism $f: G\to C_2$. By Cauchy's Theorem, $G$ has an element $x$ of order $2$. So $\varphi(x)$ is a permutation of order two with no fixed points. So $\varphi(x)$ is a product of $n$ disjoint transpositions. Since $n$ is odd, we have $\psi(\varphi(x))=1$. So $f$ is surjective. If $K$ is the kernel of $f$ then $G/K$ is isomorphic to $C_2$. So $K$ has index $2$, i.e. size $n$.
The last fact tells us there are no simple groups of size $2n$ if $n$ is odd and bigger than $1$.
By the way, the last proof used Cauchy's Theorem for $p=2$. I know it's got nothing to do with your main question, but here's a cute proof. Suppose $G$ is a group with even order. We aim to find an element of order $2$. Let $X$ be the set of elements of order greater than $2$. Then no element in $X$ is equal to it's inverse, so we can partition $X$ into sets of size $2$ by putting each element with its inverse. So $|X|$ is even which means $|G\setminus X|$ is even. Since $G\setminus X$ contains the identity, it must contain at least one more element, which has order 2.
Answer: Let $G$ be a group. Since the normal subgroups of $G$ coincide, as a set, with the subgroups that appear as kernels of homomorphisms with domain $G$, the normal subgroups are exactly the subgroups of $G$ that appear as the left object in short exact sequences of the form
$$
1\longrightarrow N\longrightarrow G\longrightarrow K\longrightarrow 1.\qquad(*)
$$
The point is that once you have an exact sequence $(*)$ the group $G$ can be reconstructed out of $N$ and $K$ plus some extra-combinatorial data (technically, cohomological data depending only on $K$ and $N$).
Now suppose that $G$ is finite. Then, the isomorphism theorem tells you that $|G|=|N|\cdot|K|$, i.e. the group $G$ can be reconstructed out of smaller groups plus some additional data depending only on those smaller groups.
If you have a list of finite groups that contain no normal subgroups (these groups are called simple) the above sets the very first step towards the goal of reconstructing all finite groups.
When $G$ is not finite the property has still some interest, for instance when studying representations of $G$, i.e. homomorphisms of the kind
$$
G\longrightarrow{\rm GL}(V)
$$
where $V$ is some vector space.


STFT needs circular shift or not?

Question: In some textbooks and websites, circular shift operation is done before doing FFT of windowed data, in the explaination, circular shift is to ensure zero-phase. But in other textbooks and websites(I would say most), circular shift operation is ignored in the implementation. So what is the correct way to do STFT and Why?
Answer: There's no universally "correct" or "incorrect" way to do STFT, as the choice to apply a circular shift depends on the specific application and requirements. For many applications, the phase distortion introduced by not applying a circular shift might be negligible or can be ignored. In some cases, the phase information might not even be of interest at all, and only the magnitudes of the STFT are used.
So, whether or not to apply a circular shift in the STFT depends on your specific application and the importance of phase information in your analysis. The idea is to apply a window function (e.g., Hamming, Hann, or Blackman window) that is centered around the zero phase. This is helpful in minimizing the phase distortion, which can potentially improve the clarity of the resulting spectrogram or be beneficial for certain applications like the inverse STFT.
All in all, it depends strictly on your application and perhaps limitations!
Comment: "if my application is phase sensetive ... circular shift operation is strictly needed" the effect of shifting (or not) is very predictable, and can be taken out in the frequency-domain output.
Comment: Thanks a lot. So technically speaking, if my application is phase sensetive(i.e accurate phase value is needed, for example, phase vocoder), circular shift operation is strictly needed to correct phase distortion?
Comment: For that matter, in applications where the FFT and the data collection are co-resident, the shift may be done implicitly, just by where the collected data gets stuck as it is collected.
Answer: Yes, shift. For the spectrogram $|\texttt{STFT}|$, however, it makes no difference.
For most (if not all) non-spectrogram applications, the shifting step is either done directly or compensated for in post-processing. Major ones are instantaneous frequency/amplitude localization (and their applications, including denoising and decomposition), phase vocoding (audio stretching, pitch-shifting, other), and advanced spectral manipulation (modifying STFT and inverting) due to losing one-integral inverse.
Advantages to not shifting are limited: easier to code efficiently, and easier for most practitioners to understand since most view STFT as "windowed Fourier transform". There may be a few others I'm missing, including applications, but I wager they're few.
The reason is simple: not shifting largely invalidates STFT as a time-frequency representation. This is understood from Equivalence between "windowed Fourier transform" and STFT as convolutions/filtering, which also explains the rest of my answer.
It's implemented in ssqueezepy (I'm author), and includes CPU and GPU acceleration.
Comment: I'm in agreement with this.  Perhaps for reasons that OLGD would not agree with.  Remember that the DFT is circular, not linear.  The second half is really the negative half.  The middle of the window should be at index 0.

STFT needs circular shift or not?


Point sample opacity/alpha in Adobe Photoshop?

Question: I opened a PNG containing an alpha channel in Photoshop and wanted to get the opacity / alpha of a given point in the PNG file, so that I could match that opacity in a new photoshop layer. How can I do this? is there any way to get an alpha value at a point the way the color sample tool gives RGB values at a given point?
Answer:
Open the Info palette
Click on the palette option in the top right corner and choose Panel Options...
Where it says "Second Colour Readout", choose Mode: Opacity
Hit "OK"

In the info palette it will now tell you the opacity level of wherever you put the mouse.
Comment: Perfect! I knew there was a way to do this.
Comment: Hmmm. I am getting 100% which is plainly incorrect as I can see the underlying layers through the area I am sampling. It feels like 10%. What could I be doing wrong?
Answer: If there is a portion of your image that contains 100% of a color, and your alpha section contains < 100% of that same color, you can do it. For example, if you have a gradient from 100% color to 0% color, with alpha transparency, here's what you do:

Open gradient transparency file in Photoshop. It should be layer 0.
Make a copy of layer 0.
Using the move tool, move one layer to the left, the other to the right, so that there is gap between them.
Add a background layer and fill it with white. You should now have 2 gradients on a white bg.
On the original layer 0, place color sampler #1 at the point on the gradient that you want to measure for opacity. The color at that point will show in the info palette.
On the layer 0 copy, place color sampler #2 at the point where the gradient is 100% color. The color at that point will also show in the info palette.
Make sure that the color samplers each show a different value.
On the layer 0 copy, begin to lower the opacity, and then use the arrow keys (on kb) to lower the opacity in 1% steps. Lower it until the color sampler values match. Now read the opacity of the layer. This should be the opacity at point you are testing for, provided the base colors are the same.

Note that you need the colored background. If you turn off the bg, you'll notice that the color samplers will read the same for your gradient. Give it a try. This is the reason for step #7. I don't know that this will work if the colors are not the same, or at least very close to get you in the ballpark.
Answer:
Make solid white layer upon solid black one;
CTRL + click on layer with your iamge. It will make selection based on its opacity;
Select white layer and click "Make mask" button (under layer stack). It will make mask from your selection;
Profit! Simply use color picker on that point - any color in RGB will show you that point's alpha on your image;


Passing commands to blender with GUI open

Question: is there a way to pass python commands to blender with the GUI visible? I have a simulator made in Matlab where measurements can be changed. When one of these measurements change I want the script to pass a command to an open blender GUI so the changes are made in real-time. I have everything working except that if I use the interactive python console I can't see the GUI, it's just grey. Right now I have to use the command to run blender and then run a script, but to make any changes I have to rerun blender with an updated script.
Answer: It could be any way that you can pass data from one Python script to another. I am not going to pretend I know a lot about that, but one simple and primitive way could be to save a script to a file and check if the file is changed from Blender. You can make an add-on(See Blender's Text Editor Templates menu) with a timer, that checks for scripts to run.
I believe there are more sophisticated ways as well. For example see Python: Server and Client in Blender. But that looks considerably more difficult to make.


Is the GST credit any higher than usual starting July 2010?

Question: I've heard through the grapevine that starting July 2010 GST credit cheques will be higher than usual because of this new HST? Does anyone have a confirmed answer to this? Thank you.
Answer: The GST/HST credit is a federal program meant to offset some or all of the GST or federal portion of the HST.  The amounts are not increasing due to Ontario or B.C. introducing HST.  The amounts are the same for all Canadians irrespective of province.
However, the GST/HST credit is still increasing, slightly, due to inflation.  Here's a link to the schedule of the GST/HST credit payment amounts.  Note the individual amount increases from $248 to $250.
However, Ontario is introducing the new Ontario Sales Tax Credit.  Perhaps that's what you heard about?  There's also a list of OSTC Frequently Asked Questions.  Note in particular:

The [Ontario Sales Tax] credit is a
  non-taxable quarterly payment that
  will be issued separately from the
  GST/HST credit payments.
Answer: The 250 is for for a single person per year so the total of the 4 payments which would be 62.50 for a married person the benifit amount is 500 a year (4 payments) which equals 4 payments of 125 =500 I hope that answers your question
Answer: If you havent done so, open an account at cra.gc.ca/myaccount for all payment dates and scheduled payments. I checked my account and my July GST payment was 175.75 and the October, January and Arpil payments are 285 each!!


What's the difference between mitm attack and sniffing?

Question: What's the difference between MITM attack and sniffing? Also could anyone name a few other attacks similar to those?
Answer: Typically, an eavesdropper (sniffer) will be passive -- that is they will not modify the traffic.
Man-in-the-middle (MiTM) attacks usually imply an active adversary -- one who will change the contents of the message before passing it on.
The two are not entirely distinct, as a MiTM may use their active attack to read the contents of messages, or simply to disrupt communications.
Answer: It's sort of like asking the difference between a car and steering. When you are driving a car, you can (and probably should!) steer it. But you can steer a bike too...
Enough with the analogy, the difference, in my view, is that MitM is a class of attack and the sniffing is simply the word for analyzing packets on the network (and often just the packets going to/from your network card).
Once someone has become the "man" in a man-in-the-middle attack, they are able to sniff incoming/outgoing packets of their target.
Other related attacks/terms (to name a few) would be Arp Poisoning and DNS hijacking
Answer: A sniffing attack is a attack on confidentiality. It can be via a span port on a switch, processes on servers through which the traffic passes, on the end user client. Sniffing is often an MITM attack but it is passive.
A MITM attack is typically a more active attack where the traffic route has been altered to include the adversary, such as a rogue access point, or ARP/DNS poisoning, to allow a sniffing attack, break encryption, and/or tamper with the delivery of content (an integrity and confidentiality attack).
Once established as an active attack a MITM can hijack sessions, alter content to hide activity, inject malicious code, and depending on the service accessed perform sensitive functions. Some but not all of this is possible as a follow on from a passive sniffing attack using the information gathered.
Related / similar attacks are MiTB (man in the browser), keylogging, session hijacking, click jacking, and XSF.
Answer: The question should actually be "Difference between ARP Poisoning and Network Sniffing"
MITM attack can occur in both cases. Network sniffing is possible in each and every internal network and there is no other cure other than encryption or end point security. If you are on public wifi or untrusted  network, you shouldn't be using unencrypted services over network or internet. For example an attacker can hijack your session within a network if you are surfing and logged into a non-https website.
While in ARP poisoning, attacker can even alter traffic because attacker's machine becomes the gateway of target machine. An example would be DNS spoofing via ARP poisoning. Since attacker's machine is the gateway of target, he can fake the DNS and resolve facebook.com to his own IP. He can then host a phishing page on his IP. So thats why whenever you visit facebook.com or others, you should check the greenlock on top. If you see some SSL error on https://www.facebook.com then it probably means someone is in the middle of you and facebook.com and you shouldn't force browser to proceed. ARP poisoning can be prevented and is mostly not possible in big organizations.
Answer: An attack can fit into multiple classifications at the same time.
In this case, these attacks both deal with captured network traffic between two hosts. The deciding factor is what's done with the captured data.
Man in the Middle (MITM)
Here network traffic is secretly captured and relayed between two hosts. If the data is not relayed to its intended recipient, then the attack is not a MITM attack, but rather a denial of service (DoS) attack. In fact, even if the data is relayed, but at suboptimal speeds, then the attack is both an MITM and a DoS attack.
Sniffing
This is the analysis of captured network traffic. If someone just analyzes captured traffic intended for his machine (with say Wireshark), that's just passive sniffing. If someone captures traffic with say, ARP poisoning, and then analyzes that traffic, then that becomes an active sniffing attack.
A word about ARP Poisoning
Strictly speaking, this just a preliminary step that allows for different types of follow-up attacks. Again, it depends what's done with the captured network traffic. If the traffic is not relayed to its intended target, you have a DoS attack. If it is, you have an MITM attack. If the traffic is also analyzed, then you additionally have a sniffing attack.


How to keep running multiple geth nodes running on multiple VMs continously?

Question: I have 50 VMs and I installed geth on every VM. Now I need to run geth on each VM by doing ssh on each VM. So, I am facing one problem with this when I start a geth node on VM by ssh it starts at that time but, when I come out of ssh it stops. How should I keep the geth process running on VM continously even if I come out of ssh from that VM?
Comment: What OS are you running on your VMs? `screen` may be your best bet here
Comment: I have Ubuntu-16.04 running on each VM. @TC8
Answer: I run our private nodes on Ubuntu VMs through screen - this provides an environment which can run on after you close the SSH connection. You could also use it to run multiple geth instances on the same VM, if you felt like it (just create multiple datadirs and use unique ports for each instance)
See the manual here for full info, but some high level features I'd mention are as follows:

You can configure a custom /etc/screenrc file to preload geth, log files etc in individual tabs within screen nice and easily. You can then copy this file to each VM and run screen in a terminal; once geth is running correctly press ctrl + a, d to detach from the session and it'll continue running in the background
include autodetach on in your screenrc file to ensure that the process carries on even if your SSH connection cuts out unexpectedly
see here for some custom screenrc formatting to make your tabs prettier - and easier to manage
Answer: Use docker container with dynamic ports
you can use docker compose similar to something like this setup
and then docker-compose up --scale node=200 without having to manually configure each instance


Website Access Denied

Question: I'm new to TOR. I downloaded TOR Bundle for Mac OS. My current version is 10.12.6. When I launch TOR it looks like Firefox but shows TOR Browser in the top line of the tab (menu line?). I have an American Express account and I can access it using Safari or Firefox. The URL I use to access my American Express account rejects me by saying: "You don't have permission to access "http://online.americanexpress.com/myca/logon/us/action/LogLogonHandler?" on this server.  Reference #18.17dcf180.1505760563.19f6a98." I'm not sure why the error message does not show https and only http. The URL shows a secure https. What setting do I need to change to allow access? I need an answer suitable for a kindergartener. Thanks.
Answer: americanexpress administrator set up the server to refuse all Tor IP addresses, so, it is not possible to login. their server refuse you as login as you use proxies. possibly their admin installed suricata on their server or similar software that can recognize tor IP address and block access.

Website Access Denied


Unknown electrical component in circuit

Question: I was checking out a circuit for power management. That's when I came across this unknown component which looks so much like half a transformer and a switch. What exactly is this?
Comment: Looks like a relay to me.
Comment: is this regional (US)? Today I know that a zig zag line can mean a resistor, but when I learned it there were only rectangles. [same here](http://www.homofaciens.de/bilder/technik/relay_005_400x195.gif), left is what we got here, right is how I learned to draw it.
Comment: A more common arrangement would show the coil to the left of the contacts, so you can visualize the coil pulling the moving contact toward itself when energised.
Comment: @dlatikay The two different resistor symbols are indeed a Europe vs US distinction. I believe a few other symbols are also different.
Answer: It's a relay. Single-pole double-throw relay, to be precise. Extremely basic and common component. A current through the coil creates a magnetic field to control the switch. Typically used to allow for circuit isolation and/or for using a low current signal to control a high current source. Wiki
Comment: They can also be used to replace switching transistors to a certain (and highly inefficient) extent, or to easily switch multiple circuits with a single signal. If you're interested, [here's a simulation](http://tinyurl.com/y6uekcfm) of a demo circuit I was asked to create. Mix of SPDT and DPDT relays to create an astable multivibrator 4.4Hz clock and H-bridge motor controller.
Answer: It appears to be a relay, which as you suggest does look a lot like a combination of half a transformer (coil) and a switch; in this case, it is a magnetically operated switch.
Some schematics seem to draw a relay with the extra parallel lines (bars) between the coil and the switch contacts, others do not, so you may not always see those two parallel lines between the coil and switch contacts. To my knowledge this looks like a regular single-throw relay, with a normally open (N/O) switch contact and a normally closed (N/C) switch contact, on either side of the common (usually marked 'C') switch contact.
When the coil is energized by a voltage being applied across it, a magnetic field forms, and this attracts the switch 'arm' away from the N/C switch contact towards the N/O switch contact. When the coil is no longer energized, the switch arm (usually with the aid of an additional spring, spring leaf, or due to the arm being formed from spring steel or similar into a spring-like shape) will return to make contact with the N/C switch contact.
Relays come in many shapes and sizes, some with many series of switch contacts that can be 'thrown' when the coil is energized, and then return to their resting positions after the coil voltage is removed.
Some particularly interesting and complicated relays were used in analogue telephone switch systems, such as these before the advent of fully digital exchanges. Sometimes telephone exchanges will still have some pieces of analogue switch gear working along side the newer digital equipment, but most exchanges are now fully digital. I worked at a British Telecom exchange for a short while in the late 1990's and they were still transitioning from the analogue exchange equipment to a fully digital fibre-exchange, and there were several floors of the building still occupied with huge equipment racks of analogue switch gear and telephone relays. It was quite a sight to behold and to hear!
Wikipedia has some great additional reading on relays too: https://en.wikipedia.org/wiki/Relay
I hope this helps, and hopefully others with more experience than I, will contribute or make corrections if I haven't explained things clearly.
Comment: It's a single-pole double-throw, not single throw. Easily confused. I remember it by thinking "Pole = moving Parts" and "Throw = Things it can Touch." Also, relays (and inductors in general) are more concerned with current than voltage. May seem a pedantic point, but it's an important distinction to understand.
Comment: NC = Normally closed, NO = Normally open.  When the coil isn't energized, the C = Common (unmarked middle terminal) is connected to the NC terminal. When energized, the NO is connected to C, and NC is disconnected from C.
Comment: I believe the bars symbolize the magnetic core of the coil. If the bars are absent, it's a coil wound around air.

Unknown electrical component in circuit


Dual boot Windows 7 and Peppermint (merge two drives)

Question: I had two laptops; one Windows 7 and one Peppermint OS.  The Linux machine died and I would like to re-size the partition on the Windows drive and copy over the Linux drive to make the machine dual boot.  I have seen tutorials on installing Linux to a new partition but can I simply copy over the files from the Linux drive?
Answer: You can resize the Windows drive after booting from a Linux USB/CD.
After that you can copy the files from the old Linux drives onto the newly created partition after making a filesystem on it (assuming you can built in that drive in e.g. a USB enclosure).
For the copied files you have to change /etc/fstab to reflect new UUIDs or partitions, and you have to update the grub configuration. Then you can install grub in the bootsector and dual-boot the machine.
It might be easier just to do a fresh install and copy your data files over.
Comment: I will probably go with the fresh install option.  Thanks.
Answer: The simple answer is no.
In order to dual boot, you have to partition a hard drive and install the operation system on the separate partition.
Luckily, most linux distros offer the capability to dual boot.
Here is the general tutorial on how you can a dual boot system with USB/CD:
First, grab an .iso of the Linux system you would like. Make sure that is the right distribution (either x32 or x62 bit)
Second, create a boot disk with either USB/CD. I use Unetbootin because it is simple and effective.
Third, restart computer, boot using the USB .iso image, and from there you will get the choice to either install the new OS or to test it out. If you are intent on installing, go right ahead and start that process, else you can test the linux distro and leave your original hard drive untampered.
Note: When installing the new operating system, you are going to have to repartition your existing hard drive. Some operating systems will do this automatically, but if you have to do so yourself, here is a general procedure:
First, create two new partitions. One is for the operating system itself, which you can format as Ext4. Give it at least 10 GB of space, and set the mount point as /.
Second, create the second partition for what's called swap space. This essentially helps your computer manage memory more effectively and keeps it running fast. If you have a small amount of ram (one or two GB), you'll want your swap partition to be twice as large as the amount of RAM you have.
If you have any more concerns, refer to Peppermint OS installation guide here:
http://peppermintos.com/guide/downloading/


Designing 0- 300 mA current source with 12v Voltage supply (load = constant 40ohm)

Question: I'm trying to design a 0 to 300 mA controlled current source, the problem is that the supply voltage is a normal adapter with a 12v output. I'v already tried several op-Amp based circuits but the voltage drop over the load exceeds the power supply in all of them. suggestions for a circuit?
Load is a constant 40ohm device.
Thank you all
Comment: What are the characteristics of the controller?
Answer: You say you want a 0-300 mA current source, but that the load is a constant 40 Ω.  There is therefore no distinction between a 0-300 mA current source and a 0-12 V voltage source.
The biggest problem you have is that your circuit can't drop any voltage at full output since you only have 12 V to start with.  That's not possible, so what you asked can't actually be done.  However, you can get reasonably close.  Of course a better answer would be to start with a power supply a little above 12 V so that the pass element is allowed to drop some voltage at full load.
To minimize the voltage drop across the pass element, use a MOSFET.  It's not hard to find devices that can go down to a few mΩ with full gate drive.  20 mΩ, for example, is 0.05% of your 40 Ω load.  That would be within measurement error for most purposes.
You didn't give any constraints on how this current source is supposed to be controlled, so we can pick something simple.  A pot setting the gate voltage of the MOSFET provides control over the current.
Here is a circuit that meets all your specs, except that it doesn't quite put out 12 V or 300 mA with exactly 12 V in:

This particular MOSFET can handle up to 20 V and goes down to less than 10 mΩ with 10 V on the gate.  Only you can say whether that is close enough.  Again, your specs are actually impossible to meet.
The control is achieved by rotating the pot (R1).
Answer: This would be my starting point: -

Choose R1 to be low in value hence it won't drop too much voltage in sourcing current to the load. If you chose 1 ohm then to get 300 mA through the load, Vin would be 0.3 volts and the drop across R1 would also be 0.3 volts. The drop across the transistor would be about 0.2 volts at best so, to deliver 300 mA into a 40 ohm load requires a supply of 12.5 volts.
So you might as well bite the bullet and generate 15 volts from the 12 volts using a dc-to-dc converter and there are plenty around. If you pick an isolating one it gives more options because you could use a converter that produced 2.2 volts at the output and float that output up to produce a rail of 12 volts + 3.3 volts = 15.3 volts. Plenty of options.
If your load can drop significantly below 40 ohms then you might need a heatsink on the PNP transistor.
If you want to look at other options regards generating a constant current these google images should help.
Comment: +1 for the isolated DC-DC converter suggestion because it would allow the use of a cheap single supply op-amp like the LM324, by just flipping everything over.
Answer: Any circuit you can build will have some voltage drop. 300mA * 40 ohms is 12V which is your nominal power supply voltage. If your power supply is a bit low and/or your load resistance a bit high you will never get to 300mA even with a direct short.
So, you have two main choices here- the easiest is to compromise the spec and limit the current to maximum (say) 275mA which gives you a nominal 1V to work with. Maybe that ends up being 0.5V after you take into account tolerances. That is tractable- the maximum drop across your pass device (transistor, probably) plus the voltage drop across the measuring resistor must not exceed that 0.5V. If the transistor needs 0.25V you can use a 1 ohm resistor and meet the spec. The lower the resistor value the less voltage for your feedback, so more errors will creep in. The trade-off will depend on what your required stability and accuracy spec is.
The second choice is to boost uo your 12V using some kind of switching supply to something high (eg 15V), in which case you can choose a nice big feedback voltage such as 3V (use a 10 ohm resistor) or 2.25V or 2.5V to match a reference voltage. Such a circuit will produce more EMI, consume more power and will be more complex than a simple current regulator, but it will meet your stated requirements.

Edit: Since others have supplied (perhaps dubious) schematics, I'll throw one or two in here for good measure:
Boost converter:
If you follow the 34063 data sheet calculations you can easily determine the values of the components not shown.
Current source ( note source, not sink):
The op-amp I show is an unusual high-voltage rail-to-rail input type. There are other ways of doing it but this is simple. An ordinary LM324 will not work, and certain FET op-amps will only work if  you are lucky.

simulate this circuit – Schematic created using CircuitLab
If your load is actually a constant resistance and you don't need to adapt to any changes then you could build a 0-12V supply, but it would not be significantly simpler than what is shown.
Comment: thank you,
I did try to design a boost converter but my it failed, could you guide me to a simple design procedure?
Comment: Easiest design procedure is to go to a manufacturer or distributor with a parametric search engine and look at various "chips" that are available that meet the requirements- maximum input voltage well over 12V will eliminate many of them, so you will have fewer to look at in detail. The detailed design procedure will be outlined in the datasheet (inductor specs and frequency, for example). One of the oldest, cheapest and often least efficient chips is the [34063](https://www.onsemi.com/pub/Collateral/MC34063A-D.PDF), you can check out Figure 9 and adapt the output voltage.
Answer: well you can try this circuit. It uses a negative feedback to stabilize the output at near to 12V. Since it's done by a good loopgain, you can expect pretty good source resistance as well. Well with 12 Volt, you can't expect a 300mA load, but it's pretty close.
Comment: That circuit will NEVER work. For a start, what controls the current? Next, have you bothered even to consider the significant limititations imposed by a 741 op-amp?
Comment: My answer refers to increasing the supply voltage to 15 volts. Even if you did this your opamp circuit WILL NOT control the load current as asked for.
Comment: @Andyaka, voltage at the emitter of that emitter follower will always be at 12 (well to the best of what opamp can do). Now opamp can only go as much in the output. so you are kind of right, we want a voltage more than what opamp can supply. but current is controlled by a 12V/40ohm.
Comment: @Andyaka, The design was simulated to be alright! And OpAmp is bound to be saturated, even in your design. because of 12V supply voltage, it is quite impossible to meet the design with simple circuits.
Comment: I believe with a 15V supply this design will work even better...That is the core of the standard regulator ICs out there...Throughout the negative feedback, load will be supplied with a steady 12V voltage (and 300mA as requested)
Comment: Oh my, another 741. Let's party like it's 1968. What next, wax and paper capacitors?
Comment: The 741 was bad in it's day, so I'd downvote just from the frustration of actually using it.


iOS client app with Mac server

Question: I am attempting to build a client/server game architecture and would like to begin testing the game using my local Mac as the server.  I have found several articles on Bonjour, but that is for local network traffic only.  My goal is to make this application work over the Internet, connecting to a hosted application on a static address to facilitate turn data.  However, I'm at a loss as to which Cocoa APIs to use for this purpose.  Should I use NSConnection, NSStream subclasses, or good 'ol C sockets and whatnot.  The game state is already built in Objective-C and is ready to be set in motion once I have the server facilities ready.  Any insight?
Comment: You might also be interested in https://bitbucket.org/snej/mynetwork/wiki/Home
Answer: NSConnection, NSStrean and C sockets are build for different needs. You need to specify the needs of your game and the kind of service in order to get more help. If you want to develop a client-server application that relies on the Internet and not on the local network, Bonjour will not be able to help.
C sockets, and Cocoa APIs that wrap around them are intended to operate on an open network stream between the client and the server. The advantage of having an open stream is that you can have the server send data to the client without the client having requested for it. NSURLConnection in Cocoa works differently. With it, you can perform HTTP requests and receive formatted responses from a server.
If your application is based on HTTP requests, I recommend you take a look an NSURLConnection, or AFNetworking, as a 3rd party alternative. If your application relies on open streams, I recommend you take a look at CFNetwork from Apple (C wrapper around BSD sockets that originates from the days Macs had Carbon, with great performance, stability and versatility) and GCDAsyncSocket, a 3rd party library wrapped around BSD Sockets, supports Crand Central Dispatch, is Objective-C ready, and does the job wonderfully.
I hope I helped.
Answer: I suggest you to use sockets, since they're not hard to use and are a standard way. I've even written an asynchronous wrapper class around BSD sockets: https://github.com/H2CO3/TCPHelper
This is for simple, one-to-one TCP protocol connections, supporting both IPv4 and IPv6. You can send and receive raw NSData and possibly build a protocol around it.
Foundation classes such as NSURLConnection are not particularily for this purpose; rather than to interact with standard HTTP servers (I suppose you don't want to implement a full HTTP server for a game).
NSNetServices may suit you just like CFNetwork, but the latter is a bit harder to use. If you'd like to use Foundation classes, I'd recommend NSNetServices.
Hope it helps.
Answer: There are many different ways to accomplish this.  It really depends on how you'll be passing the data and what it will be used for.
First, I would setup a hostname that you can use for development purposes with your game. You can use anything like http://dyn.com/dns/ to setup this for your Mac.  Then you can enable a compiler setting to switch out the development / production URL's.
Next, I would recommend using TCP sockets for your game (using CocoaAsyncSocket - https://github.com/robbiehanson/CocoaAsyncSocket).  This method should work fine your your use case.  Since you are doing turn-based data (and since all of that data is vital) I would not recommend using UDP sockets (but those would work if you were solely passing position, video, or audio data where a dropped packet might not matter).

iOS client app with Mac server


What happens when you're not online and the drafts start?

Question: If I join a league and then go offline. And in the meanwhile the host/starter of the league start the draft selection. How will I get the players? Are they assigned automatically?
Answer: All player/team/alt selections are drafted randomly if you are offline during the drafting phase.
However, you can still manage your team until the matches start (starting line ups, flex player, etc)
After this weeks matches are played, you can participate the new draft again. If you are online, it is manual drafting, if you are offline, it is assigining random but the picks will be according to the suggested order so you will still have a decent team.
Answer: I'm not sure what you are talking about, but if you are in select champion phase, and your internet goes down, then if the time goes to zero, then you are kicked of the match and your friends will return to room. Is that what you asked?
Comment: I am talking about fantasy lcs not normal games
Comment: you tagged league of legends!
Comment: It is technically league of legends related


Why very few countries have joined the Coalition for Disaster Resilient Infrastructure?

Question: To my understanding, the Coalition for Disaster Resilient Infrastructure is an international knowledge platform and could help countries for efficient disaster management.
Why are there very few countries in it?
Answer: Like always, there are most likely a whole range of reasons why there are few member states to the Coalition for Disaster Resilient Infrastructure (CDRI). But I think it is safe to say that money is one of the more pressing reasons why few  countries signed up.
With most countries (governments) in the world already in significant debt, this would mean spending additional money they do not have for a situation which may or may not occur to them in the near future. And the conservatives/republicans they have a strong tendency of caring more about money than people, regardless of which country we talk about.
When you look at the list of member countries, you can see that about half of the member states is fairly rich.
You can clearly see that similarly to the mandate of the CDRI, but not included in their primary objectives, even rich countries struggle with this. A very good example is actually the United States. Where it has been proven repeatedly that building codes can greatly reduce damage and increase protection for people who are hit by a hurricane or twister, you still see many houses in the US build from wood, board and bricks. In parts of Australia the building code requires not just concrete but even the roof and the walls being structurally integrated to make it stronger. This will help survive a major hurricane. Likewise, it has been shown repeatedly that the only wall to stop flying timber from penetrating a wall during a tornado is, again, concrete. Yet most houses in the US are not build from concrete. And this is all about money. Short term policies. And here we're talking about the US not a 3rd world country how does not have any money.
The reason I bring this up is because it is a good example that shows that it would require significant investments to achieve such goals. The building materials are expensive. And the construction labour force to do this is simply not in place.
Electricity. Most countries have above ground electric cables. Easy and cheap to install and cheap to maintain because of accessibility. Yet they break much more frequently. And they typically break when there is a disaster and you need them the most.
In addition to all this there is also politics involved. China and India are not the best of friends. Of course China is not going to sign up to this, since the whole plan was initiated by India. And with this, though only 1 country, you capture some 20% of the world population.
In addition to the above, most people hate changes. Why change if what you have works? Never mind it does not work, they think it works, or at least works for them. Or similarly; 'Yes, it happens, but it does not happen to me'. And this thinking is what you also see in governments, because believe it or not, they are actually people like you and me as well.
On a site note, I would like to mention that Mongolia has signed up. A very poor country, landlocked between Russia and China, who both have not signed up. They went through a political transition during the last 15 - 20 years or so, which is far from complete. And they signed up as well! Very encouraging indeed.
Answer: There are many, many platforms, ngo's that faciltate disaster management. For example, the UN coordinates a worldwide network on climate change prevention with climate mitigation. This has added urgency in recent years due to the series of unprecedented global heatwaves.
The platform that you've highlighted is part of this extensive programme of works being launched at a UN Climate Summit Week 2019. There is so little participation because people with the power - western politicians - and China - are not simply living up to their commitments of climate mitigation funds. After all, it is a scientifically acknowledged fact, that the carbon pumped into the atmosphere since the indistrial revolution was mostly done from Western powers fuelling their industrialisation when the aymosphere was thought of as an infinite sink. After all, the Global South are saying they were the least cause of the current climate crisis and yet they are paying more heavily through it because of the poorer infrastructure there isn't resilient against the climate crisis.
For example, the Pakistani Prime-Minster, Shehbaz Shariff has said that Pakistan is not to blame for the climate crisis fuelled disaster that has flooded much of the country, saying:

We are suffering from it, but it is not our fault at all ... we are dealing with a situation that I have not seen in my lifetime. More than one million houses damaged or destroyed and seventy-two districts of Pakistan are in calamity and all four corners of Pakistan are underwater and more than 3,500 km of roads habe been washed away. Arpumd one million animals have died. It is the toughest moment in the history of Pakistan ... Now, I say, without fear, I have not seen such devastation in my life. We request the international community to come and help us and stand by us in this hour.

If these promised climate mitigation funds were forthcoming then these disaster and resilience protocols would see a far greater uptake.
Answer: To be honest, I've not seen a lot of press about it (outside India), so it could be simply because of its obscurity. Other than that, looking at its charter, I can speculate that the permanent/prominent role given to India in the charter

5.5 India shall be permanent co-chair of the Governing Council.
5.6 The other co-chair shall be nominated by rotation by the members of the Governing Council, every two years.

might have annoyed some countries that don't have (too) good relations with India, relative to the benefits of membership. (Concretely for now some $3M in grants, from what I could figure out.) The permanent Secretariat is also located in India.
The other current co-chair is the US--a fact that might have annoyed the Russia+China aligned countries, for the time being. (Neither Russia nor China joined CDRI.)
Answer:
the Coalition for Disaster Resilient Infrastructure is an
international knowledge platform . . .  Why are there very few
countries in it?

It is easy for countries to free ride on its efforts by hiring civil servants or government contractors who have assimilated the knowledge that it has developed for a fraction of the price of being a member.
Comment: Providing some evidence for your claim would be good. (For instance, that governments have hired contractors or are implementing recommendations from the CDRI without being members.)


Monoprice printer: no files found on SD card

Question: My monoprice printer was working; I then tried to format the SD card on a Mac, then it stopped working. I have now tried three different SD cards after formatting on a Windows PC, and still nothing works. Are there supposed to be files on the SD card itself like some kind of root files?
Comment: See the discussion at https://3dprinting.stackexchange.com/questions/7845/how-to-format-an-sd-card-for-monoprice-select-mini-v2 and see if it helps.
Answer: I've no idea why 3D printers don't like SD cards formatted by operating system utilities, but they don't. Use SD Memory Card Formatter to format your memory cards. Unfortunately, you have probably lost any data that was on the original SD card.
The SD cards that are supplied with 3D printers typically contain documentation, test files, and device drivers. However, these files do not need to be present for the correct operation of the printer. All that is needed is a correctly-formatted SD card containing the G-code files that you want to print.
Comment: This addresses the formatting of the card (like the answer in the [linked question](/q/7845/), can you comment on the root files part of the question? I've never heard of such files for printers.
Comment: I'm skeptical -- my A8 clone  is perfectly happy with SD cards I've formatted FAT32 via MacOS


Number of subgroups of an infinite group

Question: Is there an infinite group with only a finite number of subgroups?
Answer: No. An infinite group either contains $\mathbb Z$, which has infinitely many subgroups, or each element has finite order, but then the union $G = \bigcup_{g \in G} \langle g \rangle$ must be made of infinitely many subgroups.
Answer: Note that there are infinite groups with only a finite number of normal subgroups. For example the following infinite groups are simple.
The finitary alternating group $A(\lambda)$ for any infinite cardinal $\lambda$.
$PSL_n(K)$, with $K$ an infinite field and $n\geq 2$.


VPN provider asks to install RootCertificate. How is it safe?

Question: I want to use VPN provider (ProtonVPN), and don't want to use an app. They ask user to install their Root Ca. How safe is it? What type of info could they get from my laptop? If I have their certificate installed, does that means they can see and get all info from my browser, including passwords and https sites? And what about other non browser traffic? How safe is it? What are the risks?
Comment: The primary function of a VPN is specifically so that the VPN provider sees all your traffic, not your ISP (or public WiFi). If you don't trust the VPN more than your ISP then there's not much point using one.
Comment: The actual reason to use a VPN is to connect an external machine to a private corporate network. But it's recently being heavily marketed for "privacy" to the general public in order to make money.
Comment: *If you don't trust the VPN more than your ISP then there's not much point using one* Not exactly; there is another major difference: my ISP can easily match a name and an address with my navigation data; my VPN provider has to jump through more hoops to do that.
Answer: Your question sounds too broad. It sounds like "trust this certificate for any possible purposes" including SSL/TLS, means also for accessing web sites in your browser via SSL/TLS. The most of users will answer a question asked in such broad form by "Of course, don't do that".
But pay attention to their instruction step 4:

... select Use Custom Settings and Always Trust only the IP Security
  (IPsec)

Suppose you are afraid that they want to be a man-in-the-middle and intercept your traffic to read or to modify it. If you trusted their certificate for SSL purposes, that would be possible. But you set the SSL usage policy to "Never Trust". And if they do that, then your browser will warn you, that the web site you are trying to open has an invalid certificate because it was issued by untrusted CA (by Proton CA).
But since you allow trust for IPsec only, other purposes are not affected at all.
TLDR: Yes, it is safe, if you follow the needed steps exactly.
Comment: I have no issues with your answer (in fact I voted it up) and I didn't issue an answer exactly because I wasn't able to adequately answer the OP's question. My comment was aimed at checking your opinion as to whether you agreed such request was suspicious. I haven't yet had the chance to get into the website to check the instructions, but at face value, it looks suspicious to me. I'll delete the comment since I don't want to cause confusion or give the wrong impression.
Comment: I have not read the instructions, I will have a look.


Kirov-class battlecruiser could change history?

Question: I was a big fan of zipang (anime) and final countdown (movie), will be like if one Kirov class cruiser modernization return in 1942
Comment: Stop assuming everyone saw what you did and explain us what the cruiser can do
Comment: Please explain why you think it would make a difference.
Comment: Zipang shows it can. Final countdown shows it can't. It depends a lot on the rules of your time travel.
Comment: Your question doesn't seems to be asking anything at all.
Comment: @VictorStafusa, it isn't a *good* question, but if you've seen the movie the intent seems clear.
Answer: Let's start with a few assumptions:

A McGuffin or plot device transports a fully operational Kirov-class battlecruiser into the year 1942.
For more or less understandable reasons, the crew decides to assist the Soviet government of the time, i.e. Stalin. While they might not be actual Stalinists, they're patriots, and waiting the war out in Tahiti isn't really an option.
After a misunderstanding or two, they open communication and Stalin believes that the crew of the Kirov are genuine and willing to help in the Great Patriotic War.

The next question would be just how desperate the Soviet government is at the time:

The smart move would be to bring the ship to a safe port (in the Far East?) and to put the crew and equipment to work in R&D. One cruiser, no matter how good, is going to wear out. It would be incredibly short-sighted to fire her missiles at the enemy instead of starting to reverse-engineer them.
Textbooks in her library will be extremely useful, too. In addition to science, they can make use of history books up to the arrival of the ship for reference. They're history, but they have the benefit of hindsight and analysis.
By contrast, any descriptions of history after the arrival of the ship are going to be questionable. The time travelers will alter events and the butterfly effect makes their knowledge invalid.
The stupid move would be to send the Cruiser against the German Navy. She is no ASW ship and the German surface fleet was well handled by the Brits.
If any of the P-700 missiles have a nuclear warhead, using them might be considered if there is a way to employ them against strategic land targets (and if the crew has the required launch codes).

What kind of world do you want to build? A novel, a gaming scenario? That should influence your choices.

Will any of the characters end up in the Gulag, perhaps in a special Sharashka camp?
Will any of the characters rise to leadership positions in the Stalinist regime? Do they have to betray anybody?
How soon until the Soviets can mass-produce nuclear weapons? A bomb they made themselves can be expended more easily. On Berlin? During the Korean War?
Can they come up with a delivery system to hit the US?
Even without using nukes, a more confident Stalin might not press the western Allies for a second front. A cold war with the USSR in control of continental Europe, and with a steady stream of reverse-engineered technology to help their R&D?

Random thoughts:

The ship will have radar proximity fuses for their guns, plus manuals and at least a few officers who understand the science behind them.
Quite a lot of computing power. How much depends on when they left the real world and got marooned in the fictional world. Do they have a PC, a programmer, and a compiler? They could compute firing tables for historical artillery and help with other kinds of research.
The Kirov has turbines for top speed, and three helicopters. Soviet jet and turboprop technology gets a boost.
Comment: Quite true. To see combat the crew really would have to decide to help the Americans or the British against the Japanese. I guess they could do convoy escort in the Mediterranean too. Or convoy raiding if they decide to side with Hitler. Hard to see Russians siding with Hitler even if they hate Stalin, though... Optimal solution would probably be to go to the Americans and make a deal. Giving the US a big tech boost early enough might have been enough to force Stalin to adopt a different strategy post-war. The crew might take the gamble of the outcome being better for Russia.
Comment: @VilleNiemi, depends on what time they came from. Are they Communists first or Russians first? Is the captain even a Russian?
Answer: On second thoughts, the arrival of the time-travelling cruiser might just as well doom the Soviet war effort.
Stalin's paranoia will splash on everybody whose original-timeline-future-self approved Khrushchev's secret speech at the 20th party congress, despite the fact that they were indispensable senior management during the war years.
So depending on who gets the history books first, either a new great purge or a desperate revolt.


For $K$ the splitting field of $x^8+1$ over $\mathbb{Q}$, determine $Gal(K/\mathbb{Q})$.

Question: Let $f(x) = x^8+1$.  To determine the Galois group $G$, we first need the splitting field and before that we need to find the zeroes of $f$. So, $\left(re^{i\theta}\right)^8 = 0$ implies $r=1, \theta=\frac{\pi}{8}, \frac{3\pi}{8},\ldots, \frac{15\pi}{8}$ where by half angle formulas all of the roots are
\begin{align*}
\pm \left( \frac{\sqrt{2+\sqrt{2}}}{2} + i\frac{\sqrt{2-\sqrt{2}}}{2} \right) & &\pm \left(\frac{\sqrt{2-\sqrt{2}}}{2} + i\frac{\sqrt{2+\sqrt{2}}}{2}\right) \\
\pm \left( - \frac{\sqrt{2+\sqrt{2}}}{2} + i\frac{\sqrt{2-\sqrt{2}}}{2} \right)& & \pm \left( -\frac{\sqrt{2-\sqrt{2}}}{2} + i\frac{\sqrt{2+\sqrt{2}}}{2}\right)
\end{align*}
Adjoin these to $\mathbb{Q}$ to get the splitting field $K$.  It's not hard to see that actually $$K= \mathbb{Q}\left(\frac{\sqrt{2+\sqrt{2}}}{2},\frac{\sqrt{2-\sqrt{2}}}{2},i\right) =: \mathbb{Q}(\alpha,\beta,i).$$ Assuming I've done all this right, we can now find the Galois group $Gal(K/\mathbb{Q})$. This is where I start running into trouble.  In particular, the Galois permutes roots of the respective minimal polynomials of $\alpha,\beta$ and $i$.  But $\alpha$ and $\beta$ are conjugates so $\alpha \mapsto \pm \alpha, \pm \beta$.  Then $i \mapsto \pm i$ so we have $4\cdot 2 = \fbox{8}$ elements of $G$. This number should equal the index $[\mathbb{Q}(\alpha ,\beta,i):\mathbb{Q}]$. But I calculate $$[\mathbb{Q}(\alpha,\beta,i):\mathbb{Q}] = [\mathbb{Q}(\alpha,\beta,i):\mathbb{Q}(\alpha,\beta)][\mathbb{Q}(\alpha,\beta):\mathbb{Q}(\alpha)][\mathbb{Q}(\alpha):\mathbb{Q}] = 2\cdot 2\cdot 4 = \fbox{16}.$$ I'm certain $i$ is of degree two over $\mathbb{Q}(\alpha,\beta)$, and I'm also certain that $\alpha$ is of degree 4 over $\mathbb{Q}$, since the minimal polynomial can be found pretty easily to be of degree 4. What I'm iffy on is the middle part.  My work shows that the minimal polynomial of $\beta$ over $\mathbb{Q}(\alpha)$ is found by $$\frac{\sqrt{2+\sqrt{2}}}{2} = x \Rightarrow x^2 = \frac{2+\sqrt{2}}{2} \Rightarrow 2x^2-(2+\sqrt{2}) = 0$$ so it's of degree 2. Is this where I am making a mistake?  If not, then indeed the index is 16 so the order of $G$ must be 16 as well.  Now if this is the case, what are the other 8 automorphisms I'm not seeing?  Of course, there's also the possibility I messed up much earlier on, and that's what's making all this so difficult.
Comment: $x^{16}-1=(x^8+1)(x^8-1)$.
Comment: Maybe I'm not seeing the relevant part, but at first glance it doesn't seem all that helpful since I'm asking about $x^8+1$ not $x^8-1$. Do some of the results carry over?
Comment: Thank you for showing your work so well. If only all posters were this thorough!
Comment: @rschwieb No problem at all.  Thank you for the quick and helpful answer.
Answer: I think you are going about it the hard way. You know the roots are the odd powers of $\zeta=e^{\pi i/8}$, and you may find that a far more useful form for the roots than what you've done with all those square root of two thingies.
Comment: Ah, so actually $K = \mathbb{Q}(\zeta)$, where of course $\zeta$ is of degree 8 over $\mathbb{Q}$, so $[\mathbb{Q}(\zeta):\mathbb{Q}]=8$, which is what we want. Then the automorphisms are $\zeta \mapsto \zeta^i$ for $i=1,\ldots,8$. This is a much cleaner approach, thank you.
Answer: When you adjoin your $\alpha$, you already get your $\beta$ for free, since:
$\beta=\frac{\beta\alpha}{\alpha}=\frac{\sqrt{2}}{\alpha}$
Also note that $\sqrt{2}$ was already adjoined when $\alpha$ was, since $\sqrt{2}=4\alpha^2 -2$
This is the source of your extra factor of 2 in your degree computation.
Comment: You're absolutely right.  I had a feeling there was some really simple relationship between $\alpha$ and $\beta$ I just wasn't seeing.  Thanks.
Comment: @unit3000-21 I remember running into this same trouble when I was doing it for the first time :)


Updating table takes very long time

Question: I have a table in SQL Server 2008 (SP2) containing 30 million rows, table size 150GB, there are a couple of int columns and two nvarchar(max) columns: one containing text (from 1-30000 characters) and one containing xml (up to 100000 characters).
Table doesn't have any primary keys or indexes (its is a staging table). So I am running a query:
UPDATE [dbo].[stage_table]
SET [column2] = SUBSTRING([column1], 1, CHARINDEX('.', [column1])-1);

the query is running for 3 hours (and it is still not completed), which I think is too long. Is It? I can see that there is constant read rate of 5MB/s and write rate of 10MB/s to .mdf file.
How can I find out why the query is running so long? The "server" is i7, 24GB of ram, SATA disks on RAID 10.
Updated:
table contains one int column, two nvarchar(20) columns and two nvarchar(max) columns. Column1 and Columns2 in the update clause above are nvarchar(20) columns. The "big" columns are not updated.
Many thanks!
Comment: Are the updates columns indexed?
Answer: Honestly, that's a huge amount of work that you're doing (text searching and replacing on 150 gigabytes).  If the staged data originated outside the database you might consider doing the text operations there, without any of the database overhead.
Comment: Thanks for your answer. I have updated the question. The column1 and column2 are nvarchar(20) columns, so the text being searched is not that huge, only the table is huge.
Comment: I suspect it's still true that you'd be better off doing this outside the database.  There's a lot of overhead in processing and updating each one of those rows — not as much as if you were operating on the entire text base, but still a lot.
Answer: You are doing some string manipulation on a field - something that SQL is notoriously bad at. Consider writing a SQL CLR function that does what you need and use that instead of SUBSTRING([column1], 1, CHARINDEX('.', [column1])-1).
Comment: Why would an index speed this UPDATE up?  There's no WHERE clause.  In fact, for this UPDATE an index would slow things down (because of the time needed to update the indexes).
Comment: I don't see how an index can improve the query. It just has to be a full table scan.
Comment: If there is no selection criteria, why does the lack of indexes matter?
Answer: A practical way to test if something is out of the ordinary is to only update some of the data. Write a view that selects say the top 10,000 rows, and run the update against the view.
If 10,000 updates in what you would expect to be "normal" for your server, then it would follow that it is just "a lot of data to update".
If this small updates seems unduely long, then investigate more.
At least this gives you a decent testing ground.
Answer: There are a few options here.  But without more information regarding what you intend to do with the data after this update is performed, Larry Lustig's answer sounds like the most appropriate.  But other options follow:

Create column2 as a calculated column instead of a physical column.
Perform the calculation as you pull the data from the staging table (which is also what would take place if you go with the previous bullet.
Index column2 and then perform the updates in chunks of 10,000 records or so where column2 is null.  This will keep the implicit transaction size down, which is probably what is currently killing your performance.
Answer: I haven't done this kind of processing in SQL Server, so I'm not sure if the advice fully apply. But I'm confident enough to suggest you try it though.
What I usually do in Oracle is to avoid updates entirely when processing ALL rows in a situation like the one you describe (single user, batch event).
Either I migrate the logic from the update statement back to the statement that inserted the rows. Or if this is not possible, I create a new table and put the update logic in the select list. For example, instead of doing
UPDATE [dbo].[stage_table]
SET [column2] = SUBSTRING([column1], 1, CHARINDEX('.', [column1])-1);

I would do:
create table stage_table2 as
   select column1
         ,substring(column1, 1, charindex('.', column1)-1) as column2
         ,column3
         ,column4
     from stage_table;

drop table stage_table;

alter table stage_table2 rename to stage_table;
-- re-create indexes and constraints, optionally gather statistics

I could also do this with parallel query and nologging option to generate very little redo and no undo at all, which would outperform an update statement with such a large marginal it's not even funny :) Of course this is because of Oracle internals, but I think it would be possible to replicate it with SQL Server as well.
There is something in your description that may make this a less efficient approach though. You had some really large text columns that you would have to "drag along" in the CTAS statement.
Also, you need to investigate your hardware setup because it is not fit to work with the amount of data you have thrown at it. Either there is something wrong with the configuration, or you have a lot of other activity going on:

I can see that there is constant read
  rate of 5MB/s and write rate of 10MB/s
  to .mdf file.

I can beat that on my girlfriends 2 year old laptop. Given a read speed of 5 mb/s and a table of 150 GB, it would take 8,5 hours to scan through the table just once. This is assuming that the database adds 0% overhead, which is not the case.

Updating table takes very long time


Mixed models in repeated measurement with one treatment

Question: I have an experiment that includes 8 subjects during one treatment, measuring response variable. The hypothesis is that there is some correlation between AV and lactate during the treatment. Some subjects have a very late response and some earlier, it maybe depends on different physiology.
My idea was just to use the trend changes point from the fixed factor,  In the figure some subjects have the trend change at time point 6, some have trend changes start at time point 10 leading to few data points for some and more for others. So, the data input to the mixed model is only the trend changes in data for every subject.
The fixed factor, because of the treatment, is changing all the time steps during the 2 hours experiment as does the response variable (AV).
So, if I look at the data plot with just linear modelling they have different slopes and intercepts for all subjects. I was thinking to model with random effects for intercept and the slope, see code below.
Answer: I'm a newbie, but I don't see any reason to drop the earlier time points.  Try random slopes and intercepts and a quadratic term.


Rename project name from windowsformapplication2

Question: I am new to C#. I have created an application in C# (connecting to Teradata database)that I named it as windowsformapplication2 (the default that comes). But, now I want to change the name to a meaningful name(CPU_Scoring). I have tried to rename project and solution, but I see the components in 'bin' are the same. When I run my application, it runs as windowsformapplication2 not` CPU_Scoring. Is there was way to do this, or do I have to create my application again ?
Comment: Project > Properties.  Spend an half hour looking what is there, press F1 if you don't understand something.
Comment: You need to change the assembly name. Right click your project, go to properties. Click `Application` on the left, and then change 'Assembly Name' (and probably default namespace too).
Answer: In Visual Studio

In Solution Explorer, right click on Main solution > Rename
In Solution Explorer, right click on project (under solution) >
Rename
In Solution Explorer, double click, or right click on Properties >
Application Tab, rename Assembly name and Default namespace to match.
Also rename the namespace, Open one of your class files. Right click
the namespace > Rename... this should search and replace all
references to your namespace throughout the project.
Close the project > rename the project folder.
Edit .sln file in notepad, change the path to the cjproj. ie
windowsformapplication2\bar.csproj --> CPU_Scoring\bar.csproj

You might also like to have a look on Proper way to rename solution (and directories) in Visual Studio


Trigger Approval Process

Question: I created an Approval Process but I'm not aware how to trigger such approval process. What I would like to know is how to trigger the Approval Process when Opportunity stage = 'Proposal Submitted for Approval'. The stage field is a standard picklist field and when 'Proposal Submitted for Approval' in the stage picklist is selected then the Approval Process must be triggered automatically. As far as I'm concerned the Approval Process can be triggered automatically with the help of the Process Builder therefore I created a Process Builder but I'm not sure how to configure it to use my Approval Process and to be initialized when stage 'Proposal Submitted for Approval' is selected.
Please advise how to trigger the Approval Process automatically when Opportunity stage is 'Proposal Submitted for Approval'?
Answer:
Add the entry criteria for the records to be entered in the process builder.
Check for the stage field matches 'Proposal Submitted for Approval'.
Use Submit for approval (initiates an approval process) action.

For reference see the Document
Answer: You can create a flow to check if the field is set to 'Proposal Submitted for Approval'. Once the flow is created, you can create a quick action Submit for approval and place it on the page layout. Configure this quick action such that it invokes the flow. By having an entry criteria on your approval process, the concerned approval process would be invoked.

Trigger Approval Process


reject queries based on specific client_app_name and nt_username

Question: With a surge of applications that can be used to pull information, my sql server is constantly getting tapped, and there are a couple of users that keeps running refresh. Is there a way to reject query based on specific client_app_name and nt_username? Alternatively, is there a way to add the combination of the user and the app to security to decline access to SQL? i.e. Approve the user access if client_appname is excel but decline if the appname is 'Mashup Engine'.
Answer: Yes, you can use a Logon Trigger and call ROLLBACK if you want to deny the logon.
Alternatively if you are on Enterprise Edition you could use these in a resource governor classifier function to route them to a workload group in a resource pool with limited resources.
Note the app_name() is potentially easily settable from the client if they are making adhoc connections, e.g. via SSMS, or can edit the connection string used by your app.


Flipped Images for SharePoint 2013

Question: Some of the images that we upload to SharePoint 2013 look fine on the Windows 10 Photo viewer, but display upside down once uploaded to the website. Windows 7 photo editor never caused any issues. Is there a setting that I need to change in SharePoint to display images the way they show on the computer via photo viewer?
Answer: This is a known issue and here is a work around to overcome this issue :

First I uploaded a picture from my computer to the SharePoint site.
It uploaded fine.
Then I uploaded an image sent by client to the SharePoint and
noticed it was upside down (see image above), even though it was
right side up when I opened the same saved image from my computer.
I uploaded the second and third picture and they behaved the same
way. They were right side up when opened from the computer but as
soon as they were uploaded to SharePoint they turned upside down.
I then saved the first upside down picture in SharePoint to my
desktop. I figured I will work with one image at a time and see what
happens.
I deleted the first image from SharePoint after I saved it to my
desktop.
I opened the newly saved picture on my desktop and opened it in
Windows Picture Viewer. It was upside down just the way it looked in
SharePoint. Keep in mind that the picture originally was fine and
was right side up when the client sent it to us. It only got flipped
upside down when it was uploaded to SharePoint.
I flipped the picture upside down so it looked the way it was
supposed to look (i.e. right side up). By the way, opening it in
Microsoft Paint and flipping it upside down also yielded the same
results.
I then uploaded this picture to the SharePoint site again and it
fortunately was right side up. Whew!
I repeated these steps for the other two pictures and it worked.
They were finally uploaded to the SharePoint and displayed right
side up as shown below.

SharePoint image turn upside down
Source of above workaround steps :
Images Turn Upside Down When Uploaded To SharePoint 2013

Flipped Images for SharePoint 2013


JavaScript Array forEach function not working?

Question: I tried to do some changes in the W33 school's javascript code to learn about the difference
between forEach and map, is there anyone can please tell me why the output of this code is still:
45,4,9,16,25
instead of
90,8,18,32,50
Isn't it forEach means call a function to every element in this array? I know I should not use return because the forEach does not return valid result.

const numbers = [45, 4, 9, 16, 25];

numbers.forEach(myFunction);
document.getElementById("demo").innerHTML = numbers;

function myFunction(value, index, array) {
  value * 2;
}
<!DOCTYPE html>

JavaScript Array.forEach()

Calls a function once for each array element.

Comment: `forEach()` doesn't modify the array, it just calls the function with each array element as the argument. Also, the function doesn't return anything. It calculates `value * 2` but doesn't do anything with it.
Comment: But if you really want to modify the array, you can use this, `numbers.forEach((number, index) => (numbers[index] = number * 2));`
Comment: `forEach` _can_ modify the array but you need to assign the new value back to the element at the index. `numbers[index] = value * 2;`
Comment: for each only executes the function for every element in the array, it doesn't create a  new array
Comment: use map instead  const newNumbers = numbers.map(myFunction) and return value *2
Comment: or push elements in a new array from the myFunction
Answer: The line value * 2 performs a calculation, but it doesn't do anything with the result of that calculation. You could change the line to value = value * 2 and that would assign the result of the calculation to the value variable. However, that still wouldn't change the values in the array, because the value variable is restricted to the scope of the function.
This is because when you transfer a number to another variable, you are only transferring the value, not the reference. i.e.
let a = 1;
let b = a;
a = 2; // a is 2, b is 1

This is different to arrays and objects, where the reference is transferred:
let a = [1];
let b = a;
a[0] = 2; // a[0] is 2, b[0] is 2

So a way to fix your code might be to manipulate the array instead, i.e.
const numbers = [45, 4, 9, 16, 25];
numbers.forEach(myFunction);

function myFunction(value, index, array) {
  array[index] = value * 2;
}

// numbers is [90,8,18,32,50]

This works. However, I would recommend the simplicity of map instead of forEach. Array#map uses the return value of each function call to replace each item in the array.
const numbers = [45, 4, 9, 16, 25];
const doubles = numbers.map(myFunction);

function myFunction(value, index, array) {
  return value * 2;
}

// numbers is [45,4,9,16,25]
// doubles is [90,8,18,32,50]

Answer: The function myFunction basically does nothing, it doubles the current value and does nothing with it. In your case, you need to mutate the array. But it's not a good idea to mutate the array which you're traversing.
To achieve your goal, I recommend creating a new array using the map function.
const numbers = [45, 4, 9, 16, 25];

const doubledNumbers = numbers.map(val => val * 2); // [90, 8, 18, 32, 50]
document.getElementById("demo").innerHTML = doubledNumbers;

Answer: This is because you are not re-setting the value of numbers with the multiplied value.
You need to set it according to numbers[index] inside the map function.
const numbers = [45, 4, 9, 16, 25];

numbers.forEach(myFunction);
document.getElementById("demo").innerHTML = numbers;

function myFunction(value, index, array) {
  numbers[index] = value * 2;
}


how to set i2c bus to soc audio codec

Question: I'm working on an audio codec driver for cs4245 device. It's controlled by i2c. I have 2 hardwares (devel-board), one of the them has the codec attached to i2c-1 and another to i2c-2. The first one is working, but the second not.
I've tested the communication (using i2cdetect, i2cget) with codec in the second board and it's working. Its communicates and receive the chip ID.
Looking into the code I can find the definition of i2c bus that should be used to set the bus communication:
static struct snd_soc_dai_link mod_duo_dai =
{
    .name = "MOD-DUO-I2S",
    .stream_name = "MOD-DUO-SUNXI-I2S",
    .cpu_dai_name = "sunxi-i2s.0",
    .codec_dai_name = "cs4245-dai",
    .platform_name = "sunxi-i2s-pcm-audio.0",
    .codec_name = "cs4245-codec.1-004c", // EDITED
    .ops = &mod_duo_ops,
    .init = &mod_duo_dai_link_init,
};

So, I edited highlighted line to "cs4245-codec.2-004c" but the driver still looking for i2c-1. The kernel prints bellow shows that:
bus: 'i2c': really_probe: probing driver cs4245-codec with device 1-004c
[i2c_device_probe] client name: cs4245, adapter name: sunxi-i2c.1, adapter nr: 1

Also I inserted a print inside function snd_soc_instantiate_card in soc-core.c to be sure it's getting my changes:
snd_soc_instantiate_card: cs4245-codec.2-004c

Later, kernel reaches codec probe function, it shows:
[   11.907394] [CS4245]Failed to read i2c at addr 0x4C.
[   11.919643] cs4245-codec: probe of 1-004c failed with error -70

Should edited line be enough to change the i2c bus?
The code is available at: https://github.com/moddevices/linux-sunxi/blob/mod-duo/sound/soc/sunxi/mod-duo.c
I've tried also change the bellow line as described in the comment:
static const struct i2c_device_id cs4245_id[] = {
    {"cs4245", 1}, // changed to {"cs4245", 2}
    {}
};

Does not work too. This piece of code is present in the codec driver: https://github.com/moddevices/linux-sunxi/blob/mod-duo/sound/soc/codecs/cs4245.c
Answer: The i2c bus option is being set at arch/arm/plat-sunxi/devices.c file, following commit fixing it.

how to set i2c bus to soc audio codec


adjustable window and adjustable reset delay watchdog Timer

Question: I am using watchdog timer which have adjustable window BUT ITS RESET delay is fixed.This reset pin  is active high during normal operation and during fault condition its gives 200ms low pulse. So how can I drive  power supply using this reset pulse?
Comment: What is current limit an RC=T value
Comment: I am new to electronics I just want to reset power supply using this reset pulse given by external hardware Watchdog timer but I dont know how to increase its pulse width ?Is there any solution to increase its pulse width? I have to stretch this asserted reset pulse to 10 second from 200ms? I heard about Monostable multivibrator  or any better approach for this ?
Comment: You can trigger a one shot multivibrator to stretch the 200ms pulse.
Comment: 10s seems like a fault condition from overtemp
Answer: As you already presumed, you can use a monostable multivibrator to extend your pulse, for example using a 555 timer. If you enter "555 timer monostable" this is the first image that pops up:

(Image source)
Just connect your watchdog timer output instead of R2 and the switch and connect a transistor (with base resistor) to drive the relay on the OUT pin.
Select R1 and C1 so t is 10 seconds according to the formula in the picture.
Comment: Thank you for adding the image source, I see it has a lot of valuable information about 555 timer circuits.