Capacitive voltage divider with varactor

Question: Is it possible to create a capacitive voltage divider where one of the capacitors is a varactor whose capacitance can be manipulated/varied according to a signal? A varactor is a two port device; what would the circuit look like so the voltage control signal could vary the capacitance?
Answer: Yes as long as the net impedance ratio is not frequency dependant on other factors of inductance and load impedance sensing.
Actual impedance of every wire, source , load and stray impedance must be known with applied voltage across Varicap as modulation will average the attenuation in a log manner. So it is not a linear attenuating capacitance voltage transformer.
Switched cap bank with CMOS may be more linear, so it depends on use.
Answer: Typical varactor circuit has the control signal isolated by a high-value resistor or inductor, and a series capacitor (or another varactor, the opposite way) to block DC. There are dual varactors made for the purpose.
For example:

Where C2 and the BB804 dual varactor form a voltage divider, and V1 controls the capacitance.
(The reason for using a dual varactor rather than a single varactor is that the capacitance will vary with the signal voltage, causing unwanted side effects such as distortion if the signal voltage is relatively large. By using two diodes, that variation tends to cancel out, at least to the extent that the diodes are both matched and linear).
Comment: I expect the current that could be output by such a circuit would be tied to the absolute size of each "capacitor"?
Comment: The output impedance of the divider is the usual X1*X2/(X1+X2) where X = 1/(2*pi*f*C). So, yes.


Voltage Divider Bias

