RC Filter Parallel Potentiometer

Question: I am trying to teach myself electronics, namely audio filtering, and I came across this circuit. Now with my limited knowledge the 'volume potentiometer' (that's what it is explained as) seems to be in parallel with the resistor forming the high-pass RC filter so would this mean that this circuit is wrong. I think that the output of each filter needs to be buffered and that those outputs should have the poteniometers on them? All the pots in the circuit are 10K Log's
Answer: It's not the best example of a three way splitter (I doubt you'll see something like this inpractice, it's just an example), but 680 is less than 10k, which means the cutoff will be little influenced. The same for the others where the cap is in parallel with the pot -- at cutoff, the impedance is less than the pot (~1.6k). That's not to say they will not be influenced, here's how the three outputs look like when there's no potentiometer (R=1G Ohm), compared to 10k:

Given @user7286370's comment: No, they combine, but as you can see in the picture, the effect of one large resistor in parallel with a small one will result in a new resistor that's slightly less than the smallest of the two. Consider the formula: \$\frac{R_1 R_2}{R_1+R_2}\$. If \$R_1\$ is much greater than \$R_2\$, what happens? Here's what happens when you put a \$10\Omega\$ resistor in parallel with another varying from 1 to 100:

If the resistor is less than 10 (see the graph), the combined resistance drops significantly. If they are equal, 10 each, the resultant is 5, and as the resistor goes to 100 you can see the resultant value going up, towards 10, asymptotically. That means that, the higher the parallel resistor, the less impact it has.

Here's the equivalent schematic for the highpass case:

As you can see, the pot effectively becomes two series resistors, with their values set by the wiper position (here, from 0 to 1). At the output you have the input impedance to the next stage (considered larger). From R1's perspective, it "sees" the two series resistances, thus the whole potentiometer, which, as determined above, does not influence too much R1's value. And, at the output, you have R2 with R3 forming a variable voltage divider.
Not sure what you meant to say with this: "does not act as a 'volume' control for a fixed value filter", but buffering is the recommended way to do it because, as you can see in the 1st picture, despite the large value of the pot, it still influences the filter, even if only by a bit.
Comment: Thank you but maybe I am a little stupid, are you saying that two resistors in parallel do not form a single resistor electrically but act as two seperate entities due to the differing values?
Comment: To be more precise, the encircled area in your picture shows a 680 and a 10k resistor, the resultant is `(10k*680)/(10k+680)=636.7`, which is less than 680, but not by much. Something of a rule of thumb says that if the parallel resistor is 10x greater or more, it is considered larger, if it's 100x or more, it's much larger. Note: don't take "rules of thumb" as laws, never; they are for guidance, only.
Comment: Thanks, so my assumption of the circuit being wrong is correct in that the pot becomes part of a network with existing resistors and does not act as a 'volume' control for a fixed value filter. Would I also be correct in assuming that each filter needs to be buffered with an opamp before passing to pots for mixing so that the amplitudes of high and low filters could be controlled independently? Of course however I understand that I could just leave them where they are to effectively adjust the cutoffs, but amplitude adjustment of fixed filters is the goal
Answer: I think this question has been well answered already, however I want to add a few things.
First the actual question: why are there potentiometers placed in parallel with other components (specifically resistors where it will change the resistance as they combine)?
The circuit will be designed with the pots to form the correct cutoff frequencies when they combine with the fixed resistors. The cutoff frequencies won't move depending on the position of the wiper as the resistance with respect to ground is constant. EDIT: as noted in comments this is only true individually! The interactions are negative. See my last paragraph re: interactions.
Effectively the circuit just gives a low-pass filter, band-pass filter, and high-pass filter and allows you to blend them together.
With regards to buffering: sufficient buffering would be provided by simply adding a summing amplifier at the output node of the given circuit. This would prevent loading of the filters.
Further if you're interested in this kind of circuit, there are lots of interesting tone stacks from both old and modern guitar amplifiers, check out this website. They were designed with minimal cost and with older technology. Putting an op-amp buffer everywhere wasn't really possible, particularly before transistors were even being used! The sound of the circuit was designed such that the interaction between sub-circuits would yield sonically pleasing results.
Comment: "The cutoff frequencies won't move depending on the position of the wiper as the resistance with respect to ground is constant." - They _will_ move because all the pot wipers are connected together, so each pot affects the resistance to ground of the adjacent filters. If one pot is set to minimum it will short the other wipers to ground and there will be no output at any frequency. Bad circuit!
Comment: Ah good point! I suppose I should have clarified they won't change the cutoff individually.

RC Filter Parallel Potentiometer


Programmaticaly read and write on PQI Air drive

Question: I have a PQI Air drive  and I need to programmaticaly read / write data on this device with android.
The manufacturer offer a proprietary application S+Flash which read / write but it can't be used to allow a programmaticaly access.
I can download file via HTTP access, so I tryied to use WEBDAV but it doesn't seem to worm (error 451 or 501), and FTP (connection with anonymous failed with 500 OOPS: cannot change directory:/home) and also SMB.
Any idea ?
Is it possible to capture the communication made by this application on Android ?
I ran tests with nmap, I got this result :
Starting Nmap 5.61TEST4 ( http://nmap.org ) at 2012-07-23 19:32 Paris, Madrid (heure d’été)

NSE: Loaded 87 scripts for scanning.

NSE: Script Pre-scanning.

Initiating ARP Ping Scan at 19:32

Scanning 192.168.2.1 [1 port]

Completed ARP Ping Scan at 19:32, 0.20s elapsed (1 total hosts)

Initiating Parallel DNS resolution of 1 host. at 19:32

Completed Parallel DNS resolution of 1 host. at 19:32, 16.57s elapsed

Initiating SYN Stealth Scan at 19:32

Scanning 192.168.2.1 [1000 ports]

Discovered open port 80/tcp on 192.168.2.1

Discovered open port 8080/tcp on 192.168.2.1

Discovered open port 445/tcp on 192.168.2.1

Discovered open port 139/tcp on 192.168.2.1

Discovered open port 21/tcp on 192.168.2.1

Discovered open port 23/tcp on 192.168.2.1

Completed SYN Stealth Scan at 19:32, 0.48s elapsed (1000 total ports)

Initiating Service scan at 19:32

Scanning 6 services on 192.168.2.1

Completed Service scan at 19:33, 81.51s elapsed (6 services on 1 host)

Initiating OS detection (try #1) against 192.168.2.1

NSE: Script scanning 192.168.2.1.

Initiating NSE at 19:33

Completed NSE at 19:34, 22.12s elapsed

Nmap scan report for 192.168.2.1

Host is up (0.016s latency).

Not shown: 994 closed ports

PORT     STATE SERVICE     VERSION

21/tcp   open  ftp         vsftpd 2.0.7

23/tcp   open  telnet      BusyBox telnetd

80/tcp   open  http?

|_http-methods: No Allow or Public header in OPTIONS response (status code 501)

|_http-title: Index of /

139/tcp  open  netbios-ssn Samba smbd 3.X (workgroup: WORKGROUP)

445/tcp  open  netbios-ssn Samba smbd 3.X (workgroup: WORKGROUP)

8080/tcp open  http-proxy?

|_http-methods: No Allow or Public header in OPTIONS response (status code 501)

MAC Address: 00:03:7F:FF:FF:FE (Atheros Communications)

Device type: general purpose

Running: Linux 2.6.X

OS CPE: cpe:/o:linux:kernel:2.6

OS details: Linux 2.6.17 - 2.6.36

Uptime guess: 0.021 days (since Mon Jul 23 19:03:20 2012)

Network Distance: 1 hop

TCP Sequence Prediction: Difficulty=203 (Good luck!)

IP ID Sequence Generation: All zeros

Service Info: OS: Unix

Host script results:

| nbstat:

|   NetBIOS name: WIRELESS_FLASH_, NetBIOS user: <unknown>, NetBIOS MAC: <unknown>

|   Names

|     \x01\x02__MSBROWSE__\x02<01>  Flags: <group><active>

|     WIRELESS_FLASH_<00>  Flags: <unique><active>

|     WIRELESS_FLASH_<03>  Flags: <unique><active>

|     WIRELESS_FLASH_<20>  Flags: <unique><active>

|     WORKGROUP<1d>        Flags: <unique><active>

|     WORKGROUP<1e>        Flags: <group><active>

|_    WORKGROUP<00>        Flags: <group><active>

|_smbv2-enabled: Server doesn't support SMBv2 protocol

| smb-security-mode:

|   Account that was used for smb scripts: guest

|   User-level authentication

|   SMB Security: Challenge/response passwords supported

|_  Message signing disabled (dangerous, but default)

| smb-os-discovery:

|   OS: Unix (Samba 3.3.4)

|   NetBIOS computer name:

|   Workgroup:

|_  System time: 1970-01-01 01:35:44 UTC+0

Comment: I'm interested in whether you got an answer for this. I am trying to use Air Drive as media server for both my rooted Kindle Fire and iPad. The S+ Flash program will only display .mov or .mp4 files; I'd like to be able to stream .avi. Any thoughts?
Comment: Smb will work. (I don't know why I didn't see it the first time). you have to download application according your device. OMHO vlc can read streamed video on smb.
Answer: Try download files by browser from port 8080 to player. iPad - oplayer (internal browser), Android - any: MX, etc.
ftp 192.168.100.1   user: root, pass: pqiab


Sanitising Black chef "whites"

Question: I have just been given new black "whites" at work. We are soley responsable for the laundry of these items, and I was surprised to see that my new "whites" are to be washed at 40 degrees. Can anyone recommened a sanitiser that wont "bleach" the colour but will make my uniform safe?
Comment: Soap itself is anti-microbial (even without getting to the 'anti-bacterial' soap obsession), but ["Getting Clothes Clean"](http://aces.nmsu.edu/pubs/_c/c-503.html) has a section on "Removing Germs from Clothes" that mentions "Boiling clothes or hanging them in the sunshine were once common ways to get rid of germs. With modern fabrics, fabric finishes, and washing methods, other ways can be used to disinfect the family laundry. ... Quaternary, pine oil, or phenolic disinfectants can be safely used on any washable fabrics."  ... but I have no idea how they'd affect color.
Answer: You may consider using a small amount of Borax, Pinesol or some other form of pine oil, or even the kitchen-friendly, environmentally friendly vinegar.
Answer: I don't know about yours, but my dryer hits well over 150 degree for an extended period of time during the drying cycle.  I would think that would handle the business right there.  Throwing some quat in the rinse cycle would guarantee that no germs could survive but you would have to make sure you use enough to reach the requisite concentration.
Comment: @Marti: [Quat is a disinfectant cleaner made by 3M](http://www.3m.com/product/information/quat-disinfectant-cleaner.html).  It's short for "quaternary".
Comment: quat? Translate, pls?
Answer: Napisan is awesome. I genrally use it on cloths/tea towels/table linen and it gets stains out/sanitizes them so I'm sure it would work on whites. I have to say I've not used it on black fabric but it says suitable for colors on the box.

Sanitising Black chef "whites"


Particle in infinite square well with $\langle E \rangle = (1/4) E_1 + (3/4) E_4$

Question: Suppose we have a particle in an infinite square well with $\langle E \rangle =  (1/4) E_1 + (3/4) E_4$. I know that I can calculate the uncertainty in the particle's position by $\sqrt{\langle E^2 \rangle-\langle E \rangle^2}$. I can calculate $\langle E \rangle^2$ easily as I know $\langle E \rangle$. But how would I go about calculating $\langle E^2 \rangle$?
Comment: If the energy is $E_1$ with probability $\tfrac{1}{4}$ and $E_4$ with probability $\tfrac{3}{4}$, then $\left\langle E^2\right\rangle=\tfrac{1}{4}E_1^2+\tfrac{3}{4}E_4^2$.
Comment: $$\langle \mathcal O \rangle = \int \mathrm d x \psi^*\mathcal O \psi$$
or similar equations for different bases should work.
Answer: You should note that $\left< E^2 \right>$ is actually $\left<\phi| E^2|\phi \right>$, so to calculate it we have to calculate $|\phi\rangle$ first.
from $\langle E \rangle =  (1/4) E_1 + (3/4) E_4$ we can speculate that
$$|\phi\rangle=(1/2)|\phi_1\rangle+(\sqrt{3}/2)|\phi_4\rangle$$
and the calculation becomes:
$$\left<\phi| E^2|\phi \right>= \langle \phi| E^2| \biggl((1/2)|\phi_1\rangle+(\sqrt{3}/2)|\phi_4\rangle \biggr)$$
$$=(1/4)\langle \phi_1 | E^2|\phi_1\rangle+(3/4)\langle \phi_4 | E^2|\phi_4\rangle=(1/4)E_1^2+(3/4)E_4^2$$
note that terms like $\langle \phi_1 | E^2|\phi_2\rangle$ fall because of the orthogonality relation.


Intuitive explanation of Dvoretzky's theorem

Question: I am wondering if anyone has an enlightening explanation of why Dvoretzky's theorem (which says that a high-dimensional convex body has an almost round central section) is true -- there are a number of proofs but all of them seem a bit technical...
Comment: Do you accept concentration of measure (and specifically, Levy's theorem that Lipschitz functions on a high-dimensional sphere are almost constant outside of a set of very small measure) as intuitive?  From that theorem it is not hard to show that if a convex body is somewhat round, then most of its low-dim slices will be very round, which is already a large part of Milman's proof of Dvoretzky's thm.
Comment: Personally, my take is that measure concentration is initially decidedly unintuitive, because it's an intrinsically high-dimensional phenomenon, and our intuition is trained by two- and three-dimensional experience.  You could say the same thing about Dvoretzky's theorem itself.  Working in high dimensions requires (in part) retraining your intuition to encompass measure concentration.  Once you've done that, Terry's one-line summary gives you most of Milman's proof: the norm corresponding to your convex body is almost constant on most of the sphere.
Comment: @Bill: Indeed, I once showed two proofs (Milman's and Gordon's) of Dvoretzky's theorem to an audience of probabilists.  The point of the talk was the probabilistic tools, so I stated D-R without proof and said something like "There has to be some geometry in the proof somewhere. This is where it's hidden, but of course there'd be no result without it."
Comment: It is at least suggestive that every ellipsoid in $\mathbb{R}^3$ has a planar section that is a circle.
Comment: Arelated question in $\mathbb{R}^3$ ($3$ is not usually viewed as close to infinity, but...) is: given two concentric ellipsoids $E_1, E_2,$ and letting $\chi(E)$ be the excentricity of the ellipse $E,$ what is $\min_P \max_{i=1, 2} \chi(P\cap E_i),$ where the min is taken over all planes through the origin [think of $E_1, E_2$ as the John ellipsoids of some $K$]
Comment: @TerryTao I certainly do not deny concentration of measure, the question is whether it is intuitive (or can be made intuitive). What's your take on this?
Comment: Incidentally, I recommend Keith Ball's article, already mentioned below by Carlo Beenakker, for a presentation of Milman's proof that highlights the big ideas without getting as bogged down in the technicalities as many writers.
Comment: Well, if you accept concentration of measure, then of course Dvoretzky's theorem is clear. A way of getting an embedding of a finite dimensional normed space $E$ into another space $F$ is to define a random linear operator $T_\omega$ from $E$ into $F$ that is, on the average, an isometry or good isomorphism.  If you have enough concentration around the mean, then for some $\omega$ the operator $T_\omega$ will be a good isomorphism.
Comment: When $F$ has dimension $n$, the classical way of getting Euclidean sections is to let $E$ be the $n$ dimensional Hilbert space and let $S$ be the operator that makes $SB_E$ the ellipsoid of maximal volume contained in $B_F$.  Randomize $S$ by considering $SU$ as $U$ varies over the orthogonal group or unitary group, depending on the scalar field.  Then $\Bbb{E}\|SUx\|$ is independent of $x$ in the unit sphere of $E$ and has good concentration around the mean, but you need to get a lower on $\Bbb{E}\|SUx\|$--that uses the D-R lemma.....
Comment: ....or, if you know something $F$ (such as cotype), you can use the properties of $F$ to get a better lower estimate. The concentration around the mean is good enough that a union bound argument allows you to conclude that there is a $U$ s.t. $\|TUx\|$ is close to the mean for all $x$ in an $\epsilon$-net of the unit sphere of $E_k$, where $E_k$ is the span of the first $k$ ON basis vectors for $E$ and $k $ is at least $C_\epsilon \log n$ (or better when you have a better estimate on the mean of $\|TUx\|$ from cotype)....
Comment: ...But this is just an outline of one standard proof of Dvoretzky's theorem rather than an intuitive explanation.
Comment: @Bill: Isn't that what Terry and I said?  (Well, okay, we left out Dvoretzky-Rogers.)
Comment: Sure, Mark; I explained the conceptual framework (which is used e.g. also to get embeddings of subspaces of $L_p$ into $\ell_p^n$) and how the approach is used to get Dvoretzkys theorem.  Concentration is "obvious" if you are a geometer with the classical approach and to probabilists if you use the random gaussian approach, but you still need the D-R lemma to estimate the mean.
Answer: There is a more difficult proof than the quantitative finite dimensional proofs that gives only the qualitative version of Dvoretzky's theorem but is arguably more intuitive.  You use Ramsey's theorem to prove that if $X$ is an infinite dimensional Banach space, then there is a Banach space $Y$ that has a monotonely unconditional basis $(e_n)$ s.t. $(e_n)$ is isometrically equivalent to every subsequence of itself and such that $Y$ is finitely representable in $X$ (meaning that for every $\epsilon > 0$, every finite dimensional subspace of $Y$ is $1+\epsilon$-isomorphic to a subspace of $X$).  This is at the beginning of the Brunel-Sucheston spreading model theory and is elementary.  So $Y$ looks a bit like the spaces $\ell_p$, $1\le p < \infty$, and $c_0$.  Now $c_0$ is universal for finite dimensional spaces (up to $1+\epsilon$), and $L_p$ for all $p$ contains $\ell_2$ isometrically (span of IID $N(0,1)$ random variables when $p<\infty$), and $L_p$ is finitely representable in $\ell_p$, so this is a pretty good hint that Dvoretzky's theorem is true.  To finish the proof, just apply Krivine's theorem, which says that for some $1\le p \le \infty$, the space $\ell_p$ is finitely represented in $Y$ (in fact, for each $n$ there are disjointly supported elements in $Y$ that are $1+\epsilon$-equivalent to the unit vector basis of $\ell_p^n$).  Krivine's theorem is proved in the Springer Lecture Notes volume written by V. Milman and S. Schechtman.
If you are willing to settle for subspaces of $Y$ that are just uniformly isomorphic to $\ell_2^n$, you can replace Krivine's theorem with more elementary arguments.  Tzfriri did that in
Tzafriri, L. On Banach spaces with unconditional bases. Israel J. Math. 17 (1974), 84–93.
Comment: I will need to digest this... I guess one question is: why did Grothendieck suspect Dvoretzky's theorem was true?
Comment: Grothendieck knew the Dvoretzky-Rogers theorem, which I guess is some evidence. He had another proof of an important application of the D-R theorem that motivated the discovery of the theorem (namely, that in every infinite dimensional Banach space there is an unconditionally converging series that is not absolutely convergent). Actually, these days the D-R theorem is considered the most difficult step in the proof of  Dvoretzky's theorem.
Answer: To develop some intuition, the following argument might help, suggested (and dismissed) by K. Villaverde, O. Kosheleva, and M. Ceberio, Why Ellipsoid Constraints, Ellipsoid Clusters, and Riemannian Space-Time: Dvoretzky's Theorem Revisited.
A stronger version of Dvoretzky's theorem (due to Milman) asserts that almost all low-dimensional sections of a convex set have an almost ellipsoidal shape. An $n$-dimensional section consists of points $(x_1,x_2,\ldots x_n)$ such that $g(x_1,x_2,\ldots x_n)\leq 0$. Generically, this function $g$ will be smooth and a Taylor expansion to second order would be a good approximation,
$$\sum_{i,j=1}^n a_{ij}x_i x_j+\sum_{i=1}^n b_i x_i \leq a_0,$$
producing an ellipsoid.
Comment: @Mark and Igor : the half dimension of spherical section is the clue ! Let the ellipsoid be $\sum_1^{2k} a_i x_i^2=1$ and $(a_i)_{i=1..2k}$ be increasing. Take $c$ in $[a_k,a_{k+1}]$. Then the subspace $x_{k+1-i}=t_ix_i$, $i=1..k$ will do the job if $a_i+t_i^2 a_{k+1-i}=(1+t_i^2) c$, which is possible by choice of $c$ (maybe with infinite $t_i$). An obvious adaptation works in the odd $2k+1$ dimensional case, giving a $k+1$-dim spherical section.
Comment: @IgorRivin : perhaps you should ask why high dimensional ellipsoids have large almost spherical sections, intuitively ?
Comment: Milman's proof shows that after applying a linear transformation, most low-dimensional sections have an almost spherical shape.  Applying the inverse transformation, you get almost ellipsoidal sections, but the "most" part gets lost.  But, since ellipsoids have (about half-dimensional) *precisely* spherical sections, you still get almost spherical sections of the original body.  I'm sure I've seen a short proof of the existence of spherical sections of ellipsoids in some lecture notes by Schechtman, but I can't find it now.
Comment: I am a little confused -- low-dimensional sections have an almost SPHERICAL shape (and Milman, as you say, makes this into a "most sections" statement). Also, in the paper you mention they seem to use Dvoretzky's theorem (rather than give any sort of argument for it). Am I confused?
Comment: @IgorRivin --- my very limited understanding of Dvoretzky/Milman is based on Keith Ball's "Elementary Introduction to Modern Convex Geometry", where it is shown that "any symmetric convex body in $R^n$ has almost ellipsoidal sections of dimension about $\log n$." I would be surprised if almost all sections would be spherical, ellipsoidal seems the generic thing to expect.
Comment: That's why Dvoretzky's theorem is so cool! The wikipedia has a correct statement: http://en.wikipedia.org/wiki/Dvoretzky's_theorem
Comment: @Igor: the usual formulation is in terms of the Banach-Mazur distance which doesn't see a difference between ellipsoids and balls.
Comment: @BS yes, I agree, that may be more tractable, intuitively...


Flat File in a Unit Test

Question: Is it considered bad practice to use a flat file when doing unit tests? If an application reads in flat files and parses them, would this be a better approach than hard coding strings into the unit tests themselves?
Answer: It's only bad practice for sure if the text files aren't checked into version control.
There isn't anything hugely wrong with reading text files, provided the text files are in source control along side the class reading it.
However, I personally would rather hard code all the values into a bunch of lists because they are being used for unit tests. There is nothing wrong with that. Where I work I work on software that analyzes data from real world sensors. I have written python scripts that will take the flat text files and convert those into C# static class files ready for being plugged into the unit tests.
Comment: At some point I give up and start using real files. But not until I really have to, it's normally possible to do 99% of it using hard-coded data. I think I have two file-based tests. Both are regression tests and I'm testing something like "after 65k iterations something bad happens" or "files larger than 2GB do not work" (what, someone reintroduced the small file size bug? Say it isn't so).
Comment: +1 for the headline. A flat file is nothing but test data, absolutely acceptable if it is version controlled along with the tests. We just have to make sure that a test is repeatable.
Answer: Does the flat file contain information that can be rendered in a human-readable form? If so, store the information in the most-human-readable format.
e.g. Script file, Text-based data representation, etc. Those can be placed together with the unit test code and checked into version control.
e.g. Image files, Audio files. The natural way to render an image file is to leave it as an image file, so that it can be opened by any image viewer. Don't try to store test image files in a format that makes them non-renderable (e.g. save it as Base64 in an XML file; unless you're testing a library that performs that conversion and you have an image viewer that can render the image for you)
e.g. synthetic binary data. In this case, it is better to write a test helper function that generates the synthetic binary data on the fly. The test helper function is the "human-readable form" that explains how the data is generated; nobody can understand that by looking at the data alone.
Answer: I personnally think it depends on what you are testing.  I tend to try and break down my unit tests as small as possible and to only test one piece of functionality.
It seems to me you are trying to test two things here:
1. Reading in a file
2. Parsing that file
I might break down the unit tests to accomodate both those cases and in the case of 2. then I would consider hard coding strings a valid situation.
Comment: I think it's OK to test 2 things if you've tested the first (reading a file) thing before hand.
Answer: It doesn't matter much. If the test language supports multi-line string literals then it may be a bit easier and faster to include the data in the test code.  If the test language has poor support for multi-line string literals (e.g. Java) then it will be easier to use a flat file.
Answer: There is nothing wrong with hard-coding values (whether they're strings, numbers, objects, etc.). The unit test is a strict test that determines the behaviour of a single type of input. Having all the information in the unit test itself provides an unchangeable value and is clearer to see what is being tested.
Comment: I tend to agree.  While I wouldn't see a flat file being used in a unit test as terrible, it's a ways from "good" too. At the least, it's another external dependency to manage.
Comment: Interesting. So perhaps it'll be better to have my values into a separate class in the unit test project or something similar?
Answer: The advantage of flat files is that you can put many data there to feed the tests. The Django unit test framework works with fixtures, files with data for that purpose (in this case it use json or xml).
Another advantage is that your test code is written for taking the data from that file and is ready for testing synthetic data generated by hand (by now) or by machine, so you could then drop that file, save the script that generate the fixture and you don't have to change your test.

Flat File in a Unit Test


How to remove rust from the cooling system

Question: Hi  I have a 2000 Honda Civic.  There seems to be a lot of rust in the coolant. I just got it back from the mechanic who repaired a failed water pump.  Any suggestions on what to do to fix this?  Thanks.
Answer: There are two methods I've heard of for removing rust from a cooling system.  Both involve using a weak acid.
The first involves running a 50 / 50 solution of distilled water and vinegar in the engine for a day or two.  There is a very good explanation of what he did here.  I used this on my 98 Mazda 626 with moderate success.
The one you specifically asked about is the citrus flush, which is attributed to Mercedes Benz.  You can even buy official Citrus Flush kits for various Mercedes Benz vehicles.  There is a nice tutorial on this with lots of pictures here.
According to this site you can just use a 10% solution of distilled water and citric acid, something like 2.2 pounds of citric acid in five liters of water.  You basically need to drain and flush all coolant from the system, then refill with the CA solution, run the engine for 15 minutes at 2500 rpm, drain and flush to remove all solution, then refill with coolant and check for leaks.
I must point out that there is some anecdotal evidence that there is a certain risk to this procedure:

Search under my name...Ive done the citrus flush twice and both times other components have been taken out, like the radiator, water pump etc. Im not saying dont do it, just be ready - anything that is on the edge of failure will be pushed over. Have your credit card warmed up and parts supplier ready forewarned :-)
In my opinion, if your cooling system is functioning properly, I would not do the citrus flush.

So do this at your own risk.
Comment: I use a diluted muratic acid mix with water, then flush with water, then flush with baking soda and water mix, then flush again with water.


Transfer videos over Wifi to NAS

Question: Today on my Android phone, I take videos of my kids, 5-10GB weekly, and then move them with xPlore application to the NAS (synology) over the 5G Wifi internal network.
I have a new iPhone XR iOS 14.6 and I would like to do the same, move from the iPhone the movies that I make to the NAS without going over the Internet.
The way I'm doing it right now:

I go to the Photos app
I select the video in question, I click on the Share button, I choose to copy on my iPhone
I go to the Files app and from there transfer the video to the NAS
Go back to the Photos app and delete the video
Go back to the Files app and delete the video

How can I minimize/simplify the number of steps done above (these are 40 steps for 8 videos)?
I do not need a real time solution, I can move my videos once a week/month.
PS: I understand that it could be done via my Windows PC, to install iTunes, but that is more complicated than via the steps that I described above. I do not have any MAC at home.
Answer: The top result from google for, "auto backup photos to NAS ios" is https://www.photosync-app.com/home.html and it seems to accomplish what you want.

Transfer videos over Wifi to NAS


QT - How to properly handle Vsync and multiple QGLWidgets

Question: I'm using three different QGLWidgets in the same main thread, preferably rendered at 60fps but I cannot achieve more than 20fps. It seems that this is caused by Vsync as each widget probably tries to synchronize with the refresh rate independently and therefore they lock somehow. If I only use two widgets I achieve 30fps. Or if I fix the update rate of one widget to, let's say 10fps, I reach 25fps on the others (10+25+25=60). swapInterval() always returns 0, independent of the value I set with setSwapInterval(int). Any ideas? Can I disable Vsync? Or might the problem be caused by something different?
Comment: Have you found a solution yet?
Comment: Unfortunately not. I kinda have an ugly workaround by simply hiding the widgets since I'm not always using all of them at the same time but of course that's not an acceptable solution.
Comment: Too bad, I would really like to know what the problem is.
Answer: It seems that its currently the bug from Qt 5.0 - https://bugreports.qt.io/browse/QTBUG-29073
Turning the Vsync off will solve the problem with dividing update rate between QGLWidgets, your graphics card will render to screen as fast as you tell it to or as fast as it can. But you must disable the VSync in graphics card settings. Just setting fmt.setSwapInterval(0) will do nothing.
Unfortunately another problem raises, if you are painting video that contains horizontal moves, tearing will appear.
Hopefully the Qt 5.3 shall fix this bug.
Comment: Thanks! For some mysterious reasons I have never thought of the possibility that disabling Vsync could actually be a graphics card setting - problem solved ;)
Answer: For those who are still struggling with this issue, my short answer is: before trying anything else: install Qt 5.4.
Longer answer:
I never had any issue to disable VSync with Qt 4.8.
Using Qt 5.3.1 (in Kubuntu 14.04 64bit), I have never been able to force my QGLWidget not to sync at VBlank, which means that swapBuffers() was blocking no matter what. I disabled VSync both in the "Desktop effect" panel and the NVidia control panel, and setSwapInterval(0) to no avail. Therefore my fps have always been clamped to 60fps/numOfQGLWidget (unless I used SingleBuffering, but the flickering was not tolerable in my applications). Using multi-threading, it should theoretically be possible to have VSync enabled (hence no tearing), and achieve 60fps for multiple QGLWidget, but I failed to have that working as well.
Today, I just installed Qt 5.4, and it magically solved the issue: I can successfully have a non-blocking swapBuffers(), as I used to in Qt 4.8. I think Qt 5.3 forced VSync somehow no matter what you driver settings were. But it is no longer the case in Qt 5.4, at least in my configuration. It seemed the Qt team did a lot of work to improve OpenGL for Qt 5.4 (notably, they introduced the QOpenGLWidget class), so my advice to anyone using OpenGL with Qt would be to make the update to Qt 5.4, it will likely make your life easier.
Comment: @SPlatten In your main() function, before constructing your QApplication, construct a `QSurfaceFormat format`, set `format.setSwapInterval(0)`, then `QSurfaceFormat::setDefaultFormat(format)`. See http://doc.qt.io/qt-5/qsurfaceformat.html#setSwapInterval and http://doc.qt.io/qt-5/qsurfaceformat.html#setDefaultFormat . Hopefully, it should do the trick. Otherwise, you might need to look at your graphics driver settings, or OS / desktop environment, which may override these settings. Generally, it's hard to ensure that vsync will be enabled in a portable manner.
Comment: Thank you, I will give it a try.
Comment: Any advice on how to implement vsync with QOpenGLWidget, I'm using QOpenGLWidget as the base class for my video rendering window, but I get tearing.


How to get pixel location in after rotating the image?

Question: I'm trying to rotate some images with some boundary boxes, but I couldn't get the new bb. So if I have an image of 100x70 and I have a pixel at (19,39) and then I rotate the image with angle = 45,
how can I calculate the new position of this pixel?
Answer:
EDIT: As pointed out by Frank, the original answer mixed up row vector and column vector affine transformations. The formulas have been edited to use row vectors to be consistent with the referenced Mathworks page.

You first need to define where you are rotating your image around.
If you are rotating it around (0,0) (i.e. your image is located in the positive x and y quadrant), you can apply a rotation matrix in its vanilla form:
$\left[\begin{array}{c}x' \\y' \\1\end{array}\right]^T=$
$\left[\begin{array}{c}x \\y \\1\end{array}\right]^T
\begin{bmatrix}\cos \theta &\sin \theta &0\\-\sin \theta & \cos \theta &0 \\0 &0 &1\end{bmatrix}$=$\left[\begin{array}{c}x\cos\theta + y\sin\theta \\-x\sin\theta+y\cos\theta \\1\end{array}\right]^T$
where x and y is your starting pixel location, x' and y' is your new pixel location, and $\theta$ is the counterclockwise angle to rotate. T means to transpose and is mostly there so that the row vector fits on the screen. You can ignore the 3rd row for now. Notice that because you are using sine and cosine functions, the new pixel location is unlikely to be an integer, so you will need to do some rounding.
However, if you are rotating around the center of the image (which is the more common use-case), you will need to first translate the "origin" of your image to the center, apply your rotation, then move your image back.
This alters the calculations to this:
$\left[\begin{array}{c}x' \\y' \\1\end{array}\right]^T$
$=\left[\begin{array}{c}x \\y \\1\end{array}\right]^T$
$\begin{bmatrix}1 &0 &0\\0 &1 &0 \\-X/2 &-Y/2 &1\end{bmatrix}$
$\begin{bmatrix}\cos \theta &\sin \theta &0\\-\sin \theta & \cos \theta &0 \\0 &0 &1\end{bmatrix}$
$\begin{bmatrix}1 &0 &0\\0 &1 &0 \\X/2 &Y/2 &1\end{bmatrix}$
$=\left[\begin{array}{c}(x-X/2)\cos\theta + (y-Y/2)\sin\theta + X/2 \\-(x-X/2)\sin\theta+(y-Y/2)\cos\theta + Y/2 \\1\end{array}\right]^T$
where capital X and Y are the size of your image in the x and y directions.

You can read more about image transformations on the mathworks page here.
Comment: There is an error in this answer: If you multiply your column vector (x y 1)^T from the right, then the translational part (X/2 and Y/2) must go in the rightmost column and not to the last row. The matrices you use are only correct if you multiply your vector (x y 1) as row vector from the left. The rotation matrix will rotate in your case into the other direction. In that sense, the information from the linked mathworks page is correct only for row vectors multiplied from the left.


Power Switching Circuit ESP32

Question: I've designed the power supply section for powering an ESP32 board and for switching between USB Power and 5V external power, would this circuit be sustainable and work properly?
Comment: When both VBUS and 5V_EXT are present, consider the tolerances on the supplies are well i.e., consider VBUS is at the highest level and 5V_EXT is at its lowest level. Can there be a current flow from VBUS to 5V_EXT. This is a critical point you need to look into.
Comment: To prevent a high current path between VBUS and 5V_EXT I'm going to add another diode from +5V_EXT to C9. That should solve the issue as suggested right?
Answer: That should be OK, but it would be safer to add another diode to keep USB power from flowing your internal supply.  If you're concerned about efficiency, you can replace the diodes with "ideal diodes" such as the MAX40203.
Of course, this is still simply voting according to which supply is higher.  There's also options such as TPS2105-EP if you want more fine-grained control; with a fairly light external load on it so it doesn't float, you could probably use the input you want to prioritize as the select line (e.g., use USB power if it's there, but use internal power only if USB power is unavailable).
Comment: To prevent a high current path between VBUS and 5V_EXT I'm going to add another diode from +5V_EXT to C9. That should solve the issue as suggested right?
Comment: That should work, as long as you're OK with highest voltage wins.  In retrospect, you're using an LDO, so dissipation isn't an issue...it's just a question of whether the LDO or the diode dissipates the excess power.
Comment: Thank you so much kind sir.
Comment: Glad to help.  :)
Answer: When you are using a diode in series with VBUS and 5V_EXT, there is no risk of reverse current but, you need to check if the drop across the diode is acceptable because it will reduce the Vin of the regulator. For eg., for this 3.3V regulator, as per the datasheet, the recommended minimum Vin is 3.3V+1.3V = 4.6V if the load current is 800mA (dropout voltage specification). Take into account the diode drop and the tolerances of the supplies and see if this can become an issue.
Comment: If you are convinced that you don't have the reverse current issue, you could remove D5. Otherwise, you could try the other options suggested by Cristobol

Power Switching Circuit ESP32


Cannot add Web Reference

Question: Recently we came across an issue with adding web references to existing c# project. Basically we tried to give the URL which was the generated enterprise wsdl as a web reference to our solution. And we tried it on our fsandbox environment. Here is the issue I'm getting,
"An internal server error has occurred An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience. Thank you again for your patience and assistance. And thanks for using salesforce.com! Error ID: 1349832752-5469 (39318494)"
We have been using this feature with great success for last couple of years. But this is the first it is giving a weird error message like this. Please help to sort this out
Thanks,
Mudi
Comment: This doesn't provide technical detail. So, you will have to contact Salesforce with given error id.
Comment: What API method were you calling when the error occured?
Answer: I connected with SFDC support. And they were unable to fix the issue. Instead they suggested to use Add Service Reference instead of Add Web Reference.
But when I tried to load the web Reference today, it worked well as expected. So not sure what's going on here. Either way it works fine now

Cannot add Web Reference


Book Plot Sugestions

Question: Does anyone have a good plot suggestion for a children's fantasy? Maybe about a 13 year old girl in the 1500's. Anything will do.
Comment: Hi, Lizzy. Unfortunately, this sort of open-ended plot question isn't really what we do here. There are lots of other sites where you could ask stuff like this, but we want questions to have a single focus and an objective answer.
Comment: Perhaps this question could be 'rescued' by asking *where* one can find plot suggestions, particularly for that target audience and type of setting.
Comment: Hi Lizzy.  As JSB said, this type of question isn't a good fit for this site, which is focused on answerable questions, not open-ended discussion.  However, if you build up a little reputation here (through asking or answering other questions, for example), you'll be able to use [chat], where free-flowing discussions and brainstorming are quite welcome.  I'm sorry we couldn't help you with this question, and I hope you'll stick around and check out other questions.
Comment: @Monica Cellio: Why are you referring to the poster as "Lizzy"?
Comment: @Rrr apparently the user has changed names since I left that comment in 2013.
Answer: If I can suggest something, that would be a story about a young female who attends the medieval school of wizardry. She is forced to have very strict training and no friends in school, because teachers believe that one day, she will save the world and they don't want her to rely too much on others. Somehow, she fells in love with a boy, but later realizes that he is a vampire, and that her favorite teacher, who is secretly in love with her, is a werewolf too. Unfortunately, there are some bad wizards in the world, who take it over and start their totalitarian rules. Our hero has to take part (instead of her younger sister) in a deadly competition against other teens from the school, from which only one will survive. But in the grand finale, the army of animals comes to the rescue, with the great lion who becomes a new king of the magic kingdom.
I'd love to read a story like that.
Comment: You forgot the ninja exchange students who show up riding sharks.
Comment: The source material was better than the live-action Netflix adaptation  :(

Book Plot Sugestions


A question about proving the inverse of a logical statement.

Question: Suppose the logical statement $P \rightarrow \lnot Q$ is true whose inverse's truth value is unknown. Also, suppose that $\lnot R \rightarrow \lnot P$ is true and $\lnot R \rightarrow \lnot Q$ is true, with $\lnot R \rightarrow Q$ false. The inverse of $P \rightarrow \lnot Q$ is given by $\lnot P \rightarrow Q$. Not knowing the truth value of the inverse, it follows that $\lnot P \rightarrow Q$ is only true if the conjunction $(\lnot R \rightarrow \lnot P) \land (\lnot P \rightarrow Q)$ is true, since $\lnot R \rightarrow \lnot P$ is true. By hypothetical syllogism the false statement $\lnot R \rightarrow Q$ is produced. Therefore, we can conclude that $\lnot P \rightarrow Q$ is false. Is this a correct approach to proving this statement is false?
Answer: First of all: yes, your argument appears valid.
Second: note that this doesn't really have anything to do with the "original" implication $P\rightarrow\lnot Q$, and that your argument doesn't use the assumption $\lnot R\rightarrow\lnot Q$. Really, you are just starting with the two assumptions $\lnot R\rightarrow\lnot P$ and $\lnot(\lnot R\rightarrow Q)$ and trying to deduce the statement $\lnot(\lnot P\rightarrow Q)$.
Equivalently, since the negation of $A\rightarrow B$ is $A\land(\lnot B)$, we are trying to start with the two statements $\lnot R\rightarrow\lnot P$ and $(\lnot R)\land(\lnot Q)$ and deduce the statement $(\lnot P)\land(\lnot Q)$, that is, to deduce the two statements $\lnot P$ and $\lnot Q$.
This is actually pretty straightforward:

The assumption $(\lnot R)\land(\lnot Q)$ implies $\lnot R$, which together with the assumption $\lnot R\rightarrow\lnot P$ implies $\lnot P$;
and the assumption $(\lnot R)\land(\lnot Q)$ directly implies $\lnot Q$.
Comment: That makes sense, and it is clear that is the easier way. My main concern was the use of the hypothetical syllogism and assuming that since it was known that one statement was true, the conjunction is "only" true if the other statement was true. Since the hypothetical syllogism produced a false statement, one could conclude that the other was false. It sounds like that is a valid way, but just longer.
Answer: I am very confused by your argument. First: what exactly are the givens? At first it seems like $P \to \neg Q$ is a given .... but you never use it ... In fact, you say that $\neg P \to Q$ is its inverse, and that seems to be the statement you ar trying to prove false.  So .... are you trying to show that $\neg P \to Q$ is false on the basis of the truth of $P \to \neg Q$? In particlar, are you trying to show that $\neg P \to Q$ is False by showing that $P \to \neg Q$ is True? If so, please understand that the inverse of a statement can have the same truth-value as the statement itself, so that approach does not work. Firtunately, youm don't seem to reason that way ... indeed, ypu seem to be assuming that  $P \to \neg Q$ is True .. but why? What is you your purpose for assuming this? And note ... you never really use it.  So in the end, it's all just very, very confusing what you are trying to do, and how you are trying to go about it.
Comment: All of the true and false statements at the beginning are givens. My point was to use the conjunction of one statement known to be true and the other in question. Since the hypothetical syllogism is false, I concluded that the statement in question must be false. Since the conjunction could only be true if the statement in question were true.


more than one stack in microprocessor

Question: can I use more than one stack in microprocessor?
and if I can,How can I progamming those?
Answer: Sure you can. Several CPU architectures have multiple stack pointers - even lowly 8-bit processors, such as the M6809. And even if the concept is not implemented in the CPU hardware, you can easily create multiple stacks in software. A stack pointer is basically simply an index register, so you could (for example) use the IX and IY registers of the Z80 to implement multiple stacks.
Comment: @Auto Not in the 6809, which I have extensive programming experience of. Both are available from user code.
Comment: But only one is generally available to use code, and certainly only one is used by compiled code. The other is for interrupts.
Answer: If your microprocesser has more than one hardware stack, then yes, you can. You would have to write assembler though, since no c/c++ implementation makes use of multiple stacks.
It would be easier to help if you could say exactly what architecture you're talking about.
Answer: As for the how of it.  Generally there is a special register or memory location that is used to point to the stack. Using another stack is just as simple as setting this value.  This is all processor and architecture dependent so it depends on the one you are using.
Answer: On some platforms, the stack used for return addresses is entirely separate from the one used for parameter passing.  Indeed, on some platforms, C compilers don't permit recursion and don't use any stack for parameter passing.  Frankly, I like such designs, since they minimize the likelihood of stack problems causing errant program behavior.

more than one stack in microprocessor


If I give my bank account and routing number to a stranger to receive a one-time payment, can they steal money from my account?

Question: Aside from my SSN, card numbers and PIN numbers what information does someone need to spend money from my bank account without my consent? I want to list an item for sale on an auction website and if it sells the winning bid should be in the thousands. If I accept payment by bank transfer (due to potential rules regarding payment for this type of item) can the bidder use my bank account and routing numbers to spend money from my account?
Comment: @MarkBuffalo why is it on-topic?
Answer: This depends on which juridicsion or country you live in.
For example, here in sweden, its safe to give out bank account number and routing information, because to extract money, you will need a valid ID-card tied to someone that is authorized to access the account, and of course, bank personell will of course check the ID card throughly including calling the issuer to check if the ID card is barred.
In other countries, bank numbers are considered a "password", eg anyone that have it can pull money from account.
Also check your checks if you have check access. If the checks only lists your bank number and routing number, there is a possibly that someone could create a fake check with fake signature from you, and cash that check. Some other banks might include a security code or similar that will be cross-checked against the bank's computer system.
Same with bill paying. If bill-paying using only bank account and routing number is allowed from a remote location, then you are at risk, since someone only needs to fake your signature.
But for example in sweden, you always need to sign up for such services using a ID, and if those services aren't enabled on your account, its not possible for any outsider, that have access to bank number and routing info, to extract money from account.
The best you can do, is to open a unrelated bank account, at a second bank you normally isn't a customer in. This bank account, should have NO associated services, no checking account, no bill-payer service, nothing. Only way to get money out of the account should be physically visiting the bank office.
This account would then be safe to leave out. I don't know what happens if some attempts to cash a fake check for a bank account that has no checking access, but I think the accepting bank will notice the attempt immediately when their computers show the lack of checking access on the bank account.

HOWEVER: There is a second thing that is toublesome, regardless in which way you receive money. This is that someone, could, without your permission, depoist toublesome money in your account, for example money gained from a bank robbery or sales of narcotics. When investigation goes on, there is a possibility that all accounts you own, is frozen during the investigation. When a account is frozen, it means you have to apply to get your money for day-to-day living for example food and such.
So even if the security is so tight that only you can extract money from the account even if the whole world knows your bank account number, there is a possibility you can get in trouble if someone wants you in trouble.
This means, that regardless of the payment method you accept or use for the auction in question, you should carefully vet and check the winning buyer, before giving out information to the buyer that makes it possible for him to pay. If something is suspicious of the buyer, even if he have the money (Note! The money can be stolen! Not even cash is 100% safe to receive), then go for the next highest bidder.
In most auction sites, if you bid on a item, you are always obligated to pay the bid, even if someone overvid you, because also in most auction sites, the seller has the possibility to select who should win, he isn't required to sell to the highest bidder. (but of course, if the highest bidder is clean, theres no reason for the seller to lose money on selecing a low bidder).
Comment: I don't agree with it being safe in Sweden, especially if the attacker may have access to your ID number.  However, I am in complete agreement about troublesome money. That's something I forgot to include!
Comment: Even if you have someones ID, you can't extract any money, you still need a valid ID card. Maybe if you steal the card, but as I said, the bank personell verify if its barred, so no luck stealing a ID card if the owner is quick enough to call and barr it.
Comment: Sebastian, agreed. Unfortunately, people's IDs are fair game when it comes to hackers breaching supposedly confidential data. Your ID is likely out there anyway.


"Leave the door open" vs "let the door open"

Question: Can I mean "May I leave the door open?" by asking "May I let the door open?" in any context? I know that there is, of course, a difference in meaning in both of the sentences, but I'm just wondering if I can ask "Should I let the door open?" to mean "Should I let the door at its default(open) position?"
Comment: I have never heard *let* use this way (AmE). Could you find a dictionary definition with such a meaning?
Comment: I think what you are looking for here is that you want to ask the other person whether he wants the door closed or open. If that's the case then you should ask - "Do you want the door open / closed"? / Or you may ask "Should I keep the door open"?
Answer: If the door is currently open, whether or not it would return to the open position by default, you would say, "May I leave the door open?"
If the door is closed or nearly so, then you can say, "May I let the door open?" Basically, substitute "allow" or "permit" in the sentence; "May I allow the door to open?" only makes sense if the door is not already open.
Comment: Agreed.  The only way "let" makes sense is if the door is closed, and you're asking if you can *allow* the door to open.  (Even then, it's a strange word choice.)


Debugging multiple hadoop jvms with Eclipse

Question: I have a problem that appears in pseudo-distributed mode, but not in standalone mode, and I'm hoping to scratch up some ideas on how to debug this.
Some of my mapper tasks are returning code 143. I'd love to drop a breakpoint on System.exit() and see who's calling this why, but I have to get the debugger running on that mapper.
I can get the task tracker up in the debugger by modifying my bin/hadoop script and remotely connecting to localhost:5000:
<code>...
elif [ "$COMMAND" = "tasktracker" ] ; then
  CLASS=org.apache.hadoop.mapred.TaskTracker
  HADOOP_OPTS="$HADOOP_OPTS $HADOOP_TASKTRACKER_OPTS"
# TBMark!
  HADOOP_OPTS="$HADOOP_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=5000,server=y,suspend=n"
</code>
...and I can get the first mapper (or by a minor tweak, reducer) into Eclipse by adding this into my conf/mapred-site.xml and remotely connecting to localhost:5001:
<code><property>
  <name>mapred.map.child.java.opts</name>
  <value>-Xdebug -Xrunjdwp:transport=dt_socket,address=5001,server=y,suspend=y</value>
</property>
</code>
My problem is that the failure happens at random and not on the first mapper.
Unsatisfactory ideas that come to mind include:

Somehow replace System.exit() with my own method that does a stack trace. (How does one hook a system call?)
Just keep trying to debug the mappers one by one and run each one to completion before debugging the next. (It might work...)
Track down every last place in hadoop that calls System.exit() and write a distinct signature to a log. (Yuck)
Make the debugger port number variable such that, if I can guess which one is going to fail and the delay doesn't make the bug go away, I can attach to that jvm and debug it. (Many if's, and I don't know any way to make this variable in the .xml file.)
If failure can be predicted to happen on a certain attempt, break the task tracker just before the jvm launch and hand edit the script file. (Desperate times call for desperate measures)

Any suggestions or ideas for how to make my bad ideas above work?
Answer: You could try to re-run a failed map task with the IsolationRunner
In case it fails again you should be able to add the debug options!


What are the new birds in Angry Birds Space?

Question: What are the new birds in Angry Birds Space and what are their abilities?
Answer: Angry Birds Nest has a post with analysis of the announcement video:

At first glance, the video suggests that the Red, Black, and [now-green] Big Brother birds all have the same abilities as before, though newly-designed.

The Blue birds have the same ability, though they seem a bit stronger than in the original apps.

There also seems to be a purple-colored bird (we are not going to speculate as to its name right now), whose ability is to redirect and accelerate. Personally, I believe this is a new ability of the existing Yellow bird.

There is also a new "icy" bird (again, no speculation as to name), whose ability is to freeze its contact area on a structure.

This seems to be accurate based on this newer post describing all of the birds in detail, which I won't reproduce.
Edit: Based on playing the game just now, it appears that the blue birds don't speed up as mentioned in the latter post (but not the first).  Possibly it was just confirmation bias on ABN's part since there's a nice rocket-like glow when they split apart.  As well, all birds show a plot of the first part of their trajectory.
Comment: The purple bird appears to behave much differently than the old yellow bird. The yellow bird would just accelerate in the direction it was moving at the time, while the purple bird while accelerate in whichever direction you tap no matter it's original path.
Comment: @DoozerBlake I wouldn't call it much different, it's just the redirection -- which is what the excerpt notes ;)
Answer: Red: Super Red, Ability: Shouts to scare pigs
Blues: Lightning Birds, Ability: Creates a flash and splits into 3 directions
Chuck: Lazer Bird, Ability: Targets wherever tapped
Bomb: Firebomb, Ability: Blows up
Egg: Space Egg, Ability: creates a wormhole that either sucks or pushes stuff around
Ice Bird, Ability: Freezes everything nearby that can be frozen
Terence: The Incredible Terence, Ability: Roars to scare pigs
Bubbles: Atom Bird, Ability: Expands to huge size
Mighty Eagle: Space Eagle, Ability: Creates a wormhole where the Sardines were dropped and destroys everything in his path.


Internal angle bisectors and right-angled triangle?

Question: Imagine a right angled triangle. Two of its internal bisectors are of length $7cm$ and $4cm$, respectively. The first internal angle bisector belongs to the angle of the side $a$ and the second one belongs to the angle of the side $b$ Calculate the length of the hypotenuse of the right angled triangle.
Comment: the bisectors of which angle, and please specify as right triangle
Comment: What is the name of the triangle?What is $t$ in $at$ and $bt$?
Comment: Which of the triangle angles is right?
Comment: That's part of the problem. It's not stated.
Answer: Case 1:  Suppose that $a,b$ are the legs of the right triangle. Let then $c$ be the length of the hypotenuse, and $C = \frac{\pi}{2}, A, B$ the respective angles.
It follows by inspection that:
$$ 7 = \frac{c \; \cos A}{\cos A/2} \quad \text{and} \quad 4 = \frac{c \; \cos B\; }{\cos B/2}$$
Since $\cos \frac{x}{2}=\sqrt\frac{1 + \cos x}{2}$ and $B = \frac{\pi}{2} - A$, the above  gives:
$$7^2 = \frac{2 c^2 \cos^2 A}{1+ \cos A} \quad \text{and} \quad 4^2 = \frac{2 c^2 \sin^2 A}{1+ \sin A}$$
After dividing the two equalities:
$$\left(\frac{4}{7}\right)^2 = \tan^2 A \;\frac{1+ \cos A}{1+ \sin A}$$
In terms of $t=\tan A/2$ (with $\cos A = \frac{1 - t^2}{1+t^2}, \sin A = \frac{2t}{1+t^2}$) the equation becomes:
$$\require{cancel}\frac{2 \cdot \bcancel{8}}{49}=\frac{\bcancel{4} t^2}{(1-t^2)^2} \cdot \frac{\bcancel{2}}{\cancel{1+t^2}} \cdot \frac{\cancel{1+t^2}}{1+2 t+t^2}$$
$$2(1-t^2)^2(1+t)^2 - 49 t^2 = 0$$
$$\Big(\sqrt{2}(1-t^2)(1+t) - 7 t\Big)\Big(\sqrt{2}(1-t^2)(1+t) + 7 t\Big) = 0$$
$$\Big(\sqrt{2} + (\sqrt{2}-7) t- \sqrt{2} t^2-\sqrt{2} t^3\Big)\Big(\sqrt{2} + (\sqrt{2}+7) t- \sqrt{2} t^2-\sqrt{2} t^3\Big) = 0$$
Since $A/2 \in (0, \pi / 4)$ the roots of interest are $t = \tan A/2 \in (0,1)$ and it can be shown that the only such root belongs to the first cubic. The value can be calculated exactly by solving the cubic using Cardano's formula, for example, though the resulting expression is not pretty.
Numerically, the eligible root is $t \approx 0.23579$ corresponding to $A \approx 26.53447^{\circ}$ and the hypotenuse $c \approx 7.61533$ (which agrees with the Maple solver result posted by Han de Brujin in his answer).
Case 2:  Suppose that one of $a,b$ is the hypotenuse. Since the shortest bisector corresponds to the largest angle, the right angle bisector must be $4$ and side $b$ must be the hypotenuse. Then (by the bisector length formula for the former):
$$ 4^2 = \frac{2 a^2 c^2}{(a+c)^2} = \frac{2 \;b^2 \;\sin^2 A \;\cos^2 A}{(\sin A + \cos A)^2} \quad \text{and} \quad 7 = \frac{b \;\cos A}{\cos A/2}$$
$$ 4^2 = \frac{2 \;b^2 \;\sin^2 A \;\cos^2 A}{1 + 2 \;\sin A \;\cos A} \quad \text{and} \quad 7^2 = \frac{2 b^2 \;\cos^2 A}{1 + \cos A}$$
Similar to the previous case, dividing and rationalizing in $t = \tan A/2$ gives:
$$\left(\frac{7}{4}\right)^2 = \frac{1 + 2 \;\sin A \;\cos A}{(1 + \cos A) \sin^2 A} = \frac{(1+t^2)^2 + 4 t (1-t^2)}{(1+t^2)^2} \cdot \frac{(1+t^2)^3}{8 t^2}$$
$$\cdots$$
$$2 t^6-8 t^5+6 t^4-43 t^2+8 t+2 = 0$$
The sextic can be shown to have a unique real root in $(0,1)$ which is numerically $t \approx 0.32999$ and corresponds to $A \approx 36.52438^{\circ}$ and the hypotenuse $b \approx 8.27202$.
Comment: That's an improvement worth (+1).
Answer: Here is a sketch of the triangle and its two internal bisectors $\overline{AP}=7$ , $\overline{BQ}=4$ :

We shall need a cosine law:
$$
\cos(A) = 2\cos^2(\frac{1}{2}A)-1 \quad ; \quad
\cos(B) = 2\cos^2(\frac{1}{2}B)-1
$$
Three highly non-linear equations with three unknowns can be derived then:
$$
2\cos^2(\frac{1}{2}A)-1 = 2\left(\frac{b}{7}\right)^2-1 = \frac{b}{c} = \cos(A) \\
2\cos^2(\frac{1}{2}B)-1 = 2\left(\frac{a}{4}\right)^2-1 = \frac{a}{c} = \cos(B) \\
c^2 = a^2 + b^2
$$
Since finding a solution by hand seems to be hopeless, I decided to feed this
into some computer algebra system (MAPLE) and solve anything numerically:

> eqns := {2*(b/7)^2-1=b/c,2*(a/4)^2-1=a/c,c^2=a^2+b^2};
> sols := {a,b,c}; fsolve(eqns,sols,0..infinity);
  { a = 3.402041954, b = 6.813171845, c = 7.615326654 }

Where $c$ is the length of the hypotenuse that is asked for.


Work on fuzzing of PDF file format

Question: What work has been done on fuzzing of the PDF file format?  I'm looking for work that focuses specifically on PDF, and is aware of the PDF file format.  Has there been past work that builds format-aware tools for fuzzing PDF?  Perhaps format-aware mutational fuzzing or generational fuzzing?  And are any of the tools or test suites publicly available?  The PDF file format is incredibly complex; I'd like to avoid re-inventing the wheel.
Answer: There is work on the topic, at several levels.

fuzzing of the internal tables - very easy, and doesn't really work
fuzzing of internal codecs such as z-streams
fuzzing of internal formats, e.g. fonts, JPGs, TIFFs etc. - I'm aware of some buggy implementations of CCITT "fax" monochrome picture that are still used by some fax-to-PDF machines, i.e. the companion application uses a buggy libTIFF decoder; one of these turned out as BugTraq 46-658, but there are more)
fuzzing of "extensions" such as Javascript. One tool that does this is pdffuzzer.

You will probably be interested in reading about j00ru et al.'s work (updated). An effort in Python can be found here.
Answer: look at white-box fuzzer BUZZFUZZ technical report available at https://ece.uwaterloo.ca/~vganesh/buzzfuzz.html
Comment: Corrected link: https://ece.uwaterloo.ca/~vganesh/Publications_files/vg-ICSE2009-BuzzFuzz.pdf - the one you gave does not contain the BuzzFuzz technical report.

Work on fuzzing of PDF file format


SMART "power on hours" attribute for different HDD manufacturers

Question: Is there a table of how to interpret the SMART attribute "power on hours" depending on the HDD manufacturer? Some of them use hours, some minutes or even seconds...
Comment: Good question indeed. I wonder why someone has down-voted it!
Comment: I've never seen a drive that used anything other than hours to represent "power on **hours**"...do you have an example? For instance I have an SSD that stores power on time in milliseconds, but it also _says_ that it does.
Answer: See this FAQ answer from the Smartmontools project:
http://www.smartmontools.org/wiki/FAQ#Iseesomestrangeoutputfromsmartctl.Whatdoesitmean
There are links there to vendor specific pages which may provide you with the information you're looking for.
Some other relevant FAQs on the same page:

smartctl reports the age as thousands of hours for my
Maxtor/Hitachi/Fujitsu? disk , yet it is only a few days old
On recent disks, Maxtor has started to use Attribute 9 to store the
power-on disk lifetime in minutes rather than hours. In this case, use
the: '-v 9,minutes' option to correctly display hours and minutes.
Some models of Fujitsu disks use Attribute 9 to store the power-on
disk lifetime in seconds. In that case, use the: '-v 9,seconds' option
to correctly display hours, minutes and seconds.
The power-on timer (Attribute 9 raw value) on my Maxtor disk acts
strange.
There are three related problems with Maxtor's SMART firmware:
On some Maxtor disks, the raw value of Attribute 9 (Power On Time) is
supposed to be minutes. But it advances at an unpredictable rate,
always more slowly than one count per minute. This is because when the
disk is in idle mode, the counter stops advancing. This is only
supposed to happen in standby mode. This will be corrected in Maxtor
product lines released after October 2004.
In Maxtor disks that use the raw value of Attribute 9 as a minutes
counter, only two bytes (of the six available) are used to store the
raw value. So it resets to zero once every 65536=216 minutes, or about
once every 1092 hours. This is fixed in all Maxtor disks manufactured
after July 2003, where the raw value was extended to four bytes.
In Maxtor disks that use the raw value of Attribute 9 as a minutes
counter, the hour time-stamps in the self-test and ATA error logs are
calculated by right shifting 6 bits. This is equivalent to dividing by
64 rather than by 60. As a result, the hour time stamps in these logs
advance 7% more slowly than they should. Thus, if you do self-tests
once per week at the same time, instead of the time-stamps being 168
hours apart, they are 157 hours apart. This is also fixed in all
Maxtor disks manufactured after July 2003.
Power_On_Hours Attribute of my new Intel SSD reports ~890000 hours
This is a bug in Intel 330 Firmware 300i and Intel 520 Firmware 400i.
The offset is 894794 hours. See also ticket #289 and Intel SSD
Toolbox SMART Attributes FAQ. The hours counter from Device Statistics
is not affected:


Historical Precursor to な?

Question: Prior to the development of the な particle (presumably from なる) several hundred years ago, what constructions were used where な-construtions are currently used? E.g. in the phase きれいな女, would that have been きれいの女, 女のきれい, きれい女 (and would that be kireionna or kirei onna?), きれいなる女 or something else?
Comment: I think that なる is used.
Comment: なり and たり conjugate like ラ変 verbs.
Comment: 「きれいな女」の「な」って、助詞なの?
Comment: @Chocolate 助詞というより助動詞かな?
Comment: Sorry, are you asking what developed into なる, or what developed into な?
Comment: なる is still sometimes seen, e.g. 父なる神様 = Father God in Christianity.
Comment: http://www.genji.co.jp/yougen/narikatu.htm#narikatu 「源氏物語に出てくる『用言』を、活用の種類別・多い順(※)に表にしました。」, eg 静かなり. Note that たる adjectives were in use as well, eg 堂々たる.
Comment: I suppose it would be 堂々たり predicatively? Is たる a 四段 or ラ変 suffix?
Answer: It is from なる, in a way; but it may not be the one you're thinking of. The なる here is the 連体形 of the former copula なり, which itself derives from に+あり (modern ある). This seems to have been the copula as far back as we have records of. Indeed, this kind of adjective is younger than the copula it uses - these kinds of adjectives do not occur before the Heian-jidai.
A couple of forms do appear that have since become them (e.g. adjectives ending in -らか), but I don't know how these were used - my source (Bentley's Descriptive Grammar of Old Japanese Prose) mentions their existence, but only says that these なり-based adjectives are new as of the Heian-jidai; it says nothing at all about how they were used in Old Japanese. I would speculate that they're used in the very old adjective patterns that require no morphology at all: so just like you can get /awo sora/ (/səra/?) where you would expect /awo-ki sora/, I bet you could get /tapiraka umi/ when later you would expect /taɸiraka=naru umi/ (for 平らかな海).
As for きれい, it's a Chinese loanword, and was loaned after the creation of these kinds of adjectives. So there was never a point in time before きれいなる女 - you would have used a native Japanese word like 美しい, and so you would have either /utukusi-ki womina/ or the older /utukusi womina/.
Comment: /utukusi/ would be the 終止形【しゅうしけい】 or terminal form, which only ended a sentence.  As such, /utukusi womina/ would not be correct.  The 連体形【れんたいけい】 or attributive form would have to be used for the adjective to directly precede a noun, which would have been /utukusiki/.  This is already the case in the *Man'yōshū*, written starting some time between the 300s or 400s and finalized around the mid-700s.
Comment: Also, /awo/ and the other root Japanese color words (/aka/, /shiro/, /kuro/) are also nouns, so /awo sora/ is a compound of two nouns.  /awoki/ as an adjective is indeed used, but not so much in set phrases, where the compound is the shorter and simpler formation.
Comment: Lastly, the -らか and -やか adjectives were formed by adding suffixes -ら and -や, with -か then later added on as another suffix.  According to Shogakukan, both -ら and -や indicated "XX kind of state or circumstances".  -ら may be related to pluralizing suffix -ら as in 我【われ】ら, which was also used to imply "[noun] kind of thing", and -や may be related to particle や, similarly used to imply "[noun] kind of thing".  Final suffix -か also indicated "kind of state", and I've read theories that this is related to the -か, -こ, and -く suffixes indicating "place, area".
Comment: All that said, though, 平【たひ】ら is a compound of prefix た- (of indeterminate meaning, apparent emphasizer) and ひら "flat".  たひらか is thus たひら + か, not たひ + らか.  There was also a regular /-si/ adjectival form たひらけし, with adjectivizing suffix -けし apparently 気 + し, a bit like modern 気【げ】 + な.
Answer: As others have noted, the modern な particle used with -na adjectives evolved from なる, itself not the verb なる "to become", but instead a contraction of にある "to be in a state".  So from newest form to oldest, using your example of きれい, we would have:

綺麗な女
綺麗なる女
綺麗にある女

The -naru form is still used in modern poetry and other contexts to give things a somewhat archaic and formal sense, such as in 静{しず}かなる田舎{いなか}, the quiet contryside.
Although the classical -naru adjectives did indeed seem to develop mostly in the Heian period (794-1185), the construction of [noun phrase] + にある + [noun] can already be found in the Man'yōshū, dating to some time between the mid-300s and the mid-700s.  Example:

Poem 165:
宇都曽見乃 人尓有吾哉 従
うつそみの人{ひと}にある我{わ}れや
Here, utsusomi no hito is a noun phrase ("person in the real world", i.e. "someone who is still alive") used to modify ware ("I, me").

There is also at least one example I found of what may be an early -ni aru adjective in the Man'yōshū, 寛{ゆた}, classed in Shogakukan's Kokugo Dai Jiten as a 形容動詞{けいようどうし} (-na adjective):

Poem 2367:
大舟之 由多尓将有 人兒由恵尓
大船{おほぶね}のゆたにあるらむ人{ひと}の子{こ}ゆゑに
...because [you're] the child of a person who is steadfast like a big ship
Here, the phrase ohobune no yuta ("big ship's easygoing-ness / steadfastness / steadiness") is used to modify hito.

If you're interested in the history of -na adjectives, the 概要 section of the JA Wikipedia article on 形容動詞 describes how Heian-period writers suffixed -にあり (becoming -なり) and -とあり (becoming -たり) to nouns to create new classes of adjectives.

Historical Precursor to な?


Interpretation of reference category in logistic regression

Question: I have some categorical data set; I want to use these as predictor variables, like one is slope. And it categorized in to five classes as, < 10 deg, 10-20 deg, 20-30 deg, 30-40 deg, > 40 deg. I have taken first class as reference category (< 10 deg). Now I am facing problem to interpret the beta value of the reference category, because it's not display on binary logistic regression. So what would be the value (beta), for reference category? Any suggestion regarding the problem would be appreciated.
Comment: It depends on the software you use, but generally [dummy coding](http://bit.ly/Ote3a6) is used, whereby the intercept includes the mean of the reference category and all other coefficients for your categorical variable reflect mean deviation from that value. If you have other predictors in your model, replace 'mean' by 'adjusted mean'. Here is an overview of coding systems with R: [R Library: Contrast Coding Systems for categorical variables](http://bit.ly/LFkFBg).
Answer: Setting
Let $X$ be the categorical predictor and suppose it has 3 levels ($X = 1$, $X = 2$, and $X = 3$). Let the third level be the reference category.
Define $X_1$ and $X_2$ as follows:
$$
X_1 = \left\{
\begin{array}{ll}
1 & \textrm{if } X = 1 \\
0 & \textrm{otherwise;}
\end{array} \right.
$$
$$
X_2 = \left\{
\begin{array}{ll}
1 & \textrm{if } X = 2 \\
0 & \textrm{otherwise.}
\end{array} \right.
$$
If you know both $X_1$ and $X_2$ then you know $X$. In particular, if $X_1 = 0$ and $X_2 = 0$ then $X = 3$.
Logistic regression model
The model is written
$$
\log \left( \frac{\pi_i}{1 - \pi_i} \right) = \beta_0 + \beta_1 x_{1i} + \beta_2 x_{2i}
$$
where $\pi_i$ denotes the probability of success of individual $i$ with covariate information $(x_{1i}, x_{2i})$.

If individual $i$ falls in category $1$ then $x_{1i} = 1$, $x_{2i} =
   0$ and $\log \left( \frac{\pi_i}{1 - \pi_i} \right) = \beta_0 +
   \beta_1$.
If individual $i$ falls in category $2$ then $x_{1i} = 0$, $x_{2i} =
   1$ and $\log \left( \frac{\pi_i}{1 - \pi_i} \right) = \beta_0 +
   \beta_2$.
If individual $i$ falls in category $3$ then $x_{1i} = 0$, $x_{2i} =
   0$ and $\log \left( \frac{\pi_i}{1 - \pi_i} \right) = \beta_0$.

odds ratio
Odds ratios are computed with respect to the reference category. For example, for 'category 1 vs category 3' we have
$$
\frac{\exp(\beta_0 + \beta_1)}{\exp(\beta_0)} = \exp(\beta_1).
$$
Answer: this is standard for a single variable.  the intercept is the log odds for the reference category and the dummy variables betas are the difference in log odds compared to the reference category.  so an "insignificant" dummy variable means the logs odds arent significantly different from the reference category.  this is the same as ordinary anova, just on the log odds scale instead of raw scale


Getting an exotic armor with different prefixes

Question: Twilight Arbor armor can be picked with one of the following three prefixes: Rampager's, Rabid or Magi's. But I'd like the Berserker's prefix on the armor pieces. Is it possible to have this specific armor with the Berserker's prefixes?
Answer: Unfortunately, no. I've had the same problem. However, most of these armor options are meant to be used for transmuting the skins anyway (i.e. buy the item to be used as a skin, buy a transmutation crystal off the item store and merge the item with a crafted/bought/dropped one with correct stats).
However:
According to recent datamining of the client files it seems like ArenaNet might introduce special itemshop items allowing you to reconfigure/change prefixes on items. Although it's yet to be seen how much they'll cost, whether they'll indeed appear and whether they'll allow you to reconfigure such "set" items as well, considering there probably aren't other versions (like Berserker) right now.
Comment: They will need to provide a way to allow players to change items stats when they drop magic find. Ref: https://www.guildwars2.com/en/news/looking-ahead-guild-wars-2-in-2013//
Comment: Where do you see your latter comment? And wouldn't transmutating work somehow?
Comment: Of course transmuting is an option. As for datamining: Just read the first few lines in the table, starting with *"Customize your Stats!"*.
Comment: Allright, then I'll be transmuting them. I despite the fact that the name probably depends on the one with the original stats (nót the TA armor set then) thus losing the 'cool name'. Although it's the skin I want so I shouldn't be too upset about it. I'm curious as to what the new additions to the game will be, but by the time I've managed to farm up enough tokens, I'll be able to see it ingame. Thank you @Mario.
Comment: @DavidYell I forgot about that. I've got quite a few runes/items to boost my Magic Find but you made me remember they'd drop it. This makes my decision easier!


How to test if a bitmap file has a transparent background?

Question: I created a bitmap with transparent background but in the Windows Picture Viewer I see the white background and even if I reopen it in Photoshop CS3. how do I make sure the white colour in bitmap is really transparent or see if contain any transparent colour?
Answer: Bitmaps (i.e. files with .BMP extension) do not natively support transparency: you need to save as a different format like PNG. Another format that supports transparency is GIF but it is only suitable for simple images with few colours. The best format depends on the image and where it will be used.
If the background is transparent then in Photoshop and most other image editors you would normally see a checkered background made up of small white and grey squares. But the Windows Picture Viewer itself is no good for testing transparency - it shows transparent areas as being white.
Update
Since this answer was originally written (some 8 years ago) it has been pointed out that the BMP format can support transparency in some cases. Still I would not recommend using it for this purpose, many programs will not interpret the alpha channel correctly and there would be no real reason for using it over something like PNG.
Comment: This article ACTUALLY says that BPM v2.1.4 does support transparency. en.wikipedia.org/wiki/BMP_file_format#Pixel_storage . The question now, is: how many software programs do support that new BMP version?
Comment: Yes the BMP format is now known to support an undocumented alpha channel that may work in some cases. But why would you want to use this incredibly inefficient file format in 2018 given the number of alternatives?
Comment: it is not "undocumented". I just put the link to the documentation.
Comment: I don't use BMPs anymore.
Answer: BMP's do support transparency. Bitmap must be set to indexed 256 color, and pixel at (0,0) is for the color that you want transparent.
Comment: No, they really don't. Some tools take the pixel color at (0, 0) to be considered as transparent, but there is nothing in the BMP spec that allows for transparency.
Comment: @IgnacioVazquez-Abrams Bmp format supports transparency.  https://en.wikipedia.org/wiki/BMP_file_format
Comment: I agree. BMP support transparency for quite a while.
Answer: If you have Office, start a new presentation using something other than the default blank template, then insert your picture (on the Insert tab in 2007/2010 or Insert | Picture | From File in earlier versions).  If you can see through the (supposedly) transparent bits of your picture to the background behind it, then the image does have transparency.  Otherwise, no.
This assumes that the image is in a format that PPT can insert (BMP, GIF, PNG, JPG etc).
Answer: Since v2.1.4 BPM supports transparency.
https://en.wikipedia.org/wiki/BMP_file_format#Pixel_storage

In version 2.1.4 FFmpeg supported (in its own terminology) the BMP
  pixel formats bgra, bgr24, rgb565le, rgb555le, rgb444le, rgb8, bgr8,
  rgb4_byte, bgr4_byte, gray, pal8, and monob; i.e., bgra was the only
  supported pixel format with transparency.

And here is how to test/create BMP with transparency (via PSP):
https://www.axialis.com/tutorials/tutorial-misc002.html
However, you should consider twice before using BMP today. BMP is (mostly) uncompressed therefore it wastes a lot of storage place.
PNG is one of the best formats around (too bad it does not support animation, like GIF).
There is also a new graphic format (WebP from Google) on the horizon, initially crated for web images. I can barely wait to be supported by common applications (MS Paint, Windows, programming languages, etc).
https://medium.com/beginners-guide-to-mobile-web-development/web-image-formats-googles-webp-17e2fe5fc53e

WebP is a modern image format that provides superior lossless and
  lossy compression for images on the web. Using WebP, webmasters and
  web developers can create smaller, richer images that make the web
  faster.

and

WebP lossless images are 26% smaller in size compared to PNGs. WebP
  lossy images are 25–34% smaller than comparable JPEG images at
  equivalent SSIM quality index.
Answer: Convert image to PNG to support transparency.
If photoshop cs3 does not show checkered background its not transparent.
The output or saved format decide whether you will see transparency.


is OPCODE applicable for sending ethers from wallet to another account?

Question: I know smart contracts are converted to bytecodes and they are executing OPCODES in the EVM. But I want to know, what OPCODES does Wallet to wallet transactions have?
Answer: OPCODES are also known as hexadecimal instructions that are mapped to human readable format.
There are number of EVM OPCODES available to use. You can even write an whole smart contract by using solidity in-line assembly. Which is hard to read and write but you can save alot of gas.
So anyways, I am sure you are familiar with it, the OPCODE to transfer ETH from wallet to another wallet is known as CALL.
Yes, people refer CALL, DELEGATECALL, and STATICCALL to low level function. But, in fact, they are one of few OPCODES EVM supports.
Link to solidity in-assembly docs.
You can read more about the call here.
You can read more about call vs transfer vs send here.
Tell me if it helps!


How do I find out how much free memory is left in GNU C++ on Linux

Question: I'm writing a C++ program (compiled with gcc and running on RedHat Linux).  The program needs to know at runtime how much space is left on the stack and how much is left in the heap.  I realize there may not be a definite answer to this question (about the heap), so alternatively, I could use the amount of memory already allocated from the heap instead.  Is there a a library/system function call that will give me this data?
I'd like to add that I only need this for debugging purposes, and only need rough estimates, so quick-and-dirty solutions are perfectly acceptable.  However, I need to query the memory usage very frequently, so shelling out to a Unix cmd-line utility and parsing its output is not acceptable.
Answer: You probably can create your own new and delete functions that encapsulates the real new and delete operators and take note of the memory usage at the same time.
For stack, there's a trick in C where you take a look at the address of the first local variable defined in your current function to get a rough idea about where the stack pointer is at the moment. I guess it should work in C++ but haven't tried it.
Answer: on linux you can read /proc/pid/status
Answer: Be aware that on 32-bit systems, the stack grows downwards and the heap grows upwards, and the two might meet somewhere in the middle.  The space might, therefore, be allocated to stack or to heap, but not to both at the same time.  Note that shared memory segments (if you use them) complicate the memory map.  So can dynamically loaded (shared) libraries.
+------------+
|    stack   | high addresses
|      |     |
|      v     |
+------------+
|            |
|   unused   |
|            |
+------------+
|            |
|      ^     |
|      |     |
|    heap    |
|            |
+------------+
|            |
|     bss    |
|            |
+------------+
|            |
|    data    |
|            |
+------------+
|            |
|    text    |
|            | low addresses
+------------+

On a 64-bit system, there is enough address space that you run out real and virtual memory before the collisions occur.
Also, note that (at least some versions of) Linux are willing to say more memory can be allocated than they can actually support - they over-commit.  That is not very good.  It means that practical experiments like trial memory allocations may give you a false sense of security.
Most likely, you are best off asking 'is the x MB (GB?) of space left', rather than 'how many MB (GB?) of space is left'.  Other people pointed to the /proc file system as a source of information for how much memory is in use.  I'm not sure whether it reliably tells you about how much memory is available to grab.
Answer: This is a C function to return the amount of free memory on the Raspberry PI.
It works by reading the /proc/meminfo. I'm not sure if it works for other systems.
#include <stdio.h>
#include <string.h>
// Return the amount of free memory in kbytes.
// Returns -1 if something went wrong.
int getfreememory()
{
  int returnValue;
  const int BUFFER_SIZE = 1000;
  char buffer[BUFFER_SIZE];
  FILE *fInput;
  int loop;
  int len;
  char ch;
  returnValue = -1;
  fInput = fopen("/proc/meminfo","r");
  if (fInput != NULL)
  {
    while (!feof(fInput))
    {
      fgets(buffer,BUFFER_SIZE-1,fInput);
      if (feof(fInput))
      {
        break;
      }
      buffer[BUFFER_SIZE-1] = 0;
      // Look for serial number
      if (strncmp(buffer,"MemFree:",8)==0)
      {
        // Extract mem free from the line.
        for(loop=0;loop<BUFFER_SIZE;loop++)
        {
          ch = buffer[loop];
          if (ch == ':')
          {
             returnValue = 0;
             continue;
          }
          if (ch == 0)
          {
              break;
          }
          if (returnValue >=0)
          {
             if (ch >='A')
             {
                break;
             }
             if ((ch >='0') && (ch <='9'))
             {
                returnValue = returnValue * 10 + (ch-'0');
             }
          }
        }
        break;
      }
    }
    fclose(fInput);
  }
  return returnValue;
}

Answer: You can check in the /proc namespace the files /proc/<pid>/smaps and /proc/<pid>/maps, where <pid> is the current process id.
Check this blogpost out.
Answer: Valgrind's Massif tool supports both stack and heap profiling. You may want to check its source code to see how it does it.
Answer: For the heap part, maybe you are hitting a resource limit. Check out this.
You may use Valgrind for stack profiling, but what are you going to do with it ? Stack is not like Heap. You say, you want to do this for debugging purposes. If your program runs fine, then there is no stack problem (related to its size at least).
You may set the stack size for the threads you created and inspect the stack pointer value by looking at the local variable (which must not be optimized-out) addresses. Just do some math by using the initial size, initial stack pointer value and current stack pointer value, you will get some nice numbers. Just do not forget to find out the stack direction first. This may change from platform to platform.
I think if you care this much for heap usage, then your program probably leaks memory. In this case, Valgrind can point you to the right direction. Valgrind
Answer: getrlimit with a paramater of RLIMIT_STACK will tell you how much stack space is there in total.
With a parameter of RLIMIT_AS you can find out how much virtual memory there is.
For more information look at http://linux.die.net/man/2/getrlimit


What is the definition of Building integrated photovoltaics?

Question: What is the definition of BIPV?
Building integrated photovoltaics emerged as a new way of reducing energy consumption. However, the question is how do these systems work?
Answer: "Building Integrated" can mean that the pv panels are the waterproofing roof layer in place of the roof tiles.
That is compared to pv panels mounted on the roof supported some small distance (10cm) above the existing roof tiles.
The pv panels work the same in either case as long as the roof integrated panels have sufficient cooling so that the performance is not degraded with the temperature (pv panels suffer from reduced output as their temperature increases).
Answer: Photovoltaics are build-integrated when they are part of the fabric of the building envelope itself, rather than modules which are mounted onto the external envelope.
BIPV can be roof tiles, windows or curtain-wall.
While they come in and out of fashion, they have been completely eclipsed by the growth in rooftop PV and utility-scale standalone PV, which now completely dominate the market, leaving BIPV as a small niche market. While it is conceivable that this could become a signicant growth market, it is more likely to remain little more than a rounding error in global PV figures.
Comment: In some places, integrating pv into the roof gives a higher grant from the authorities :) guess how I know...
Answer: BIPV works by converting light energy into electrical energy. The voltage output is usually connected to batteries and possibly by inverter to the national grid. Heat is an enemy of energy conversion in PV cells which means surface cooling is important.
Wind turbines similarly use voltage  inversion to convert energy to national grid power.
Answer: One of the most recent energy consumption methods is using PV panels in front of the buildings. In abbreviation, the system calls BIPV (Building Integrated PhotoVoltaic). The generated electricity in this type of system strongly depends on the outdoor conditions which could affect the temperature of the panel and consequently increase the efficiency.


Getting the Doctrine 2 ORM to hydrate objects with a custom query against a table with joins

Question: What I'm trying to do:
Execute a query with a haversine calculations against a table that also joins to other tables
What's going wrong:
The associations at the ORM level aren't working/hydrating properly with the approach I'm attempting, it would seem
The Details
I feel like if I cut and past every related bit of code, this question will become huge so I'm going to attempt to keep it to the relevant stuff.
First, here's the association mapping for the primary table being queried, which is issue
/**
 * @var IssueType $type
 *
 * @ORM\ManyToOne(targetEntity="IssueType")
 * @ORM\JoinColumn(name="type_id", referencedColumnName="id")
 */
protected $type;

Note: There are actually four other associated tables, but the one above is "failing first" so I'm hoping that if I can solve the problem for this one, I can do it for the rest
Now, working directly from this article and taking some tips from here, I'm trying to pull data from the issue table within a specified geographic radius. But, unlike the example in the article, my data is not flat in a single table.  Enter my custom finder in my IssueRepository class:
public function findNear( $em, $point, $radius=1 )
{
  $rsm = new ResultSetMapping();

  $rsm->addEntityResult('MyBundle:Issue', 'i');
  $rsm->addFieldResult('i', 'id', 'id');
  $rsm->addFieldResult('i', 'title', 'title');
  $rsm->addFieldResult('i', 'detail', 'detail');
  $rsm->addFieldResult('i', 'lat', 'lat');
  $rsm->addFieldResult('i', 'lng', 'lng');

  $rsm->addJoinedEntityResult('MyBundle:IssueType' , 't', 'i', 'type');
  $rsm->addFieldResult('t', 'name', 'name');

  $query = $em->createNativeQuery(
    "SELECT i.*
          , ( 3959 * acos( cos( radians(?) ) * cos( radians( i.lat ) ) *
            cos( radians( i.lng ) - radians(?) ) + sin( radians(?) ) *
            sin( radians( i.lat ) ) ) ) AS distance
          , t.name as type_name
       FROM issue i
       LEFT JOIN issue_type t
         ON i.type_id = t.id
      GROUP BY i.id, t.name
     HAVING ( 3959 * acos( cos( radians(?) ) * cos( radians( i.lat ) ) *
            cos( radians( i.lng ) - radians(?) ) + sin( radians(?) ) *
            sin( radians( i.lat ) ) ) ) < ?
      ORDER BY distance"
    , $rsm
  );

  $query->setParameter( 1, $point->lat );
  $query->setParameter( 2, $point->lng );
  $query->setParameter( 3, $point->lat );
  $query->setParameter( 4, $point->lat );
  $query->setParameter( 5, $point->lng );
  $query->setParameter( 6, $point->lat );
  $query->setParameter( 7, $radius, Type::INTEGER );

  return $query->getResult();
}

It's a bit messy right now, but I'm just trying to get this to work. The returned data from this query fails as soon as I attempt to pull an associated IssueType from an Issue object.
foreach ( $issues as $issue )
{
  // Fails, since Issue::getType() returns NULL
  echo $issue->getType()->getName();
}

This results in a

"Call to a member function getName() on a non-object"

error.
Now, I don't know the internals of Doctrine2 very well, so I don't know how this ResultSetMapping-based query differs from the queries I normally execute via the ORM.
Can anybody shed some light?
Versions

PHP: 5.4
PostgreSQL: 9.1
Symfony: Symfony 2.1
Doctrine: 2.3
Answer: probably (but I'm not sure) you have to describe the "meta column"
$rsm->addMetaResult('i', 'type_id', 'type');

Comment: I added this but it yields the same result. I'm assuming order-of-operation is irrelevant so I placed that line right before creating the query.


Flash buttons flicker continuously when compiled

Question: I am looking for some help with Flash (CS5 version). I have a situation where if try to put a button on the stage with visible differences in the up/over/down/hit states, when I compile the document into a .swf, the button will continuously flicker through each state in order very quickly. Also, if I break the AS3 code in the Main class file, hidden parts of a slider bar component will flicker between visible and not. I'm talking Japanese-style, seizure-inducing flicker here. I've searched my code for recursive function calls and tried deleting and re-adding components and buttons, but to no avail. Any ideas on what could be up?
Answer: Well, it seems to me you aren't using stop() to stop the button at the frame you want.
If it isn't this, then there is some error with your ActionScript, which will show up in the output panel, so check that.
Answer: When you say 'button' is it an instance of the Button Class and have you set the instance type to Button?
i.e.
Select the button in your library panel, right click and choose 'Properties'. Then set the Type to Button.
Next, select the instance of the button on the stage, open the Properties panel and just underneath where you type the instance name you should see a drop down menu containing MovieClip, Button and Graphic. Set it to Button.