Question: I am new to biasing calculations and I cannot understand why in a voltage divider bias we can apply the Thevenin Theorem to find the potential in the transistor base. For example, here http://www.learningaboutelectronics.com/Articles/Voltage-divider-bias-of-a-BJT-transistor why is V in the base calculated as if the current though the base is 0?
Comment: ... THAT website strikes again! It really needs a health warning... (1) You can often live with the error caused by assuming Ib=0, provided you know the current in the divider is at least 10*Ib. (2) But you're right, it IS an error and the website ought to point that out.
Comment: I have seen here https://en.wikipedia.org/wiki/Bipolar_transistor_biasing#Voltage_divider_biasing a correct formula (I think :) ) How it is calculated? How to calculate correctly the potential at the base?
Answer: It is an approximation.
You typically work around the approximation by setting the current flow the two bias divider resistors be 10X what the maximum expected base current would be. Some folks like to use a higher ratio than 10X.
Comment: Ok. Thanks! But how would it be correct to calculate the voltage at the base? (without approximating the current to 0).
Answer: The voltage V of the Thevenin equivalent circuit is not exactly the voltage applied to the base, otherwise, the voltage at the base terminal, when the transistor is not connected, i.e., the Open Circuit Voltage.
The other important element to consider is the Thevenin equivalent resistance, so that the entire model line connected to the transistor circuit is completed.
This model allows to simplify the analysis of non-linear circuit. The condition for applying Thevenin's theorem is that we must "remove" the transistor from the circuit to calculate Thevenin's voltage.
The Thevenin equivalent resistance is the resistance "that the transistor sees" connected to its input terminals.
Based on the operating point of the transistor, through the base will circulate a certain current, which will produce a voltage drop across the equivalent resistance, applying the base voltage that would be measured in the real circuit.
Answer: "But how would it be correct to calculate the voltage at the base?"
Starting with the base voltage VB (against common ground) it is not a problem to calculate both resistors using Ohm`s law:
Top resistor R1=(Vcc-VB)/C*IB and R2=VB/(C-1)*IB.
C=Bias factor (usually, C=10, or larger).
The DC base voltage VB is VB=VBE-VE with VE depending on the emitter dc voltage VE=IE*RE.
Answer: Keep the formula for Ib on the wiki page in mind. You can calculate it by assuming the Vbe is 0.65 volts and beta (the transistor current gain) is about 100. You can calculate the Thevenin resistance Rt. You know the Thevenin voltage Vt, so the voltage at the base is $$V_b = V_t - R_t I_b $$ Is this close enough? It's easy to determine. Recalculate for Vbe of 0.6 and 0.7, combined with beta of 50 and 150. Using all three values of each variable will give you 9 different results. If the results are close enough together, you can accept the results. If this is not the case, you'll have to find a data sheet for the actual transistor being used, and use this to find, for instance, what beta and Vbe really are. Because both of these numbers are nonlinear and hard to characterize analytically (especially beta), you'll probably need to do an iterative process, where you plug in numbers and see how far off they are from being consistent over the entire circuit, then modify and try again. Computers are a really big help here.

Voltage Divider Bias


PhoneGap / Cordova 1.6 and dojo 1.7.2 AMD works from web, not from local?

Question: I have recently upgraded my PhoneGap/dojo1.6 app to cordova 1.6 and everything works just fine.
Then I upgraded to dojo 1.7.2 using hosted dojo: [script src="http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js" data-dojo-config="async: true"][/script]
And again, everything works fine.
But when I tried to use local dojo, much like I did when using dojo1.6 and cordova1.6, the dojo.js is found and loaded, but the app won't start/load other dojo module files.
[script src="dojo1.7.2/dojo/dojo.js" data-dojo-config="async: true"][/script]
I ended copying the entire dojo1.7.2 (didn't build anything), but still the app won't load and I get no error messages in the console.
Does anyone have any idea what might be the problem?
Thanks in advance,
Guy
Comment: Did you ever resolve this issue?
Answer: Try using the following config in your dojo [script src=]:
<code>data-dojo-config="async:false,parseOnLoad:true"
</code>
Also include the cordova.js file BEFORE the dojo.js file.


What adapter do I need: Philips Headset + Samsung S4 mini duos

Question: I would like to use the microphone of my Philips headset (SHO9567GB/10, iPod compatible) with my Samsung S4 mini Duos (i9192). Right now, the headset is only recognised as headphone. What kind of adapter do I need?
Answer: The in-line-mic only works for compatible Apple products. Apple always has something different than the standard and most Android devices use the opposite. I would like to see an adapter, but it would probably use an Apple patent. I think you're out of luck, but I'll update this if I find anything in the future. Next headphone pair you buy, I recommend you looking up if it's fully Android compatible.
P.S. If you in-line-buttons (volume and track control) to work, their are apps that convert one Android compatible button to work like the other few buttons using double clicking them. I recommend Headset Button Controller I am warning you that they get annoying because you have to have the play-pause button working as well as be able to spam the play button a number of times to get it to do volume-up for example.


The specified service does not exist (Win 7 x64)

Question: We have an application that installs and accesses a service on the machine.
On one machine, that is Windows 7 x64, it produces the following error:

System.ComponentModel.Win32Exception:
  The specified service does not exist
  as an installed service

The user is an admin user and I have installed it on other Windows 7 x64 machines without an issue.
The service is listed in the services.msc, and in the
HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services and is running under 'Local System'.
I have installed and uninstalled many times, checking to make sure that the service was uninstalled/reinstalled properly but the application still produces that error.
Any help would be appreciated!
Answer: I suspect you're getting hit with WOW64 Redirection - is your EXE a 32-bit EXE?


Minecraft 1.14 - how detect blocks at some distance from the player

Question: This will be my first question here about some work I would do for a world that I'm creating. Let's jump into the question.
EASY MODE
I would be able to detect if player is in "range" of a specified block (aka mycelium). If the player has a distance of max 1, I need to spawn some particles around the player. For now, I found a tedious way to do this, but it's not covering all the cases. At the end, I post some images that explain the area mycelium should cover and cases when detection must work. ATTENTION: there is no single block of mycelium. Almost all the world will be covered in mycelium!
How I achieve that now?
For every direction, i have a commandblock checking for player, in a clock. For instance, to detect a player on the top of mycelium I used:
execute as @a at @s if block ~ ~-1 ~ minecraft:mycelium run particle minecraft:happy_villager ~ ~ ~ 1 1 1 1 10 force

This will repeat for every variation. So if I want to detect one step forward or backward, I'll do ~1 ~-1 ~ or ~-1 ~-1 ~, moving the X or the Z coordinate.
Making this for mycelium, it takes for now 5 commandblocks in the clock, and it's not covering, for example, the block above, the corners and the block near, since it will add 6 more commandblocks.
So i started experimenting
I know there is a property of objects, called distance. I tried to put @a[distance=..3] or @s[distance=..3], but the command just stops to work.
And now I'm here
Since I lost many of my time searching, and since is all very confusing because of the 1.13/1.12/1.8 versions, I decided to post an official question.
FINAL OBJECTIVE (put all things I wanted to do toghether)
I want to detect if a mycelium block is 1 block away from the player, in every direction. If yes, I would be able to:

Play a sound sequence, made with other commandblocks, to that player (only for that player, or in that position)
Apply particle effect in that position
Poison and hurt the player

Mycelium will cover almost all the world, so I cannot test for only "specific" positions or make markers. EVERY single mycelium block must be detected, and if detected, must do that sequence of actions at least once.
Answer: There is no easier way than what you tried. @e and other selectors only work for entities, not blocks.
I have made a complicated system in the past that would allow you to do something similar, but (it's not updated to 1.13 and) it would need quite a bit of setup and would create much more lag than simply typing in the 27 commands for your system.


Differences between Arma 2 Free and Arma 2 Demo

Question: Trying to find more information about the DayZ mod, I learnt that the base game (Arma 2) appears to have 2 different 'free' versions, one enticingly labeled as 'Arma 2 Free' and also a seperate 'Demo' - however neither the official site nor Steam helped me figure out why anyone would go for the demo version.
To make things more confusing, the Steam download link for Arma 2 Free says 'Download Demo'. I'm aware that demo release was 2009 and Arma 2 Free was 2011; and the features not included in the free version.
So, what is the demo - and does the Steam download for Arma 2 Free actually install just the demo or the full 'Free' version that I could get from the developer's site?
Answer: According to this page, the free version is mislabeled as a demo.  So the "demo" is actually the free-version.
The difference between ARMA II and ARMA II Free is that Free has lower quality audio/textures, and doesn't have the single-player campaign.
Also, according to this page, ARMA II Free can be used to play DayZ Mod (you still need to purchase ARMA II: Operation Arrowhead).  That page also confirms that you get ARMA II Free using the "Download Demo" button in Steam:

Users on this page have confirmed that DayZ does indeed work with ARMA II Free.

Yes you can in fact download Arma 2 Free and buy Operation Arrowhead and install it to Arma 2 Free. Then you can already play [DayZ]
The free version has low resolution textures but people say it will work. Remember, there's no support for the free version, so if something goes wrong.. well you're kind of on your own.
Answer: The demo on Steam is Arma 2 Free. If you search Arma 2 Free on Steam, you'll notice that it brings you to the Arma 2 page. The only free download link on that page is the demo link. You'll notice when you click Download demo, it begins installing Arma 2 Free. It may have been something different before 2011.


Help in understanding frequency vs phase difference graph

Question: The following graph in my textbook plots the relationship of external driving frequency and phase difference of the driver and a system. From this question (Why dosn't amplitude increase when drive frequency is above resonance?) I understand that the amplitude  is maximum at the natural frequency because the system and driving force are in phase. Therefore phase difference is $0$ at $f_0$. Why does this change for when damping comes into the picture. In other words, why isnt $0=f_0$ for higher damping?
Answer:
I understand that the amplitude is maximum at the natural frequency
  because the system and driving force are in phase.

That statement is wrong.
Undamped systems a special case, and are different from damped systems because there is no work required to maintain a constant amplitude over time.
For a damped system, the maximum amplitude occurs when the driving force can do the maximum work on the system, and that is when the phase difference between force and displacements is 90 degrees. If the force was in phase with the displacement, the force would do positive work as the force and displacement both increase, but then do equal and opposite negative work as the displacement returned to zero, so the net work over a whole cycle would be zero.
In fact the general solution for an undamped system excited at is resonant frequency also has the displacement out of phase with the force, and the displacement amplitude increases linearly over time  (i.e. the displacement is something like $x = x_0 t \sin \omega t$). To maintain a constant amplitude at the resonant frequency, the applied force must be zero, and therefore "the phase angle between the force and displacement" is undefined.
For any other excitation frequency, the force and displacement in an undamped system are exactly in phase below the natural frequency and out of phase (phase angle $\pi$) above it.


Penetration testing and report submission should be done by a certified CEH or CISSP

Question: Is it essential that a Penetration testing and report submission should be done by a certified CEH or CISSP? Or any knowledgeable person who has expertise on security & tools can perform? If any person can do, the same can be accepted as per the compliance requirement of any standard such as ISO 27001, PCI-DSS etc.
Answer: There are so many different certifications, that global regulations cannot require one specific one.
Also, certifications vary widely in what they cover. CISSP does not prepare someone for penetration testing. CEH can be seen as too 'light'. The organisation that offers the CEH has a separate certification for penetration testers (LPT).
In the UK, there is CREST for pentesters, which is required for UK companies in some regulatory situations.
At the moment, for standards such as ISO 27001 and PCI-DSS, one just has to prove that the tester was 'qualified' to perform the test.
But never just do something because a regulation said so. They are not supposed to be "check the box" exercises where you do the bare minimum. They are a guide to help you do what's best for the business. The goal is to implement the best form of the regulatory requirement in a way that meets the business goals.
Answer:
If any person can do, the same can be accepted as per the compliance
  requirement of any standard such as ISO 27001, PCI-DSS etc.

Speaking specifically to PCI, the DSS states (for example):
<code>11.3.1.b Verify that the test was performed by a qualified internal
resource or qualified external third party and, if applicable,
organizational independence of the tester exists (not required to
be a QSA or ASV).
</code>
"qualified" in this case means "as determined by the QSA performing the audit."  I have performed penetration tests as a member of a company under PCI-DSS, and the auditors asked to see my resume, which included years of security experience, the CISSP, and a number of (non-Pentest) GIAC certs.  It was easily sufficient for them.
As with anything else under PCI-DSS, your mileage may vary based on your QSA.  And, going back to the wider question of other standards such as ISO 27001, the same is true... requirements for pen tester credentials are not generally codified in the standards, but rather left to the judgement of the auditor.


How to combine bumps and dimples?

Question: I'm working on a set of diagrams to try to make interesting math activities for positive and negative integers.  These diagrams look like this.

(This diagram would represent 4-3=1.  Later, I'll test this out to see if students actually see it this way.)
What I'd like to do is to create animations where the bumps and dimples combine and become a 'flat' surface.
My first attempt is just to have gray in the overlap zone, which isn't too bad.

What I'd like is to have the overlap zone more gradually transition from the bump through to the dimple.

Here's the basic Mathematica code I used to create these images.
Unit[θ_] := {Cos[θ], Sin[θ]}

Dimple[r_, ϕ_] := Translate[Polygon[Table[Unit[θ], {θ, 0, 360*Degree,
(360*Degree)/80}], VertexColors -> Table[Blend[{White, Black}, (1 + Sin[θ])/2], {θ, 0,
360*Degree, (360*Degree)/80}]], r*Unit[ϕ]]

Bump[r_, ϕ_] := Translate[Polygon[Table[Unit[θ], {θ, 0, 360*Degree,
(360*Degree)/80}], VertexColors -> Table[Blend[{Black, White}, (1 + Sin[θ])/2], {θ, 0,
360*Degree, (360*Degree)/80}]], r*Unit[ϕ]]

OverLapTable[d_] := Join[Table[Unit[θ] - {d, 0}, {θ, -ArcCos[d], ArcCos[d], 0.01}],
Table[Unit[θ] + {d, 0}, {θ, 180*Degree - ArcCos[d], 180*Degree + ArcCos[d], 0.01}]]

Graphics[{Gray, Rectangle[{-2, -2}, {2, 2}], Bump[0.5, 0], Dimple[0.5, 180*Degree], Gray,
Polygon[OverLapTable[0.5]]}]

Additional
This sort of a side view of what I'm hoping to accomplish,

with a smooth transition between the dimple and the bump.
Comment: Thanks for cleaning up the code, wuyud!  I didn't know how to do that.
Answer: One can try Opacity:
Graphics[{{Gray, Rectangle[{-2, -2}, {2, 2}]}, {Opacity[0.9],
   Bump[0.5, 0]}, {Opacity[0.9], Dimple[0.5, 180*Degree]}}]

Comment: That's not bad, but I was hoping for something that would transition a little better.

How to combine bumps and dimples?


postresql - How to recovery DB after system re-install

Question: I had to reinstall the system on my laptop and change ssd (C:). My postgres was installed on another disc (D:), this drive was fine and I still use it, but the Postgres client was deleted with system reinstallation.
i don't have any backup of DB.
Now I wonder if there is any option to copy/recover data from old postgres (I have all the folders)?
Can I install postgres in the same place it used to be on the hard drive (D:)? or it wont work or overwrite existing data ??
Answer: pg data is stored under D:\PostgreSQL\13\data unless you configured it elsewhere, backup the entire PostgreSQL\13 folder just in case, reinstall the same version and put the data back, should work


Reference for sheaf theory

Question: I was looking for a good book where to learn something about sheaf theory. I'm really a beginner with homological algebra :I know what homology is and what are derived functors but I do kot really know anything about derived categories etc. Is there a way I can start to understand   something about sheaf with my level of knowledge and where?
Comment: I'm not sure sheaves have much to do with homological algebra or derived categories. You can *do* homological / derived things to them, certainly, but if you want to learn about sheaves, it's not a book on homological algebra / derived categories you want. I learnt about sheaves and schemes from Vakil's online "algebraic geometry" notes: http://math.stanford.edu/~vakil/216blog/ .
Comment: Thank you. I said that becaus all the book I found about sheaves started with an higly cathegorical/homological approach, so I thought the two things were strictly linked
Answer: Very often, one use sheaf theory to prove theorems, so they are usually introduced in algebraic geometry textbooks. So book specifically devoted to sheaf theory are usually a bit technical.
I would say the best reference to understand sheaf cohomology is Forster, Lectures on Riemann surfaces. It introduces in a very down-to-earth way the first Čech cohomology group and deduce all the classical theorems of algebraic geometry (Riemann-Roch, Abel-Jacobi theorem, and other) using sheaf cohomology as a main tool. It's only for curves but it's already good.
Classical references are Serre's Faisceaux algébriques cohérents, and the book by Godement.
More modern references are Sheaves on manifolds by Kashiwara and Shapira (using analytic methods), and Sheaves in topology by Dimca (more oriented toward singular algebraic varieties and perverse sheaves).

Reference for sheaf theory


What is a permalink?

Question: I am working on a joomla project. I was asked to change the permalink of my site. What should I do and what is the purpose of doing it? Please help.
Answer: If you need a definition of this word then it is:

a permanent static hyperlink to a particular web page or entry in a
  blog.

If you want to know how to change permalink then here is the answer:

Login to administrator panel
Go in Menu Manager
If it is Article permalink then create new menu item from menu manager
Select Single Article as Menu Type and then Select your Article
Leave "alias" box blank it will automatically choose alias based on your Menu Item Name.
Click on Save Button.

You can follow the same procedure for other types of components like Category, Contact etc.
Comment: how can i change the permalink of a custom component
Answer: permalink is nice looking link to your article. Without menu aliases it will be less pretty, like example.com/component/content/1-article_alias but you can do many variants of pretty links, create alias for category where you displaying article plus create alias for that article, then you will have a pretty link like this example.com/category-menu-alias/article-menu-alias and that's help your viewers read the page, but seo won't get any advantage, because google index well links with ID and numbers.
regards

What is a permalink?


How to delete a building in pixel people

Question: Once I have a worker assigned to a building, how do I remove the worker so I can remove the structure?  You can't seem to fire workers and you can't delete a structure that has them. In this case I'd rather not have a stadium but an athlete is already in place.
Answer: I thought I'd share this here, to to answer half of the question in case people are still looking at this:

"A vital addition to the townscape, the building firm houses the
  blueprints required to replicate any of the structures sent down by
  the mothership. Buildings can also be deleted so long as they are not
  one of a kind. TRIVIA: The interiors department was founded by gifted
  designer Chen De'Liah."

From Building Firm - Pixel People Wiki.
Also, here's a screenshot from my game, showing that a message "Cannot delete the only building left" appears at the top when when I try to delete a building, of which I only have one:

So, while copies of a building can be deleted, the original cannot.
This is still true as of update 1.60 (Oct 23, 2013)
Answer: As far as I know, unless there is another place your worker can move to, you simply can't.
A good alternative would be to move the stadium as far away from the rest of your stuff as possible, but I believe that is the best you can do.
Comment: I've found that there is a "building firm" company that, once built, will allow you to replicate buildings or delete empty ones.  The interesting thing is that there seems to be no way to remove workers or send them back to be re spliced.


Why does Photoshop change the position of my PNG when creating a GIF?

Question: I'm trying to create a GIF using PNGs I made in Illustrator. Each of them have the same position and size but when I export it to Photoshop, the image position changes per frame. How do I fix this?
Comment: How exactly are you importing the PNGs in to Photoshop?
Comment: Run `pngcheck -v file.png` and see if there are ancillary chunks such as "oFFs" in the file.  I don't know if Illustrator adds such chunks.
Answer: Try bringing them into Photoshop this way:
Go to File > Scripts > Load Files into Stack:

In that dialog choose 'Attempt to Automatically Align Source Images':

That ought to get your layers all lined up for you...


Coin weighing puzzle

Question: We have 5 boxes with 20 coins each. And coins of three boxes weigh 10, one of them weighs 9 and the other weighs 11.
How can we differentiate between them by using a scale(digital, not the one with two cups) only once, with 1 unit accuracy?
Comment: Weigh them? *shrugs* This puzzle needs more restrictions to be meaningful.
Comment: @mr23ceec "using a scale only once"
Comment: Is it a balancing scale (two cups and one side is equal to the other) or a spring scale (one cup and it gives you a numerical answer, usually in a certain range)
Comment: One cup digital scale
Comment: each coin weigh 10 or whole box weigh 10?
Comment: Each coin weigh 10
Answer: Place 1 coin from the first bag on the scale
2 coins from the second bag,
4 coins from the third bag,
8 coins from the fourth bag
and 16 coins from the fifth bag
subtract 310 from the total, and the result will tell you which boxes contain the wrong coins. (it is I - J, where I and J are 2^n and n is the bag number)
Comment: So its kinda binary code?
Answer:
Assuming each coin weigh 10 for 3 boxes, 9 for another box, 11 for the other
  one.

This is pretty straight forward question. Just choose $0,1,3,7,12$ and this is also the minimum number of coins you can choose as well. You will get different $20$ results except the boxes with coins with the same weight coin.
Comment: Minimum number of coins if you take out and weigh coins. If you left off one box completely then weighed 4 boxes with coins removed from each box? I think that does it handling fewer individual coins.

Coin weighing puzzle


Is this possible(pythagorean triples)

Question: My maths teacher gave me some problems and one of them was that I have a right triangle with side 6 and area 30.. So my questions are: 1.Is this even possible and 2.should I assume that most of the time, a right triangle with side 6 would be egyptian (pythagorean triple)
P.S sorry if my sentence formation isn't top tier..
Comment: Yes, one leg is 6, so take the other side as 10 so the area is 30. I don't see why not. Unless the sides have to be integers (?)
Comment: Im not restricted to integers, but thought it would be something easier  since the other problems from the list were super easy..
Comment: @sedrick Also, thanks!
Comment: The only Pythagorean triple (integer sides required) with an area of $30$ is $(5,12,13)$. The only right triangle with one side of $6$ and an area of  $30$ is $(6,10,11.66190379)$
Answer: Two possibilities:

The side of length 6 is a cathetus (adjacent to right angle):  As the area is $30 = \frac12 c\cdot6$ where $c$ is the length of the other cathetus, there must be $c=10$.
The side of length 6 is the hypothenuse (opposite of right angle): The area is $30=\frac12h\cdot6$ where $h$ is the height of the triangle, thus $h = 10$.  Moreover, as it is a right triangle, the right angle is at Thales' circle which has radius $6/2 = 3$ around the middle of the hypothenuse.  As this circle does not intersect a line that is $h=10$ units away from the hypothenuse and parallel to it, no solutions from this case.

Is this possible(pythagorean triples)


What is the difference in Admiral Pike's Rank insignia and Capt Kirk's in Star Trek Into Darkness

Question: If you look at Admiral Pike's rank insignia in Star Trek Into Darkness, and then look at Captain Kirk's insignia, they look pretty much the same.  I am not able to really tell the difference.  Both of them have 4 pins of some sort on their shoulder boards.  The only possibility I can come up with is the spacing of them.  Admiral Marcus has 5 so it's easy to see the difference with his, and Spock has 3.
Answer: The rank seems to be indicated not only by the pips on the shoulder board.  It's a combination of that and their tunic.

The higher ranked Admirals (e.g. Pike and Marcus) have a white pillar on the front of the uniforms.

The lower ranked Captains/Commanders (e.g. Spock and Kirk) just have solid gray tunics.
So Admirals get 4-5 pips on the shoulder boards, plus white on the tunic.  Captains and Commanders get 3-4 pips on the shoulder boards, with no white on the tunic.
Answer: Besides the white front of the uniform tunic, admirals have gold shoulder insignia, while captains and below wear silver.
Answer: At the time of that pic above, Pike had been made Captain.  Marcus is an Admiral.  Kirk had been demoted in position but no one really stated that he had been demoted in rank (and unlikely given he had served with distinction in the first movie).  It was even a greater (strange) inconsistency when Admiral Pike (at the time) questioned Kirk's maturity (after the first movie - during the second). Just remember though, as stated in the third movie, "Admirals do not fly" and, so, that would suggest that Admiral Pike was demoted in rank to captain a starship.
Comment: Some of this is an answer to the question but referring to another answer to back it up and some of it is tangential conversation. Answers should try to be standalone. Could you [edit] this so it isn't referring to the other answer but is self contained, add a bit more evidence and clean up the tangential information?


Will Linux Boot Faster if I install it to My Hard Drive?

Question: I currently have a live usb of Linux Mint 14, and while I'm pretty happy with it, I just want to confirm, will it boot faster if I actually install it onto my hard drive? That would be the main reason I'd install it, because even as a live usb it works pretty well, it just takes a while to boot.
Answer: Yes, almost certainly. Unless you have a very fast USB stick, any hard drive will be substantially faster than using a Live USB.
Most USB sticks use fairly cheap flash that's not terribly fast, and rarely comes close to saturating USB 2 bandwidth. There are a few specialty USB sticks built for speed, which use USB 3 and effectively have SSD controllers, but they're pretty expensive.
Comment: Great, thank you! I'd love to get a usb 3 but I'm pretty sure my computer won't even support it anyways since I got it in the summer of 2008 and according to wikipedia, usb 3 came out later in november. Not a huge deal though, I'll probably just install it :D


Rule based prediction for known data

Question: Lets say we have trained our model on 900 records (training data) . During prediction on test data of 100 records, assume model produces 95% accuracy.
The question here is, can a mechanism be built, or is there already one, which does not go by prediction route if the data is already part of training data?
Reason for this question is, in real life customers get annoyed when model gives wrong predictions (5% error) for obvious or already seen data. The question is high level, so the critic suggestions are welcome, which can solve this real world problem.
Answer: Let's first assume a textbook version of the "data". OP's suggestion is easy to implement: one just need a map containing all the training instances as keys with the true answer as value.

First, there's the problem of noise and inconsistencies in the training data: if the exact same instance appears 8 times labelled as class A and 2 times as class B, the model will be wrong 20% of the time (more about this case below).
If there are any numerical features an/or many features, the space of all possible instances is potentially infinite and it's quite unlikely to find the exact same instance twice. This makes this solution rarely useful and questionable efficiency-wise.
On the contrary, if the training data almost completely covers the space of instances then it makes the model almost useless, the map is sufficient (possibly completing any missing instances in the training data).

Let's assume a balanced scenario where the distribution of the instances makes the map solution relevant. There is still the general problem of: what is exactly "the data"?
If we look at it from a standard ML perspective, the data is made of instances, with each instance made of specific values for every feature. But how is the set of features defined? It can be all the information available, or it can be a subset of the information available.

First, all the information available is not always all the information needed to make a correct prediction. For example the true answer might depend on the local weather at the customer's location, or whether the customer is in a good mood, etc. This information is not available. This can be the reason why the model makes wrong predictions even on instances seen in the training set. For a non-expert customer their environment feels obvious, as if the machine should know this.
Even if we assume that the information available to the model is sufficient to predict the true answer, there can be the case where the model ignores some features. Obviously this would happen with feature selection, but it can also be because some features are not informative enough or because they have too many different values which would cause overfitting. This is an important point: the model needs to generalize in order to make predictions for every possible case, and generalizing involves ignoring the details to some extent. This can also be due to the type of model, for instance linear regression cannot properly represent non-linear factors.
The model can even have more information than the customer. For example the model might exploit the time of an action to make its prediction: if the customer does the same action at different times, they might assume that they should obtain the same result as the first time but they don't. This is because the model found during training that statistically most customers at time A want result X while most customers at time B want result Y. Of course a few customers will not obtain the result they expect, because they don't realize that the model uses an information that they don't take into account themselves.

With all these examples I'm trying to show that "the data" is not so clearly defined in general, the customer and the model might have a different perspective about it: two instances which look the same to the customers may differ for the model and conversely. If possible, I think it's more beneficial to understand why such errors happen: it can be something which could be fixed in the model, or it can be something which has to be explained to the customer.

Rule based prediction for known data


How do I revert mesh to original in Edit mode after finalizing shapekey?

Question: It gets me every time.
I create new shape key, set value to 1.0 in Object mode , go to Edit mode and play with my mesh. Shape key is done and ready, I can see it working when changing shape key value from 0.0 to 1.0 in Object mode. But I have forgotten to rig my mesh and now Edit mode is locked with my last modification from shape key of 1.0. Is there any way to revert my mesh in Edit mode to the state when it is on shape key value 0.0 ? Or is there any way to prevent this situation from happening when making shape keys ?
Comment: Edit mode will show you whichever shape key you have selected.  If you want to go back to editing Basis, select Basis in the list.  The values of shapekeys does not affect anything in edit mode; the only thing that matters is which shapekey you have selected.
Comment: I had impression, that no matter what shapekey I selected Edit mode was always frozen, but now I tried it again, with moving shapekeys up and down, and Edit mode was refreshed, Thank You !
Answer: In object properties you should create two shape keys. Don't edit the first one. That's your base. Use the second to create your modified shape. Switch between them by selecting from the shapekey list in the property panel.
Comment: First shape key is named Basis by default, I don't edit it, I create another shapekey and edit it. Described issue happened when modifying non-basis shapekey, and when I switch between Basis and this shapekey mesh only changes visually in object mode, but edit mode is still locked in state of shapekey 1.0
Comment: Ok, You were right in the end, I must have not been selecting them properly before, thank You


Comparison between solid rocket fuels. Which are better by performance and cost?

Question: I am interested for a comparison of solid rocket fuels by their performance and cost. Comparison by specific impulse (Isp), energy that gives (which one is more energitic), density, cost to manifacture them, cost per kg (or pound), and also other elements if you could find. Comparing them in a table would be better. Even if there are included some of the values for these elements, it is still ok. For any further info that you will find later about them, you can edit the answer.
Comment: Its an interesting question though you could get a fair way by putting "comparison of solid rocket fuels" into a search engine. This would be a good way to refine your question - I'm sure there are folks here who'd be interested to help work through any problems you find. Please see http://space.stackexchange.com/help/how-to-ask
Answer: You will find this information in books and materials labeled mostly with "pyrotechnics". Here is a table that lists some of the common solid propellant combinations, and here is a online database. And here is a short historical overview of what came from where.
I don't think you'll find good cost data anywhere except shopping around for Estes motors by yourself, but I'd recommend looking around on Richard Nakka's excellent hobby solid propellant project pages.


How to store all Modifiers/Editors of a SharePoint list item in a variable using Power Automate Flow?

Question: I am trying to append each person who have modified a SharePoint list item to a variable, so there is a record of all Modifiers and I can use that variable in emails and Microsoft Teams posts. I am new to Flow and Power Automate and I can't seem to be able to figure this out. Any help would be appreciated.
Answer: Not sure if this would completely answer your question, as I don't know which fields are being updated in the SPList.
PowerAutomate:
Trigger: When SPList is updated
Send Email(?) with field: Modified By.
That is, if you want to received multiple emails every time the list gets updated.
PS There are other ways to do this with the Multi-line Text Column, however, you seem to want to send this information out of SP. You could also explore the native "Alert" feature in SPLists. How to set alerts on SPLists


BIG CRUNCH Theory

Question: Someday before i read about a article which explained about a phenomenon called BIG CRUNCH, according to it the way Big Bang happened because of which the remains moved away from one another forming universe planets and all other celestial bodies. In the same way some day the gravitational pull caused by each of these celestial bodies will drag each other celestial bodies towards it ending the universe by making it one, is this true can this happen?
Answer: To answer your question: yes it can happen.
Three major theories exist: big crunch, big freeze (or heat death), big rip.
Big crunch means everything is eventually crushed into a single point. Big freeze is that things get so far appart that "nothing" can happen anymore (except quantum stuff but that's another story), the universe becomes the most boring place in the ...hmm universe... Big rip means that eventually the fabric of time and space stretches so much that everything is torn appart (absolutely everything) in a rather short instant.
To simplify, they really depends on a ratio being smaller than 1, equal to 1 or greater than 1. Right now, the measurement of this ratio is that it's very close to 1... + or - a small quantity. But this small quantity makes all the difference. So until we can refine this measurement, we don't know. It's like keeping a pencil on its end: whether it falls left or right can depend on a very subtle initial imbalance. Right now, we say "it's sort of in the middle" which is not very useful!
Answer: The 3 major theories are Big Crunch, Big Freeze, and Big Rip. Each of them have
 reasons why they work and don't work. The future will shed some light on this, but for now it's just fun to talk about!
Big Crunch: Poetry of sort, the universe started with a big bang and will end collapsing into the same "infinitely" small point.
Big Freeze: Everything is moving away from everything else. Eventually things will be so far away that as stars blow up, reform, and the sources of hydrogen and other things that provide stars their fuel become more rare, things will eventually become colder and colder until there's nothing but ice cubes with no scotch to put them in.
Big Rip: I don't know much about this one, mostly because it doesn't seem to be likely from what I've heard others say. I'd suggest reading up on it on the wiki article (http://en.wikipedia.org/wiki/Big_Rip) or googling it.
You can see an episode from National Geographic that talks about these 3 theories here: https://www.youtube.com/watch?v=eYc8iRyL7YU
A short article on the Big Crunch: http://www.universetoday.com/37018/big-crunch/
A short article about Big Rip (includes some talk of the math that Godzy referenced): http://www.universetoday.com/22382/no-big-rip-in-our-future-chandra-provides-insights-into-dark-energy/
Answer: It is one of the three theory's they have on this moment about possible ends for the universe. So we can't be sure, they can't really test it yet and there is not enough evidence to mark it as true. It is just a logical answer to a question, but still only a possibility.
Comment: This is not really true. We can in fact test it. The ultimate fate of the Universe depends upon the average densities of its constituents. For "normal" matter and energy, if the density is above a certain threshold (1e-29 g/cc), the Universe would eventually stop expanding and start collapsing. It turns out that the actual density happens to be exactly this threshold, within measurement errors. However, it also turns out that the majority of the Universe is something that has a repulsive effect ("dark energy"), accelerating expansion. So it seems that we will expand forever, i.e. no Big Crunch
Comment: Currently all measurements are pointing towards Big Rip, however since scientist are debating on the nature and properties of dark energy some of the physicist proposed that gravity will win the race at some point in the future. That's is anyone guess so   cheer up drinks on me.
Comment: @user6760 That's not true; the measurements don't point any way in particular.
Comment: @HDE226868 see this [measurement](http://www.space.com/17884-universe-expansion-speed-hubble-constant.html) and [elimination](http://hubblesite.org/hubble_discoveries/dark_energy/de-fate_of_the_universe.php)
Comment: @user6760 *Space itself is pulling apart at the seams* $\neq$ Big Rip, and Hubble calls it "the most speculative".

BIG CRUNCH Theory


How can I build a scrollable, colored syslog viewer with less, ccze, grep?

Question: I'd like to view logfiles with colored output, scrollable and searchable. How do I do that?
I tried less /var/log/syslog | ccze | grep error, but it is not scrollable.
Answer: That's because you're doing it the wrong way around. It's less that is scrollable so that needs to be the last command in the pipeline:
grep error /var/log/syslog | ccze -A | less -R

The options used are:

-A, --raw-ansi
If one wants to enable raw ANSI color sequences instead of using
       curses, this option does just that.

This makes ccze use ANSI color codes instead of curses. While less can deal with ANSI escapes with the -R option (see below), curses are more of a problem. Using the -A option of ccze neatly sidesteps that issue.

-R or --RAW-CONTROL-CHARS
            Like -r, but only ANSI "color" escape sequences are output in "raw" form.  Unlike -r, the screen appearance is maintained
  correctly in most  cases.
            ANSI "color" escape sequences are sequences of the form:
ESC [ ... m
where  the  "..." is zero or more color specification characters For the purpose of keeping track of screen appearance, ANSI
  color escape sequences
            are assumed to not move the cursor.  You can make less think that characters other than "m" can end ANSI color  escape  sequences
  by  setting  the
            environment variable LESSANSIENDCHARS to the list of characters which can end a color escape sequence.  And you can make
  less think that characters
            other than the standard ones may appear between the ESC and the m by setting the environment variable LESSANSIMIDCHARS to the
  list  of  characters
            which can appear.
Comment: Unfortunately, that didn't work. Even worse, it freezes my terminal while giving random character output.
Comment: @user430 ah, yes, sorry. The `less` command needs the `-R` flag in order to interpret the color codes correctly. Also, `ccze` apparently uses ncruses output by default so you also need `-A` to disable that. Try the updated answer.


How can I test the menus in a GUI using ruby?

Question: I am trying to test a GUI using the Win32API through ruby.  I would like to test that the menus in the GUI are working correctly, but GetMenu returns 0, indicating (as I understand it) that GUI (written in MATLAB) is not using the basic Win32API menus.  I would like to avoid having to simulate mouse clicks at specific locations to select the menu if I can, and instead just call the menu automatically through the test.  Does anyone know what function/API I need to use for this?  Thanks
Answer: Start with UI Automation. It's not pretty though, I guess.
Answer: Does the menu use shortcuts (e.g. Alt-F,O for "open")?  If so, maybe you could just send those instead of simulating mouse clicks.


"Search on" versus "search for"

Question: Let's say I'm doing some research on something on Google. Do I say I'm searching on or searching for something on Google?
Answer: It's search for. In fact, this is the first time I see search on at all. And indeed, as a quick-and-dirty check, the Corpus of Contemporary American English has a measly 217 cites for "search on" (as opposed to 10.220 for "search for"). The British National Corpus has 39 and 2028 cites, respectively.
Comment: I think "search on" is perfectly normal usage where the particular search engine (or search facility within an application) is not a variable to be considered. In such cases, *"search on [some search text]"* might sound a little "technical" compared to *"search for"*, but it doesn't seem at all "odd" to me. Mind you, I don't have a problem with *"search with [some text]"* in that context either, so I'm probably a bit more liberal than most.
Answer: You're searching for something on Google, or you're googling something.
Answer: When regarding search in general, it is not uncommon to 'search on (field or criteria) to find  (desired result)'

Search on the 'Sent On' field to find email that was sent last March.

"Search on" versus "search for"


Error consuming a simple remote SOAP webservice from ASPX page

Question: I have a simple webservice running on a remote server that just takes a couple of strings and integers and updates a SQL Server database. I want to use it from a new ASP.NET web form.
So today I added the remote webservice to a project by adding an App_Webservice. I added the remote wsdl filename to the .NET project (in VS2005), and named the reference wsStoreData.  It created a folder called wsStoreData.
The webservice has a function called StoreRecentPage. Here is the simple page code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.Services;
using System.Web.UI.HtmlControls;

public partial class Training_FinalPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

       wsStoreData.StoreRecentPage("1", "11", 18, 100);
    }
}

The build fails with "The type or namespace name 'StoreRecentPage' does not exist in the namespace 'wsStoreData' (are you missing an assembly reference?)"
I haven't coded in .NET for a few years, so I may be missing something obvious to you. But I have looked at online examples and they don't seem to do anything different than I have done here.
Thanks for any suggestions.
Comment: It looks like your proxy class isnt quite right, try rebuilding your proxy; this is the class that is auto generated by visual studio.
Answer: You can try with this code
protected void Page_Load(object sender, EventArgs e)
{
       //Idon't know name of your proxy, but it's your generated class from your Wsdl after
       //adding reference
       var proxy = new ProxyWebService();//Replace with your proxy class
       proxy.StoreRecentPage("1", "11", 18, 100);
}

Comment: `ProxyWebService wsStoreData = new ProxyWebService();
        wsStoreData.StoreRecentPage("1", "11", 18, 100);` now gets a similar error that ProxyWebService does not exist in the current context.


How can a Windows process completely hijack the Audio output?

Question: The Windows application Discord glitched out and made it so that no other process is able to access the audio device. I wasn't able to play YouTube videos on any browser, play any music files, or use anything that requires the use of the audio device, unless I killed the Discord process. If I tried playing a video, the video would not play, and if I tried to play a song, The media player doesn't let me press the play button. How can a process completely hijack Windows audio? How does it stop other processes from utilizing audio output? Is there something in the Windows API that allows a process to take control of and lock an audio device, and prevent other processes from doing anything that make use of an audio device?
Comment: Nothing to do directly with the Windows API, everything to do with the audio driver, while Yes interacts with the API but something undefined happen.
Answer: Note: would have commented but didn't have enough rep.
It is possible for a application to take exclusive control of an audio device.
Right click the volume icon on bottom right corner > Playback devices > Click on the audio device that is being hijacked > Properties > Advanced
In the exclusive mode box, try unticking both boxes, and see if it solves your problem.


Minkowski product as Euclidean product plus spatial inversions

Question: In special relativity, we write contravariant and covariant vectors respectively as $$A^\mu=(A^0, A^1, A^2, A^3), \quad A_\mu=(A_0, A_1, A_2, A_3).$$ Since $A_\mu=\eta_{\mu\nu}A^\nu$, we read off the relationship between each component, choosing the signature $(+,-,-,-$$)$: $$A_0=A^0, \quad A_1=-A^1, \quad A_2=-A^2, \quad A_3=-A^3 $$ and thus $A_\mu=(A^0, -A^1, -A^2, -A^3)$ in terms of the contravariant components. But in order to have $A^\mu A_\mu=(A^0)^2-(\mathbf A)^2$ as we should, with this notation where the metric $\eta_{\mu\nu}$ has been 'absorbed' into one of the vectors, we need to use the standard Euclidean product:
$$A^\mu\eta_{\mu\nu}A^\nu=A^\mu A_\mu= (A_0, A_1, A_2, A_3)^T(A^0, -A^1, -A^2, -A^3)=(A^0)^2-(\mathbf A)^2.$$ Does this mean that going into Minkowski space correspond to staying in the Euclidean space, but inverting the spatial coordinates of one of the vectors?
Comment: You can write the metric as a matrix, in which case the inner product becomes $\tilde A\eta \vec A$
Comment: This way of thinking has similarities with the "ict" trick to avoid the Minkowski (and Lorentz-signature) metrics. It might work in some special cases, but I think you'll miss a lot of the physics. See https://physics.stackexchange.com/a/327516/148184
Answer:
we need to use the standard Euclidean product

I wouldn't call it a Euclidean product but rather the usual Einstein convention for summation over the repeated indices:
$$A_\mu A^\mu  = \sum_{\mu=0}^3A_\mu A^\mu = A_0 A^0 + A_1 A^1 + A_2 A^2 + A_3 A^3$$
This expression is the same in both Euclidean and Minkowski space. The distinction between them comes when you want to relate $A_\mu$ to $A^\mu$. As you correctly pointed out, in Minkowski this is done with the help of Minkowski metric and as a result you get
$$A_\mu A^\mu = (A^0)^2 - (\mathbf{A})^2$$
How you choose to interpret it is up to you: saying that

going into Minkowski space correspond to staying in the Euclidean space, but inverting the spatial coordinates of one of the vectors

is equivalent to just using the Minkowski metric. I am not sure that this interpretation is going to help you gain physical intuition, though. It's better to just get accustomed to using Minkowski metric.
Comment: I think a potential source of confusion is the fact that $A^\mu$ can be used to mean both the four-vector and a specific component. In my post, I wrote $A_\mu A^\mu$ as the dot product of a row vector and a column vector. Once you write the *vector* $A_\mu$ in terms of the *components* $A^\mu$, then the summation convention and the standard Euclidean product are basically indistinguishable, right? Then I agree with you that it makes more sense to just use the standard conventions in any practical situation.
Comment: Dot product of a row and column vectors is yet another way of representing the summation convention. Euclidean product is superficially given by the same formula because Euclidean metric is just a unit matrix. There might be indeed a confusion between vectors and components. Either you use index-free notation and write inner product as $A^T\eta A$ (like Charlie pointed out in the comment to your post) with $A$ denoting the vector itself; or you use $A^\mu$ and $A_\mu$ denoting components of a contravariant and covariant vectors respectively and inner product is $A^\mu A_\mu$ with summation.


Keys and major pentatonic, minor pentatonic or minor harmonic scales

Question: Are Keys with minor or major pentatonic and minor harmonic scales named differently or how do you discern the scale based on the key if it's pentatonic or harmonic instead of natural?
Answer: The key is more about the tonic than any scale. A key is not pentatonic or natural or Dorian or harmonic or melodic. A key tells you two things: (1) a note name giving the home note i.e. tonic, and (2) the type of the home chord i.e. tonic chord, is it major or minor. The major/minor thing does not mean a list of "allowed" notes, it means the harmony around the home note.
Since the tonic chord already specifies the tonic note, we can simplify the formula of key as:

KEY = TONIC CHORD

... and accordingly, the name of the key follows the name of a basic chord. "This song is in A minor." A minor, the chord, not A minor, the scale.
When you're told that a song is in a key, it is to let you know what the prominent home note is, and whether the home chord is a major or minor chord. A wide variety of different scales and harmonies may be used, and the harmony may be almost anything during the song, changing and mixing harmonic feelings from different scales back and forth, but as long as the home chord stays the same, it will be in the same key.
However, you can assume a default reference scale based on the key. The reference scale is the notes you get from the key's key signature. For example if a song is said to be "in A minor", then you can assume the A minor natural scale as a basic reference grid to which you relate the song's actual harmony. For example if there's an A major chord somewhere in the song, you'll note that as a somewhat remarkable point, because an accidental is needed for writing the C# note.
This has been asked countless times, and new askers keep appearing endlessly. I think the difficulty of understanding the concept of key comes from the tonic being "invisible". You have to feel the tonic, i.e. when the melody feels to be at home. You have to actually hear the music.
Comment: Great answer. I think a mention of the dominant - which often leads to the tonic - is worthwhile. Particularly in minor keys (in majors, it's almost a given), where the very note that makes the dominant a proper dominant isn't even shown in the key signature!


Recommended sidebar / content widths

Question: I'm developing my own theme. Does WordPress recommend or require a minimum or maximum when it comes to the width of the content or sidebar elements of an post, page or archive page? If not, are there any unofficial guidelines?
Answer: There are no recommended sidebar widths, however there are LOTS of plugins that make assumptions about this (especially those that handle advertisements).
If you plan on running ads, please check the ad width requirements and use that as your baseline. For example, if you are running AdSense ads and the ad requires 300px, then make sure that sidebar has a minimum width of 300px or your might break your layout or the ad might not show.
This can be tricky with responsive or fluid layouts, but being aware of it is half the battle.
Comment: Thanks for the clear answer! I'll wait with accepting to see if there are others with something interesting as well.

Recommended sidebar / content widths


Dell Inspiron N5110 Keyboard & Touchpad

Question:
                                                                    I have Dell Laptop " N 5110 "

How do make 2 finger scrolling work + 2 fingers zoom in & zoom out work
How to Fn + f3 To lock touchpad
How to configure 1 2 3 as shown in pic
3.1 For Ubuntu Software Center
3.2 For System Settings
3.3 For Screen Off

How can I configure the touchpad and keyboard settings on a Dell Inspiron 5110? Nothing Work & i did google but find nothing
 xinput list
⎡ Virtual core pointer                             id=2 [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ PS/2 Generic Mouse                        id=13   [slave  pointer  (2)]
⎣ Virtual core keyboard                          id=3   [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Video Bus                                 id=7    [slave  keyboard (3)]
    ↳ Video Bus                                 id=8    [slave  keyboard (3)]
    ↳ Power Button                              id=9    [slave  keyboard (3)]
    ↳ Sleep Button                              id=10   [slave  keyboard (3)]
    ↳ Laptop_Integrated_Webcam_HD               id=11   [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard              id=12   [slave  keyboard (3)]
    ↳ Dell WMI hotkeys                          id=14   [slave  keyboard (3)]

Comment: Did the answer posted help you with the touchpad problem??
Comment: yes  > os.system("xinput --set-prop 'PS/2 Generic Mouse' 'Device Enabled' $(if [ $(expr `xinput --list-props 'PS/2 Generic Mouse' | grep 'Device Enabled' | cut -f2 -d :`) -eq 0 ]; then echo 1; else echo 0; fi)")  > check the 2nd answer as well
Comment: Did you manage to make the scroll work on your touchpad? As I see the script only makes the touchpad stop.
Comment: Consider this answer here: http://askubuntu.com/a/199587/44254
Answer: 1. How do make 2 finger scrolling work + 2 fingers zoom in & zoom out work
there is an application called Touchegg but it is having issues with 12.04 and need to be fixed. So at this time, it won't do the job you want.
Touchegg is designed to bring multi-touch (touchpad) functionality to Linux based operating systems. In layman's term, it is an open source multi-touch gesture recognizer for GNU/Linux which is backed by C++, Qt and uTouch-geis library. With TouchEgg, you can define what type of actions are to be initiated for a specific multi-touch gesture.
for more info have a look at my answer. I have guided through whole process.
2. How to Fn + f3 To lock touchpad?
Use application named AutoKey.
You can bind any key to any script or abbreviation.

AutoKey is a desktop automation utility for Linux and X11. It allows
  you to manage collection of scripts and phrases, and assign
  abbreviations and hotkeys to these. This allows you to execute a
  script or insert text on demand in whatever program you are using.

Latest version is v0.90.

Where to get this? it is in the ubuntu's repository!

Open software center > search for autokey > install AutoKey(GTK)

How to use this?

Open AutoKey.
Step 1 : Press Ctrl+Shift+N or from File > Create.. > New Script. Rename with whatever you like.

paste below code as shown,
import os
os.system("synclient TouchpadOff=$(if [ $(expr `synclient -l | grep TouchpadOff | cut -f2 -d =`) -eq 0 ]; then echo 1; else echo 0; fi)")

Then in bottom-right corner there is three Set buttons to set for Abbreviation or Hotkey or Window Filter. Click second Set button (because we want to set hotkey).

Click Press to Set and hit a key you want to assign(in your case fn+f3. I'm hitting fn+f1).
Click OK.
Click Save in bottom-right corner.
Now you will see your hotkey in left panel in HotKey column (in my case there is weird key like I because I have assigned fn+f1).

you have set hotkey for touchpad to enable/disable ( I have coded to make it toggle rather than just use to lock it. Perhaps you'd like it :-)  ).
3.1 For Ubuntu Software Center
==> Go to Step 1 described above.
just use this code when you paste.
import os
os.system("/usr/bin/software-center %u")

and set hotkey for 1 you have shown in screenshot.
thats it you have bound 1 for Software Center.
3.2 For System Settings
==> Go to Step 1 described above.
just use this code when you paste.
import os
os.system("gnome-control-center")

and set hotkey for 2 you have shown in screenshot.
thats it you have bound 2 for System Settings.
3.3 For Screen Off
==> Go to Step 1 described above.
just use this code when you paste.
import os
os.system("xset dpms force off")

and set hotkey for 3 you have shown in screenshot.
thats it you have bound 3 for Monitor off.
Comment: Does this make the scroll to work on alps touchpads, or it is just an option to turn off the touchpad?
Comment: it turns off and on touchpad (like toggle keys).
Answer: Very helpful instructions.
Unfortunately I run into problems with synclient (Couldn't find synaptics properties. No synaptics driver loaded?) so I looked for an alternative script for AutoKey and found the instructions in this thread very helpful. I just replaced the line starting with os.system with the following:
os.system("xinput --set-prop 'PS/2 Generic Mouse' 'Device Enabled' $(if [ $(expr `xinput --list-props 'PS/2 Generic Mouse' | grep 'Device Enabled' | cut -f2 -d :`) -eq 0 ]; then echo 1; else echo 0; fi)")

Answer: Touchpad scroll issue fixed
I really appreciate  "Dave Turvene"'s great contribution for his driver and also thanks to garyF for his script.
It fixed by touchpad scroll issue on Dell inspiron 5720 running Ubuntu 12.04.
Few extra steps i did to make it work.
Here  are my steps to make the drivers and script run.

1) After you extract psmouse-alps-dst-0.4.tar to /usr/src (on command prompt go to /usr/src/psmouse-alps-dst-0.4).
2) `sudo chmod u+=rwx install.sh`   (give execute permission to install.sh)
3) `sudo gedit install.sh`
4) add    #!/bin/bash     (if using bash shell , which is the default shell)
5) `sudo ./install.sh`
[If you get some error. You might need to install dkms to make the script run]
[`sudo apt-get install dkms`].

6) the script will run and build the source.
7) after its completes you will get the message
"DKMS: install completed.
rmmod psmouse, wait=no
insmod /lib/modules/3.5.0-23-generic/updates/dkms/psmouse.ko
MAIN: Done installing. Go to System Settings > Mouse and Touchpad to configure :-)"
8)In Ubuntu 12.04 click Dash Home in Launcher bar.
9) Then type mouse.
10) click the "Mouse and Toushpad" application.
11) click the "Touchpad" tab.
12) select "Two-finger scrolling".
13) close the application and you are all set.

Comment: thanks for adding the executable permission part... forgot to mention it :-) that can be overcome by using
`sudo bash install.sh`
but i didn't know that dkms needs to be installed. isn't it bundled with ubuntu install?
Answer: I found a very useful driver made by Dave. I thank him cos I too have an N5110 and damn the Dell doesn't want to help
Here is the quick installation link to it.
You need to extract and copy the folder in /usr/src/ and then run install.sh with root permission.
It's not complete but at least you will get edge scrolling, dual finger scrolling and be able to turn it off/on with Fn+F3.

Dell Inspiron N5110 Keyboard & Touchpad


Storing / Retrieving App Data Online using Android

Question: I am new to Java and Android. I am just beginning work on an app that will save information to a server that someone else from within the same company can retrieve using the same app from a different android device. I know how to simply store data on a server using simple php scripts but this is a bit more complex and involves one user writing information to the server, while another user can see / download it. Within a company there would be multiple users who have acceess to this data. So my question would be, whats the best way to implement a company-wide database that ONLY members of the same company can have access to? Sorry if this seems obvious to some of you. I am just getting started and I have 7 books on android programming and none of them describe how to do quite what I am trying to do.
Comment: http://www.gen-x-design.com/archives/create-a-rest-api-with-php/
Answer: To do this you need to use Android network services to access data. In other words to retrieve a networked database information your device will connect to your service with a specified URL and arguments. In turn, the service will reply with the required data, say may be in XML format. All your app needs to do is parse the XMl and display the date as desired.
Same thing applies to putting data into the server, in this case however the data will be sent as arguments to the network service URL and the service will handle the persistence to a database.
My advise is to do a Google search of the keyword "Android Network Services".


Salesforce ISCHANGED(field) Documentation

Question: Is there a FORMULA FUNCTION that is case sensitive? ISCHANGED(field) is not a case sensitive function I found from testing (Documentation is pretty vague on that). Is there a FORMULA Function that will work with for this or do I need to have this process builder use some APEX code where I know I can get this done?
Answer: String comparisons are almost always case-insensitive on the Salesforce platform. The only way I'm aware of to do case-sensitive comparisons in any context is the Apex method String.equals(). Even in Apex, the standard == operator is case-insensitive.
Comment: You can get case-sensitive comparison in Apex via === as well, but has a silly restriction; you have to cast one of the strings to an Object: `String a = 'hello', b = 'Hello', c = 'hello'; System.assert(a !== (Object)b); System.assert(a === (Object)c);` This avoids the typical NullPointerException problem using String.equals.
Comment: It's a trick unique to String values. It works because the system uses Java's String Pool implementation. When a string is constructed, the system checks to see if that string is already in heap, and if so, returns the existing string instead of using more memory.
Comment: @sfdcfox does that work with values other than string literals? It seems at odds with the object identity semantics in the doc, but that's a new wrinkle to me.
Comment: Ahhh. Got it. Objective-C does something broadly similar, but it only works with compile-time literals. (I never got into Java). Thanks!
Answer: This is an old post, but figured I'd share in case it helps others. You have a couple options with formula fields and flow:
Use a Boolean formula field to say record field 1 != record field 2, which can then be applied to decision nodes. Example: {!$Record.PersonMailingCity} != {!$Record.PersonOtherCity}
I believe the FIND() function is case sensitive. So you could say find field 1 in field 2 conceivably. I think the first option is a little easier to follow though.


Text on Path Illustrator

Question: I wanted to put the text inside the triangle path. I tried but the text is not guite readable. I want something like on picture I provided.
Answer: The example you give is not an instance of text on a path, but rather regular point text being skewed.

type your text, for example, 'EXHIB' in your example
select it with the black arrow tool (V) if it isn't already
choose the Shear tool, possibly 'hidden' under the Scale tool (S)
click and drag into the desired shape or double-click the shear tool to enter a degree value
repeat with 'ITION' with the inverse angle.

Text on Path Illustrator


Ember acceptance test not seeing updated DOM

Question: I'm still getting into the depths of Ember's acceptance testing. One issue I seem to keep having is the DOM not getting updated after an event. For example, my page has a side menu. A simple toggle changes a property in it's component which then toggles a "hide" class on the menu itself:
Component
import Ember from 'ember';

export default Ember.Component.extend({
  menuHidden: true,
  actions: {
    toggleMenu(){
      this.set('menuHidden', !this.get('menuHidden'));
    },
  }
});

Template

  {{#link-to 'dashboard' invokeAction='closeMenu'}}Dashboard{{/link-to}}
  {{#each menu as |child|}}
    {{menu-child child=child createCase=(action 'createCase') menuHidden=menuHidden}}
  {{/each}}
  Logout

Acceptance Test
import { test } from 'ember-qunit';
import moduleForAcceptance from '../helpers/module-for-acceptance';

moduleForAcceptance('Acceptance | side menu');

test('side menu opens and closes', assert=>{

  logIn('firstname.lastname@example.com', 'password');

  andThen(()=>{
    assert.equal(find('#menu').attr('class'), 'hide', 'Hidden by default');

    click('#menu-toggle');

    andThen(()=>{
      assert.equal(find('#menu').attr('class'), '', 'Now visible');
    });
  });

});

Now this is running fine in the browser. The test is logging in fine with my custom helper (the menu is only visible when logged in) and if I drop a console.log into toggleMenu() it is being triggered by the test. But it fails the last assert. I've done a console.log on the menu's wrapper's HTML before the last assert, it's still seeing the #menu element with class=hide
Is there something obvious I'm doing wrong? I can't find many examples of people with multiple andThen calls in acceptance tests, so I've tried having it nested - as above - and pulling the second andThen out inline with the first one. No difference.
Answer: If you open the developer console in the test browser window, you will likely see this error:
Assertion failed: You have turned on testing mode, which disabled the run-loop's autorun. You will need to wrap any code with asynchronous side-effects in an Ember.run

The following line in your component is considered code with asynchronous side-effects:
this.set('menuHidden', !this.get('menuHidden'));

Instead, for the test to work, you need to manually add the line to the run-loop, which is achieved by adding that line of code in an Ember.run, like so:
import Ember from 'ember';

export default Ember.Component.extend({
  menuHidden: true,
  actions: {
    toggleMenu(){
      Ember.run(this, function(){
        this.set('menuHidden', !this.get('menuHidden'));
      });
    },
  }
});

This will not affect the actual running code as the operations in your Ember.run will get merged into the main run-loop.
I had a similar issue which I managed to resolve after going through the steps mentioned in here


ASP.NET embedded code expressions

Question: The below code works but I am not sure how?
OnClientClick='<%# CreateConfirmation(Eval("EventName"),DataBinder.Eval(Container.DataItem, "EventDate", "{0:ddd, d MMM}")) %>'
Public Function CreateConfirmation(ByVal EventName As String, ByVal EventDate As String) As String
        Return String.Format("return confirm('Are you sure you wish to register for {0} on {1} ?');", EventName, EventDate)
    End Function
I have read that <%# %> is a databinding expression, but overhere we are not directly data-bidning (infact returining value from the function CreateConfirmation) and I also thought that it should work with <%= %> but it gives JavaScript error message i.e. Illigal XML character
pointing to =
Please could you clarify as to why is this?
Many Thanks.
Answer: This question is very precisely answered in an exisiting post:
Why will <%= %> expressions as property values on a server-controls lead to a compile errors?
Answer: You can call any code inside the <%#. The Eval bit is the piece that makes it relate to the row/object in the datasource.
Answer: You are still binding the returned string to the property. You can only use <%=%> with inline HTML. You have to use <%#%> when binding to a contols property.

ASP.NET embedded code expressions


Is cumulative sum large deviation an alarm for bad normal pseudo-random number generator?

Question: Given a pseudo-random number generator of standard normal distribution, I generate a matrix $(z_{t,n})_{(t,n)=(1,1)}^{(T,N)}$ of samples. I computed the mean of the cumulative sum, i.e., $\displaystyle s_t = \frac1N\sum_{n=1}^N\sum_{s=1}^tz_{s,n} $. The expected standard deviation of $s_t$ should be $\sigma(s_t)=\sqrt\frac{t}{N}$. However, for $(T,N)=(600,4000)$, I have several $|s_t|$'s exceeding $2.5
$-$3$ times $\sigma(s_t)$. Does this indicate the pseudo-random number generator is bad?
Answer: Your $s_t$ should be normally distributed. If a variable is normally distributed, you expect it to fall more than $2\sigma$ from the mean 4.5% of the time, and more than $3\sigma$ from the mean 0.27% of the time. So having "several" values beyond these bounds doesn't indicate that your RNG is bad.
To be more rigorous, you need to say exactly what fraction are exactly where. The formal way to do this is with a Kolmogorov-Smirnov test, and you should definitely do one if you are suspicious of your generator. In fact, there is a massive battery of tests that are traditionally run on RNGs. See, for example, the dieharder tests.
Comment: That said, usually test RNG test harnesses are run on new _uniform_ RNGs. Nonuniform RNGs are then constructed from uniform RNGs via established algorithms (Box-Muller, Ziggurat, etc.) If you are using an established uniform RNG, and an established nonuniform transformation algorithm, I would be satisfied with a cursory check of your code (e.g. your original KS) and would be very surprised to find new effects in higher-dimensional tests.
Comment: Thank you for the answer. I am aware of all you have said except the Dieharder test suite. The Kolmogorov-Smirnov test is best performed on the original sample itself rather than $s_t$. I was wondering if there was anything gained from examining the cumulative sum instead of the sample themselves. I was not clear about it in this question. I actually asked about the normality and independence test in another related question https://stats.stackexchange.com/q/280610/44368. I would very much like to hear your opinion there.
Comment: Yes, there is something to be gained by doing a KS test on this transformed data. Your n will not be as high as for the original data, but you will be testing for serial correlations (non-independence) that show up as distortions in multi-dimensional distributions constructed from the original distribution. Essentially all the RNG test harnesses work this way, often constructing distributions in 10s-100s of dimensions with known, testable properties.


What are some tools available for drawing good figures for computer science research papers and presentations

Question: What are good choices to create figures in computer science research papers? Not talking about graphs here, just block diagrams and simple illustrations. For example, what is the tool that can be used to produce this figure?
Answer: Personally, I am a fan of the TeX-Package TikZ. It is easy to draw simple diagrams, include small pictures or create structures by using loops and conditionals.
It also supports relative positioning, which makes everything a lot easier than manual placement.
Since all of the input is plain text, it works great in combination with source control (e.g., git) and prior versions can easily be reverted back to.
I have to mention it takes some time to get used to the syntax, but the folks over at the TeX Stackexchange are usually very helpful. They have a great showcase of scientifc pictures, too! https://tex.stackexchange.com/questions/158668/nice-scientific-pictures-show-off
When images from other documents are to be included, I usually crop them out as vector graphics from pdfs by using Libreoffice Draw. With both tools in combination, I often get satisfying results since everything remains vector graphics for the entire diagram if i wish to.
Comment: You said "easy". It is not easy. Fun, I agree, but it is quite tricky and I have limited my use of it to above cases after using it for a while.
Comment: Tikz is all but easy to draw diagrams with. I use it for highly regular, "programmable" diagrams or diagrams that need "programmatic" updates from time to time. It is not useful for quick diagrams. Other than that, Inkscape, or Ipe, or if one feels really retro, Xfig, may be more useful.
Comment: I never said anything about quick ;)
Answer: My combination:

Excel
PowerPoint

With those, you have smart art which allows you to get things done really fast but larger graphs get painful. For those I use:

draw.io

draw.io has good diagram capabilities and it is fast to learn. Sometimes there are some things that cannot be done with those. If everything else fails:

Latex equation editors
Snipping tool
Paint

With the snipping tool, I bring elements to paint from example latex equation editor or some graphs or whatever the visualization needs. I think some real professional software might be better than Paint but it is hard to justify those expensive licenses for a few pictures a year. You can probably replace the Office programs with free ones but these are the programs I use.


Giving players items based on score

Question: I have a scoreboard objective called ammoCount. That is how I am tracking the amount of ammo players have, but I would like to put some items in the players' inventories to show them how much ammo they have. So, if a player has 10 ammo, they will have 10 blocks in their inventory, if they have 64 ammo they will have a stack of blocks, and if they have 65 ammo they will have a full stack plus an extra. Is this possible?
Comment: I'm sure it's possible, but quickly thinking about it makes me think it would be very complicated.
Comment: Somehow encode score into binary(https://www.youtube.com/watch?v=WehfW3JGpf0) and assign each digit to multiple objectives and give 1, 2, 4, 8, etc amount of item accordingly.
Answer: There are two ways you could do this. The first method would involve one command block for each amount of ammo, but would be fast to update. The second method would be slower to update, but would work for any amount of ammo with just a few command blocks.
METHOD ONE
Say you're using iron blocks for ammo, you should set up any clock with this command first:
/clear @a iron_block

Which will clear the player's inventory of any iron blocks. Immediately after this on the clock, have one of these command blocks for each possible amount of ammo:
/give @a[score_ammoCount=1,score_ammoCount_min=1] iron_block 1
/give @a[score_ammoCount=2,score_ammoCount_min=2] iron_block 2
...

You could use an MCEdit filter such as this one to quickly create all of the command blocks you need. The faster the clock, the faster it will update. You can have it updating the player's inventory 20 times a second with a /fill clock.
METHOD TWO
The second method is to:

Create another objective, say "ammoCountTemp"

    /scoreboard objectives add ammoCountTemp dummy

Set everyone's ammoCountTemp to their ammoCount

    /execute @a ~ ~ ~ /scoreboard players operation @p ammoCountTemp = @p ammoCount

Give everyone with at least 1 ammoCountTemp an iron block

/give @a[score_ammoCountTemp_min=1] iron_block

Decrement everyone's ammoCountTemp

/scoreboard players remove @a ammoCountTemp 1

Repeat from step 3 until nobody is being given iron blocks

Wait a while, then start again from step 2

As I said, this is much slower. I'd only recommend this if you are going to be having huge amounts of ammo available.
Comment: Method 2 worked well, but I modified it a bit so that ammoCountTemp is modified when the player shoots/collects ammo, then ammoCount is updated to match it. As it is updated, blocks are added/subtracted.
Comment: yep, about as complicated as I thought it would be.

Giving players items based on score


Dealing with anger

Question: What is a good sefer or even book that helps people with a problem with getting angry?
Comment: Answers to this question would be most useful, I think, if accompanied by a testimonial of having personally found the book useful.
Answer: The range of sources that discuss anger in Jewish tradition is huge.
There is a sefer I saw called Haser Ka'as Milibecha, (Translated as "Remove Anger from Your Heart"), a classic mussar work compiled by Rav Avraham Tubolsky, shlit"a.
Gan Emunah (available in English as "The Garden of Peace") discusses it, and I bet Gan HaShalom does as well. Bilvavi Mishkan Evneh (Available in English as "Building a sanctuary in your heart") also discuss this.
Oroḥt Zadikim discusses it (but to take full advantage of that sefer, you have to have an understanding of how to learn mussar), and Alei Shur provides exercises regarding anger (and lots of guidance about the mussar derech in general, and lots of exercises for improving other middot as well -- this can help with using Oroḥt Zadikim).
The hard part isn't finding books or reading about it -- it's internalizing what the books have to say.
Comment: +1 for Haser Kaas Milibecha. It is the best, and it is one of my rebbeyim who authored it. It is downloadable for your Kindle reader, and you can find it [here on Amazon.com](http://www.amazon.com/dp/B005JVSHKU) for only $9.99.
Answer: There's a book by Rabbi Zelig Pliskin called 'Anger: the inner teacher', it's very clear and set out step by step.
Comment: Abi, Welcome to mi.yodeya, and thanks very much for referencing this potentially useful book! We'd love to have you as a fully-registered member which you can accomplish by clicking on "register," above.
Answer: I recall a sefer called (I think) Erech Apaim.  In addition, working on middos such as ga'ava and bitachon would be useful.
I didn't think of it as a Hebrewbooks type of sefer, but here it is.
comment: actually. there is an english translation here:
http://dafyomireview.com/article.php?docid=247
Comment: I heard about it is it available in English
Comment: I doubt it since I haven't seen it widely circulated, though I recall that it is easy Hebrew.  I don't remember the name of the author.  I do remember part of his intro:  He says the reason that Korach was wrong and that a Techeiles Talis still needs a techeiles pesil and a room with sifrei torah still needs a mezuza is that they require an exclusive mnemonic to accomplish their purpose (the pesil/mezuza).  So too, working on anger requires an exclusive approach and general middah perfection will only go so far.
Answer: The Dance of Anger. The subtitle shouldn't discourage men, either.
Comment: Did you have a good experience with it?
Comment: Yes. I wish I could remember more of it so as to give a review with more specificity. Also, like with everything, you must judiciously sift the information you receive.
Answer: Igeres Haramban read and studied once a week has helped me for many years.
Comment: @sabbahillel I'm not sure what requires more clarification in this answer more than many previous answers. Sol believes Iggeret HaRaMBa"N helps with anger (I don't disagree).
Answer: The Trail To Tranquility by Rabbi Brody is my favorite:
here it is on amazon

Dealing with anger


improve quality of PHP GD generated images

Question: i am going to start building a map generator in PHP using the GD library. i generated some images using the lib but they don't have a good quality. I just want to know that is there some way to improve the quality of the images.
The generated image is:

and the code i made is:
<?php

$canvas = imagecreate(800, 350);

imagecolorallocate($canvas, 255, 255, 255);

$pink = imagecolorallocate($canvas, 255, 105, 180);
$white = imagecolorallocate($canvas, 255, 255, 255);
$green = imagecolorallocate($canvas, 132, 135, 28);

imagestring( $canvas, 20, 290, 25, "Quality is not the best :(", $green );
function drawlinebox($x1, $y1, $x2, $y2, $height, $color){
    global $canvas;
    imagesetthickness ( $canvas, 1 );
    for ($i=1; $i < $height; $i++){
        imageline( $canvas, $x1, $y1, $x2, $y2, $color );
        $y1++; $y2++;
    }
}

drawlinebox(20, 20, 780, 300, 30, $green);
drawlinebox(20, 300, 780, 20, 30, $pink);
header('Content-Type: image/jpeg');
imagejpeg($canvas);
imagedestroy($canvas);

?>

Comment: Try to use `imagepng` instead of `imagejpeg`.  PNG (`header('Content-Type: image/png');`) may be a better format.
Comment: Have you tried the antialiasing functions?
Answer: imagejpeg[docs] takes an argument for image quality. It defaults to 75, but you can increase it up to a maximum of 100. For example:
imagejpeg($canvas, NULL, 90);

However, for generated graphics with lots of continuous colours and sharp lines, JPEG is probably not the best choice. PNGs are more well-suited to these sorts of images, and will probably give you perfect quality at a smaller size. imagepng[docs] has a few options, but the defaults should be fine:
header('Content-Type: image/png');
imagepng($canvas);

You're using imagecreate[docs] to make the image in the first place. This creates a "pallet-based" image: one that can only use a limited number of colours. This matches the lower quality of a GIF or an 8-bit PNG, but because you're not using those formats you should use imagecreatetruecolor[docs] instead. So far, your image is very simple and this might not make a difference, but it will matter if you're generating more complicated images.
If you make these two changes, your images will be sure to have perfect quality.
Comment: Also, try `imagecreatetruecolor` instead of `imagecreate`.
Comment: imagecreatetruecolor() returns black image :(
Comment: @nikc: Good suggestion, I've added that to my post.
Comment: @Ameer: Nice, glad to have been of help. If you think your problem has been solved, you should consider marking the most helpful answer as "accepted" by clicking the grey check mark next to it.
Answer: The loss of quality is beacause of JPEG Compression (which is alossy compression algorithm).
If you want best quality use PNG instead of jpeg.
header('Content-Type: image/png');
imagepng($canvas);

And for a map generator I would recommend PNG as there are many solid color areas which will be compressed quite a lot by PNG.
Only think of using JPEG if the size of PNG images is unacceptably large.
In that case as jeremy said use the quality argument of imagejpeg..
imagejpeg($canvas, NULL, $quality);

I would experiment with various qualities to find a suitable size quality trade-off. Personally i have found a quality of 90 to be acceptable in most cases, but you can up it to 100 if you want to.


Did Vinata have any doubts about the outcome of her bet with Kadru in the Mahabharata?

Question: Did Vinata have any doubts about the outcome of her bet with Kadru in the Mahabharata? Did she innocently consider herself the loser?
Answer: Did Vinata have any doubts about the outcome of her bet with Kadru?
No  Vinita did not had  full  doubts about the outcome of her bet with Kadru about the tail of the horse Uchchaihshravas , which came out from churning of ocean. In Fact she herself somewhat confidently said to Kadru this which is mentioned in Astika Parva -SECTION XX  of Mahabharata.

शवेत एवाश्वराजॊ ऽयं किं वा तवं मन्यसे शुभे |  बरूहि वर्णं तवम अप्य
अस्य ततॊ ऽतर विपणावहे ||3||  śveta evāśvarājo 'yaṃ kiṃ vā tvaṃ
manyase śubhe  brūhi varṇaṃ tvam apy asya tato 'tra vipaṇāvahe
And Vinata answered, 'That prince of steeds is certainly white. What
dost thou think, sister? Say thou what is its colour. Let us lay a
wager upon it.

This  shows that she was  certain /confident about the color of the horse in some way . As She was ready to lay a wager (an agreement in which people try to guess what will happen and the person who guesses wrong has to give something (such as money) to the person who guesses right.)
The next verse  shows us that Vinita Was somewhat confident about the outcome , as she also accepted the term "she who loose will become the  slave other's". She wouldn't have accepted this proposal by Kadru , if she was not in someway was sure about the color of the tail.

एवं ते समयं कृत्वा दासी भावाय वै मिथः | जग्मतुः सवगृहान एव शवॊ
दरक्ष्याव इति सम ह ||5||
evaṃ te samayaṃ kṛtvā dāsī bhāvāya vai mithaḥ  jagmatuḥ svagṛhān
eva śvo drakṣyāva iti sma ha
'Thus wagering with each other about menial service as a slave, the
sisters went home, and resolved to satisfy themselves by examining the
horse next day.

Actually the Uchchaihshravas Horse was completely white in color including his tail. This is confirmed from Mahabharata as well as from  other puranas.

Did she innocently consider herself the loser?
No , Even though she was somewhat confident and might have seen the horse while it was coming out of ocean , She and kadru both themselves saw the tail of the horse (which was although  originally white , but was looking black covered by the snakes) with their own eyes.As told in Astika Parva -SECTION XXIII.

तं समुद्रम अतिक्रम्य कद्रूर विनतया सह |  नयपतत तुरगाभ्याशे नचिराद
इव शीघ्रगा||1||  निशाम्य च बहून वालान कृष्णान पुच्छं
समाश्रितान|  विनतां विषण्णवदनां कद्रूर दास्ये नययॊजयत||2||
ततः सा विनता तस्मिन पणितेन पराजिता|  अभवद दुःखसंतप्ता दासी भावं
समास्थिता||3||  taṃ samudram atikramya kadrūr vinatayā saha
nyapatat turagābhyāśe nacirād iva śīghragā  niśāmya ca bahūn
vālān kṛṣṇān pucchaṃ samāśritān  vinatāṃ viṣaṇṇavadanāṃ kadrūr
dāsye nyayojayat  tataḥ sā vinatā tasmin paṇitena parājitā
abhavad duḥkhasaṃtaptā dāsī bhāvaṃ samāsthitā
Sauti said, 'Having crossed the Ocean, Kadru of swift speed,
accompanied by Vinata, soon alighted near the horse. They then both
beheld that foremost of steeds of great speed, with body white as the
rays of the moon but having black hairs (in the tail). And observing
many black hairs in the tail, Kadru put Vinata, who was deeply
dejected, into slavery. And thus Vinata having lost the wager, entered
into a state of slavery and became exceedingly sorry.

So from the description given in the verses about her state of mind at that time , we can say that she was in great greef at that time ,when she saw the black tail ,she was sad and depressed; dispirited. But as per wager ,she accepted to be slave of Kadru .
We can also say that she felt the great shock so due to that she was unable to argue about ,what might she already saw or what she was  knowing.
So we can say that she did not considered herself looser at all but she was also meantime were enable to do
anything about the fact or the situation before her, so she accepted the bet forcefully due to situation and from very much sadness. She was helpless at that time.