Sports and Sports' Meetings in Post-Apocalyptic Scenarios

Question: In a sci-fi, post-apocalyptic scenario, is it reasonable/believable to assume that despite hardships, Humans would make time to engage in recreational sports activities? And in the case of sports' meetings/gatherings, like the ancient Panhellenic Games or the modern Olympiads, how would warfaring nations agree on where to meet, what rules to follow or whether there's fair competition - do these events not require a state of peacetime and international cooperation?
Comment: In ancient Greece the [Olympic Games](https://en.wikipedia.org/wiki/Ancient_Olympic_Games) were organized every four years no matter what. If any wars were in progress *they were suspended* for the duration of the Games; this was known as the Olympic Truce. The Games were so regular that ancient historians used them to date historical events. (For fun: January 2021 is about at the middle of the 4th year of the 699th [Olympiad](https://en.wikipedia.org/wiki/Olympiad).) How did the Greeks do it? What did your research turn out?
Comment: Research brought to my attention the Panathenaic Games, where the son of the King of Minos is killed out of jealousy by other competitors. No information uncovered yet as to HOW these contests were held, and there are some accounts of participants' deaths during the games. So not sure if it was a competition as we understand, or more of a no-holds-barred blood sport.
Comment: I have reason to believe said events would take place in the Thunderdome, and would be governed by Bartertown Rules.
Comment: (1) The Panathenaic Games were very much a very local event; they *included* a sport competition, but that was just one component of a complex festivital. (2) You must understand that for the people of whom we think when we say "ancient Greece", king Minos was a mythological figure. Lots of stuff happens in myths and legends. (For example, the wife of the same king Minos mated with a semi-divine bull and gave birth to the Minotaur.) (3) Some of the sporting events practiced in Ancient Greece were bloody full-contact sports, e.g., the pankration, similar to modern MMA. Others were very tame.
Answer: All depends on the depth of post-apocalypse
If civilization is still running well, we can see lavish, elaborate competitions like The Hunger Games. If the civilization is beaten back almost to the stone age, all we could see is The Blood of Heroes.
In either case, yes, sports is just in the nature of people. Even if they can't travel and can't get much of equipment, people will find ways to compete.
Answer: Alexander said it would depend on the depth of post-apocalypse; in most parts I agree, but the type of apocalypse matters as well: nuclear, zombie, alien invasion (like XCOM, maybe?), or otherworldly influence (a la Lovecraft, or perhaps like Half-life?)?

Nuclear Apocalypse-Humanity would likely survive a nuclear apocalypse just fine according to Anixx's comments, so sports will also survive and be played as normal within a short timeframe.

Zombie Apocalypse-The book series Last Kids on Earth suggests that teenagers would have video-game-style achievements and perhaps throw things at zombies for amusement. Hunting, football, hockey, soccer-if humanity survives, sports will too, and they will likely be turned against the zombies or played inside shelters.

Alien Invasion-Once again, look at hunting. In rebellion hideouts and shelters, even military complexes, other sports would likely have a place as a fitness maintenance program and natural entertainment. Perhaps certain humans will convince the aliens that they need to prove their supremacy in a fair and equal competition (just like in Space Jam) and play sports with them. Granted, said sports will be more than a little intense....

Alien Takeover-Humans in this case would be playing sports for alien entertainment, and perhaps even be "voluntold" for gladiatorial combat.

Otherworldly influence-No matter how strange the world becomes, people will still play sports (as long as they are still surviving, not necessarily thriving). Then it's just a matter of time until humanity adapts the current roles to fit their altered reality.
Comment: The need for shelters in the case of a nuclear apocalypse is exaggerated.
Comment: Really? I was not aware of that; still, in the case of nuclear war, wouldn't one want to be in a bomb shelter?
Comment: One has to be in a bomb shelter for about 30 min after the nuclear explosion. After that you leave the shelter safely. Yes, there could be radioactive contamination of waters and crops, depending on how "dirty" the bombs were (bombs of better quality make less radioactive contamination), but you do not need to go to shelter to avoid radioactive food. Rather, you remove the upper layer of the ground and continue as usual. Look at Chernobyl. And notice that no nuclear war can produce similar contamination (unless a nuclear plant is nuked, but that is a local disaster).
Comment: In Chernobyl there vaporized tens of tons of nuclear fuel. A nuclear bomb contains several kilograms. So, no nuclear war, however intense it would be can produce similar contamination (again, unless a nuclear plant is bombed), but in any case it would not be much worse than Chernobyl.
Comment: Thank you; I accounted for your comments in my answer, what do you think?
Answer: People will always find ways to keep their spirits up in the worst conditions, and playing games/sports would likely be a part of that. During the informal Christmas Truce of 1914, soldiers even played football with the men on the enemy side. Keeping morale up is essential to getting any kind of group through a crisis successfully. They're also useful for training people for physical fitness and working in a group- if you need to protect your settlement from raiders, playing lacrosse as war training might be a good idea.
On the other hand, international competitions and any other kind of event requiring complex logistics would be one of the first things to go in a societal collapse.  So your post-apocalyptic sporting events would likely be smaller and more local.  Another potential issue is fields and arenas being destroyed or repurposed (for arable land, emergency shelter, etc.), in which case sports would need to be modified to use other spaces.
TL:DR: People would still find ways to play sports after the collapse of civilization, but events like the World Cup would be off the table.
Answer: If you ask me, people would strive to make things look as much as possible to what was before the apocalypse.
This means, various bands of thugs as in many post-apocalyptic fictions are becoming less likely with time after the event.
More likely people will try to re-create the statehood, industry, armed forces, maybe democracy etc.
I do not expect massive violations of ethics in these games, like fights to death, gladiatorial combats, etc. Rather, the opposite, the people would strive to make such events as humane and hopeful as possible.
Also, even the worst apocalypse hardly can kick the humanity further than the 19th century technologically.


Estimating sample size en poussant

Question: If we have sample mean of $n$ observations as $\bar{x}$. It is given that maximum value of the whole set is $M$ and minimum value is $0$. How many more observations we need so that the estimate for average we have differs from the true average by not more than 10 with 99% confidence?
Comment: also, wth is *en poussant*? I'd be looking incredulous at the interviewer is they threw that at me. is this an academic job?
Comment: @Aksakal that was my contribution. Literally means "in passing". Implied in the sense of sequential or cumulative. As stated, the question suggests some sampling is already done, and a sample size calculation is to be performed for the total sample to achieve desired precision. Sample size re-estimation is a hot topic in clinical trials.
Comment: is this a home work?
Comment: no interview question. was asked to think in terms of Hoeffding's inequality but I had no idea.
Comment: are you only given an upper bound?
Comment: lower bound will be zero
Comment: that's a HUGELY important detail
Comment: @AdamO, I got the French, but didn't see this used anywhere, thought it's a new term :)
Answer: The most important glaring correction is to the notion of having a desired precision of 10 within the actual mean. You cannot calculate that. You can set the desired precision of the statistic to within 10, but it may be more than 10 units from the actual mean more than 1% of the time (suppose the estimator or design is biased).
Knowing the maximum may be irrelevant. For many distributions the average is the sufficient statistic for the mean, so the maximum $M$ is an ancillary statistic and gives no additional information. There are counter examples to this, but since you have not stated a specific distribution, we assume $M$ is ancillary as a base case.
The other unknown(s) in this case are the standard error of the sample mean and the actual variance of the distribution. Assume they are $s^2$ and $\sigma^2$. (the former can be used as a plug in estimate for the latter with degrees of freedom corrections).
So with the current sample of $n$ the 99% confidence-interval-half-width (CIHW) of $\bar{x}$ is $\mathcal{Z}_{0.995} \sqrt{s^2}$ and by the addition of $q$ observations, that value is estimated to be $$\mathcal{Z}_{0.995} \sqrt{\frac{n s^2 + q \sigma^2}{n+q}}$$.
Set this value to 10 and solve for q.
Comment: if actual variance of the distribution is not know than is it possible to calculate?
Comment: @Prayalankar yes, but change $\mathcal{Z}_{0.995}$ to $\mathcal{T}_{df, 0.995}$ where $df$ is the appropriate number of degrees of freedom.
Answer: If you have upper and lower bounds M and 0, then you can apply Popovivicu's upper bound on variance:
$$\sigma^2<\frac 1 4M^2$$
Once you have the variance, apply usual sample mean distribution logic, i.e. the variance of a sample mean $\bar x$ to be $\sigma^2_{\bar x}\sim\sigma^2/n$. The rest is trivial.
$$\frac {10}{(\sigma^2_{\bar x}/n)}=2.58$$
$$n=0.258\sigma^2_{\bar x}=0.067M^2$$
"Derivation"
Ok, how would I proceed to derive this? I'd imagine the distribution with highest variance (entropy) possible, that is bounded between M and 0. That must be Bernoulli:
$$x=0:p=1/2$$
$$x=M:p=1/2$$
Then the mean is $$\mu=M/2$$ and the variance is
$$\sigma^2=M^2/2-(M/2)^2=M^2/4$$

Estimating sample size en poussant


How to tail a log file when removing lines (not appending) of the file?

Question: I want to know how to tail a log file when lines in the files are updating(appending and removing)?
Answer: You might try:
tail -f /var/log/syslog

Or whatever file you are interested in. Get out of 'tail' with Ctrl+c.
Comment: I am unaware of any log file where lines are _removed_. Which is it?
Comment: This is not working when lines are removing from the file
Comment: It's relevant to my application
Answer: You need to use the tail command which output the last part of files in real time including all incoming logs to a standard output device such as screen. the commadn to use is
tail -f /path/to/log/file

EDIT: TRY this
tail -f --retry /path-to-log-file

This will try to reopen the file with the new contents
Or this
tail -F /path/to/log/file

Comment: This is not working when lines are removing from the file
Comment: @LasithMalinga check the edit
Answer: I'm not sure exactly what you are trying to do but you could use the watch command in conjunction with the tail command... Something like this:
watch tail /path/to/file
Answer: As Atari911 said, you can use watch along with cat to do this. Use
watch cat <filename>

this will output the contents of the file given by filename every 2 seconds to standard output. To change the interval for updating the output to something like 1 second(you can't reduce beyond 0.1), you can use
watch -n 1 cat <filename>

I am using cat to output the complete file, you could tail but that would only give you the last n lines of the file, where n is 10 by default.
Refer to the manual page of watch for more info.


How can I reset achievements in Starcraft II?

Question: I started a new campaign, but the game is still listing all the achievements as being completed.  I'd like to try them again (and have the game keep track of which ones I've done).  This is the only thing I'm actively looking to clear, but there's nothing I particularly want to keep so I don't care if I wipe anything else and start fresh there too.
Answer: You can not reset your achivements, they are saved to your account on the region.
You have two options:

Go to another region and play, this should show the achivments that you have gotten in that region. This is limited by the number of regions you have the game in.
Make a new account with a new game. This will require you to buy a new game.
Comment: That... is terrible.  But thanks
Comment: There's [a request on SC2 forums for a reset option](http://us.battle.net/sc2/en/forum/topic/15538974143).
Answer: Best option, instead of buying another copy (if you don't mind not having the record keep track online), play Offline Mode after deleting your saves.
This should reset all tracked progress and give you that "fresh start" feel.


Integration of a Complex Function

Question: I am beginner in Mathematica. My goal is to calculate an integral of the following Complex function,
\begin{equation}\nonumber
f(y)=\frac{1}{2\pi}
\times\frac{\sqrt{3}a\cosh(0.4)\cos(ca/2)\cos{(\sqrt{3}ay/2)}+2\sqrt{3}a\cos^{2}(ca/2)-i\sqrt{3}a\sinh(0.4)\cos{(ca/2)}\sin(\sqrt{3}ay/2)}{1+4\cos^{2}(ca/2)+4\cosh(0.4)\cos(ca/2)\cos(\sqrt{3}ay/2)-4i\sinh(0.4)\cos(ca/2)\sin(\sqrt{3}ay/2)}
\end{equation}
on the range $y\in\frac{2\pi}{a\sqrt{3}}(-1,1)$, with the conditions $a>0$ and $1.45779\leq c\leq 2.45804$. Here $c$ is a fixed parameter although it is in the interval above. I know the expected response is $1/2$ but when I try to do it in mathematica, it only keeps the message "running ..." and does not complete the calculation. How can I solve this problem? Thank you in advance.
Comment: How is it possible that you expect a numerical value if c is undetermined?
Comment: @JoséAntonioDíazNavas also `a` is undetermined. Yet the answer is supposed to be `1/2`. This is strange problem. Mathematica can integrate this as indefinite integration. May be the OP can try that first and see if the integrand is proper, try to take the limits and see what happens.
Comment: Can you provide code?
Comment: The input should be provided in cut-and-pastable form.
Comment: I'm sorry, the code it is, g[y_]:=(Sqrt[3] a Cosh[0.4] Cos[c a/2] Cos[Sqrt[3] y a/2]+2 Sqrt[3] a Cos[c a/2]^2-I c Sqrt[3] a Sinh[0.4] Cos[c a/2] Sin[Sqrt[3] y a/2])/((Cosh[0.4]+2 Cos[c a/2] Cos[Sqrt[3] y a/2])^2-Sinh[0.4]^2-4 I Sinh[0.4] Cos[c a/2] Sin[Sqrt[3] y a/2]+4 Cos[c a/2]^2 Sin[Sqrt[3] y a/2]^2)
Integrate[g[y],{y,-((2 \[Pi])/(a Sqrt[3])),(2 \[Pi])/(a Sqrt[3])},Assumptions->{a>0,1.45779<c<2.45804}]
Comment: I'm sorry, but I don't understood. What is it OP? How can I take the limits? Thank you.
Comment: "OP" means original poster. i.e. the person who started the discussion thread. If you rationalize the integrand and integrate it as indefinte integration, then Mathematica can do it. Now you can apply fundamental theorem of calculus to find the definite value from the upper and lower limits. But this works only if the integrand is proper. So you need to check that first. ![Mathematica graphics](http://i.stack.imgur.com/ZqCmp.png)
Answer: Rationalize all the 0.4, thinking that might expose simplifications and other integration methods
g[y_] := (Sqrt[3] a Cosh[4/10] Cos[c a/2] Cos[Sqrt[3] y a/2]+2 Sqrt[3] a*
  Cos[c a/2]^2-I c Sqrt[3] a Sinh[4/10] Cos[c a/2] Sin[Sqrt[3] y a/2])/
  ((Cosh[4/10]+2 Cos[c a/2] Cos[Sqrt[3] y a/2])^2-Sinh[4/10]^2-4 I Sinh[4/10] *
  Cos[c a/2] Sin[Sqrt[3] y a/2]+4 Cos[c a/2]^2 Sin[Sqrt[3] y a/2]^2);

FullSimplify to make it smaller
FullSimplify[g[y], a > 0 && 1.45779 < c < 2.45804]

By inspection pull multiplier not dependent on y outside the integral, thinking that might simplify and speed the integration, and assume that doesn't have a zero denominator.
(Sqrt[3] a Cos[(a c)/2])/(3 + 2 Cos[a c] + 4 Cos[(a c)/2] )*
  Integrate[(2 Cos[(a c)/2]+Cos[1/2 Sqrt[3] a y] Cosh[2/5]-I c Sin[1/2 Sqrt[3] a y]*
    Sinh[2/5])/(Cos[1/2 Sqrt[3] a y] Cosh[2/5]-I Sin[1/2 Sqrt[3] a y] Sinh[2/5]),
    {y, -((2 \[Pi])/(a Sqrt[3])), (2 \[Pi])/(a Sqrt[3])},
    Assumptions -> {a > 0, 1.45779 < c < 2.45804}]

and in a few seconds the result is
(Sqrt[3] (5.25758+1.99761 c-1.77636*10^-15 Cos[(0.5+0. I) a c]-
  6.66134*10^-16 Cos[(a c)/2]) Cos[(a c)/2])/(3+4 Cos[(a c)/2]+2 Cos[a c])

It is interesting, at least to me, that while there is not a decimal point anywhere in the integrand, other than the assumptions, that the result is given in terms of approximate decimal numbers.
I'm also a little concerned that your initial f(x) started with a 1/(2 pi) but that doesn't seem to appear in your g[x] code. Are f(x) and g(x) really equivalent and correct?
Comment: Yes, f(x) and g(x) are equivalent. I forgot to type $\frac{1}{2\pi}$ in code.

Integration of a Complex Function


How do I select a mixed group of troops with the Stimpack option showing?

Question: Is there a technique to select an all bio army (marine, marauder, medivac, and ghost) but with the stimpack option available first? Because when I select that army, I get the ghost options first, and I have to tab to select the other army options.
Comment: How are you selecting them? With a click and drag or as an already saved group?
Comment: I always use the saved groups: 1 bio, 2 tank/drop, 3 air/widow.
But for that problem, against protoss, sometimes I need use 1 bio + 2 ghost, to access stim fast, but I lost tank control for quick engagements...
Answer: The answer to your question is No.
Starcraft has a priority system built-in, and there is no way to modify the priority order.
Ghosts take priority over bio, so if you group your ghosts with the rest of your army you'll have to tab-stim every time.  Because of this you'll likely see ghosts used on a separate hotkey than the rest of the terran army.
The good news is that the stimpack ability takes priority over everything else except the raven's abilities, so omitting ghosts from the control group should solve your problem.
Answer: I usually use this set up:

Marine/Marauder
Tanks/Ghosts (depending on which one I have)
Medivac (or a drop squad or put Marines/Marauders in the same
group if controlling all of them at once)
All other air
CC
Any other special hit squad

You usually will have your ghosts and tanks in the back lines, which is why I put them together. Once the tanks are all set up, you can then select a few ghosts at a time to use EMP or Nuke or whatever.
The key is to put your Marine/Marauder in a hotkey set up that is easy to select and easy to manipulate.
You can also set up custom hotkeys in the options menu for each race and each unit. So you may want to try to set up an easier hotkey set up that works well with your general strategies.
Answer: You can set it up so the stim option shows up first.
when you select the bio army, press the tab button. This cycles your unit types. Eventually the ghost commands are replaced by the stim command.
once the stim command is showing, set your squad hotkey. That should then be your default squad command.
Comment: While the idea sounds great, this dose not seem to work in practice.


How to rename a local APT repository?

Question: I follow the steps in this post to create a custom repository, but I want to rename it. I can't find any way to do it. Can you please help me?
Comment: What do you mean by rename?  Repositories don't have names.  Do you mean the suite name (e.g `bionic`/`focal`)?  The component (e.g. `main`, `universe`)?  The path (e.g. `/usr/local/mydebs`)?
Comment: Let me elaborate on this. I downloaded a package and used the dpkg-scanpackages program, now after changing the sources file I can install the package via apt-get. But the name of this package is beyond my control. I want to name this package say MyRepository, to be able to install it by writing apt-get MyRepository, instead of apt-get AnotherDudesName.
Comment: @DiplomateProgrammer What do you mean by repository here? Are you talking about package name?
Comment: I don't know the terminology. I created a local repository using the dpkg-scanpackages command like in the post I linked. Everything is fine, but there seems to be no way to change the name of the package.
Answer: Sounds like you want to know how to rename a package.  There are two ways to do this.   In this example, I'm going to change the name of cowsay to mysay
From source
Download the debian  (or ubuntu) source package, rename the files as appropriate, replace the old name with the new name in the debian/* directory (that's what the sed lines are doing, then build it with dpkg-buildpackage.
Be a little careful, because some packages may have build rules which depend on the package name and may not be as trivial as cowsay.  This is probably the toughest option.
apt source cowsay
mv cowsay-3.03+dfsg2 mysay-3.03+dfsg2
mv cowsay_3.03+dfsg2-8.dsc mysay_3.03+dfsg2-8.dsc
mv cowsay_3.03+dfsg2.orig.tar.gz mysay_3.03+dfsg2.orig.tar.gz
cd mysay-3.03+dfsg2/
sed -i 's/\bcowsay\b/mysay/g' debian/changelog debian/control
sed -i 's./debian/cowsay./debian/mysay.g' debian/rules
dpkg-buildpackage -uc -us

From binary
Get the *.deb you want to manually split the archive up, edit the control file and then put it back togeather.
apt download cowsay
mkdir mysay && cd mysay

# Split everything up
ar -x ../cowsay_3.03+dfsg2-8_all.deb
mkdir control
tar -xf control.tar.xz -C control

# CHange the package name
sed -i 's/cowsay/mysay/' control/control

# Put the control file back togeather
cd control
tar -cf control.tar.xz *
mv control.tar.xz ../
cd ..
rm -r control

# Put the rest back togeather
ar r ../mysay_3.03+dfsg2-8_all.deb debian-binary control.tar.xz data.tar.xz

From binary (method 2)
This one simplifies the re-combining process. This is probably the easiest method.
apt download cowsay
ar x cowsay_3.03+dfsg2-8_all.deb
mkdir -p mysay/DEBIAN
tar -xf control.tar.xz -C mysay/DEBIAN
tar -xf data.tar.xz -C mysay/
sed -i 's/cowsay/mysay/' mysay/DEBIAN/control
dpkg-deb -b mysay

A few final notes:

If you try to install cowsay and mysay on the same machine, one of the packages will fail.  That's because they both supply the same files, so it's impossible for your system to know which owns it.  A way to make this foolproof is to add a Conflicts: cowsay to the control file of mysay.

Renaming packages is a little strange.  It is sure to cause the conflicts mentioned above.  I not sure I can picture a case where this is necessary.
Comment: Thanks, I think this addresses my issue.
Comment: However, I tried a similar approach with binary before and it didn't work. I changed the control file in the control.tar.xz directory of the archive, changing Package from the original name to my own. But when I call the dpkg-scanpackages command, the control file is once again changed to what it was before and it doesn't work.
Update: it seems for some reason there's an archive inside the archive, so that's why it wasn't updated. Probably should work if processed carefully.

How to rename a local APT repository?


Retrieving permission sets

Question: Does the metadata api returns the object permissions in the permissions sets? I want to retrieve the object permissions for standard as well as custom objects.
Answer: USING SOQL
You can fetch this information by Querying 3 objects - PermissionSet, PermissionSetAssignment and ObjectPermissions.
SELECT Id,IsOwnedByProfile,Label FROM PermissionSet
WHERE IsOwnedByProfile = TRUE

The above query will return the permission set that you have created and not owned by profile.Then you can use below query to get the object permissions -
SELECT Assignee.Name, PermissionSet.Id, PermissionSet.isOwnedByProfile, PermissionSet.Profile.Name, PermissionSet.Label
FROM PermissionSetAssignment WHERE PermissionSetId
IN (SELECT ParentId FROM ObjectPermissions
WHERE SObjectType = 'XYZ__c' AND
PermissionsCreate = true)

Reference - https://developer.salesforce.com/blogs/engineering/2012/06/using-soql-to-determine-your-users-permissions-2.html
USING METADATA
You can use metadata API to retrieve the object permissions.If you check metadata developer guide and search for PermissionSet , you can easily see that this type returns multiple parameters from API v29.0 onwards like-applicationVisibilities,classAccesses, fieldPermissions,ObjectPermissions, etc. Specifically talking about ObjectPermissions, the return type is PermissionSetObjectPermissions[] (List of PermissionSetObjectPermissions). Now this list has all the information that you require like - allowCreate, allowDelete, allowEdit, allowRead, modifyAllRecords,object, viewAllRecords. Out of this Object is a string type while rest are all boolean corresponding to the permissions on object.
Reference - https://resources.docs.salesforce.com/sfdc/pdf/api_meta.pdf (Metadata API v.34 Summer'15 page 416)
Now if you are looking for developing this using Apex, kindly refer this package - https://github.com/financialforcedev/apex-mdapi and this example - https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataServiceExamples.cls#L234
Comment: I wanted to use metadata api, not SOQL to retrieve permission sets.
Comment: I updated my answer, hope it helps!
Answer: You may use something like this
SELECT SobjectType, ParentId, PermissionsRead
FROM ObjectPermissions
WHERE PermissionsRead = True AND SobjectType = 'Merchandise__c'.
ObjectePermissions and FieldPermissions are child to Permissionsets. Hope this helps

Retrieving permission sets


Grep in couple thousands files

Question: I have directory with cca 26 000 files and I need to grep in all these files. Problem is, that I need it as fast as possible, so it's not ideal to make script where grep will take name of one file from find command and write matches to file. Before "arguments list too long" issue it took cca 2 minutes to grep in all this files.
Any ideas how to do it?
edit: there is a script that is making new files all the time, so it's not possible to put all files to different dirs.
Comment: use `find` with `xargs` or `grep -R`
Comment: It works good, but it takes 10 minutes...
Answer: With find:
cd /the/dir
find . -type f -exec grep pattern {} +

(-type f is to only search in regular files (also excluding symlinks even if they point to regular files). If you want to search in any type of file except directories (but beware there are some types of files like fifos or /dev/zero that you generally don't want to read), replace -type f with the GNU-specific ! -xtype d (-xtype d matches for files of type directory after symlink resolution)).
With GNU grep:
grep -r pattern /the/dir

(but beware that unless you have a recent version of GNU grep, that will follow symlinks when descending into directories). Non-regular files won't be searched unless you add a -D read option. Recent versions of GNU grep will still not search inside symlinks though.
Very old versions of GNU find did not  support the standard {} + syntax, but there you could use the non-standard:
cd /the/dir &&
  find . -type f -print0 | xargs -r0 grep pattern

Performances are likely to be I/O bound. That is the time to do the search would be the time needed to read all that data from storage.
If the data is on a redundant disk array, reading several files at a time might improve performance (and could degrade them otherwise). If the performances are not I/O bound (because for instance all the data is in cache), and you have multiple CPUs, concurrent greps might help as well. You can do that with GNU xargs's -P option.
For instance, if the data is on a RAID1 array with 3 drives, or if the data is in cache and you have 3 CPUs whose time to spare:
cd /the/dir &&
  find . -type f -print0 | xargs -n1000 -r0P3 grep pattern

(here using -n1000 to spawn a new grep every 1000 files, up to 3 running in parallel at a time).
However note that if the output of grep is redirected, you'll end up with badly interleaved output from the 3 grep processes, in which case you may want to run it as:
find . -type f -print0 | stdbuf -oL xargs -n1000 -r0P3 grep pattern

(on a recent GNU or FreeBSD system) or use the --line-buffered option of GNU grep.
If pattern is a fixed string, adding the -F option could improve matters.
If it's not multi-byte character data, or if for the matching of that pattern, it doesn't matter whether the data is multi-byte character or not, then:
cd /the/dir &&
  LC_ALL=C grep -r pattern .

could improve performance significantly.
If you end up doing such searches often, then you may want to index your data using one of the many search engines out there.
Answer: 26000 files in a single directory is a lot for most filesystems. It's likely that a significant part of the time is taken reading this big directory. Consider splitting it into smaller directories with only a few hundred files each.
Calling find cannot explain poor performance unless you do it wrong. It's a fast way of traversing a directory, and of ensuring that you don't risk attempting to execute a command line that's too long. Make sure that you use -exec grep PATTERN {} +, which packs as many files as it can per command invocation, and not -exec grep PATTERN {} \;, which executes grep once per file: executing the command once per file is likely to be significantly slower.
Comment: @user001 Yes. How much they differ depends on the filesystem and possibly on the underlying storage, but I'd expect any filesystem to be measurably faster with 260 files in each of 100 directories compared with 26000 files in a single directory.
Comment: Thanks, I will google something about it and probably I will split that.
I made exactly what you are writing about and it took 3 times longer than only grep...
Comment: Gilles, are you saying that performance would differ significantly for 26,000 files in one directory versus 26,000 files distributed over, say, 100 directories?
Comment: Thanks for the clarification. I asked a follow-up [question](https://unix.stackexchange.com/q/466883/14960) on this point in order to understand the basis for the discrepancy.
Answer: If you need to grep ALL the files multiple times (as you said, running a script) I would suggest looking into ram disks, copy all files there and then grep the files the multiple times, this will speed up your search by a factor of at least 100x.
You just need enough ram.
Else, you should look into indexing the files, eg. into lucene or a nosql database and then running queries upon that.
Comment: As noted elsewhere, this doesn't help the fact that there are too many files to run a `grep` against. There's also the point that: "there is a script that is making new files all the time, so it's not possible to put all files to different dirs."
Answer: If you are open/able to rely on an external utility, the popular utility ripgrep provides the binary rg which uses parallelism and smart file filtering by default.
You can control the level of parallelism if you wish:

-j, --threads NUM
The approximate number of threads to use. A value of 0 (which is the default) causes ripgrep to choose the thread count using heuristics.

Additionally, quoting the ripgrep README, rg "is built on top of Rust's regex engine [which] uses finite automata, SIMD, and aggressive literal optimizations to make searching very fast."
Beside this, there are other aspects that make rg faster than grep. Depending on your situation, you might want to turn some of these off:

By default rg is recursive.

If your directory contains subdirectories that you do not want to search, you can disable the recursive behaviour with --max-depth 1.

By default rg does not search files present in any .gitignore or similar file, nor does it search hidden files, and binary files.

If you want to remove those filters you can add the -u flag (once (-u) for ignored files, twice (-uu) for ignored and hidden files, three times (-uuu) to stop all filters).
Assuming that you have subdirectories in your directory that you do not want to search and that the default filtering is useful in your situation, you would then run (from your directory):
rg --max-depth 1 pattern

Outside your directory, you'd have to add its path:
rg --max-depth 1 pattern /path/to/dir

If you want to search ignored files and hidden files, but not binary files, you'd use:
rg --max-depth 1 -uu pattern

If you want to follow symlinks, you have to add the -L flag.
Answer: All files in the directory
grep 'search string' *

with recursively
grep -R 'search string' *

Comment: I didn't downvote, but there are a few issues with yours: the OP mentionned a "arg list too long", which your first one won't fix and is probably what the OP was doing before. The second one doesn't help either in that regard (would have helped had you used `.` instead of `*`). `*` will exclude dot files (though with -R, not the ones in the recursed directories). -R as opposed to -r follows symlinks even with recent versions of GNU grep. You'll also have an issue with files in the current directory whose name starts with `-`
Comment: Care to elaborate the -1?

Grep in couple thousands files


Pin IO for a computer running Linux

Question: I'd like to control a few input pins (say 5) and a few output pins (at least 2) from a computer. The computer has no parallel port. What is the best way to do this? USB-to-parallel adapter (anybody have one to recommend which works on Linux)? Or perhaps there is some other general purpose USB "control board" where I can use read input from some pins and write output to others? I don't even know what to google for, so any pointers are appreciated!
Comment: "Drive a few pins"? I get it you want to control several pins of a microcontroller from a Linux host computer? Which is simple.
Comment: http://dangerousprototypes.com/docs/FT2232_breakout_board
Answer: It will depend what speed you need to read or write data at.  However many of the FTDI chips support this sort of USB<->parallel using the D2XX interface (programmers guide here).
Some chips such as the FT245B (datasheet here) are designed for implementing custom parallel interfaces.  See the block diagram below.
Comment: I was just trying to caution about the difference between your very appropriate but niche-market recommendation, and the easier to source but unsuitable cables sold for parallel printers.
Comment: Yes, though be aware that while it sounds like they should be, flexible parts like the FT245 are typicall **not** the chips typically used in USB parallel **printer** adapter cables - those typically use chips that are useless for much of anything beyond actual printing on printers.  Pre-assembled FT245 cables do exist, but tend to be for niche applications such as device programmers or experimenter projects.
Comment: @ChrisStratton Printing wasn't in the question - unsure if I'm missing something here?
Answer: If you have US$108 to spare, this "Affordable Multifunction DAQ with USB" (http://labjack.com/u3), by LabJack, may solve your problems . Perhaps overkill for what you want (16 I/O pins) but it works with Linux, and it's programmable from all the major languages.
In general, if you search for linux daq usb you will find plenty of options.
Answer: It is very easy to make your own using a microcontroller like an Arduino or mbed. The microcontroller will appear as a virtual serial port when plugged in with USB, and you can send it commands. On the microcontroller side, write a small program that interprets the commands and changes output of the pins or returns an input. This may not provide timing as good as a "real" DAQ box, but if you don't need that kind of quality, it can be an affordable solution.

Pin IO for a computer running Linux


breaking Muslim Friendships permissible?

Question: I have a best friend.(same gender)who loves me so much. and I'm the only muslim friend she has. but every single day we spend  total 4 hours chatting about halal but past, childhood and other things . (never gossip). sometimes also learn quran together. our frendship brings good and bad to our akhira. soemtimes one weighs over another. and she doesn't seem to be guilty about spending time too much like this. but I do. is it ok, if I cut ties with her/ block her contact. even though it'll hurt me and her. but it's for the sake of allah. to not waste  away my time talking about usless things.? it really affects my concentration in salah. please advice .
Comment: Whatever thing you do, be it small or big, if it's done just to please your Rabb, then there can be no harm in it. My opinion is if you can find a balance without cutting ties with your Muslim friend, that would be better. Because one's faith is not complete unless you want the best for the other believers as well. Always try to please your Rabb in the best way possible, aim for a greater reward. If to there is no improvement, you can always distant yourself. But first try to reason and come to an understanding for the better with your friend.
Answer: Bismillah Hir Rahmaan Nir Raheem
As Salaamu 3laykum,
I hope you are doing well. The main purpose of our life is to worship ALLAH (Glory Be To Him).
Quraan
I did not create jinn and humans except to worship Me. (Surah 51 verse 56)
Now when it comes to friendship it becomes very important to choose our friends wisely.
Hadith
The Prophet (ﷺ) said: A man follows the religion of his friend; so each one should consider whom he makes his friend. (Abu Dawud in the chapter of general behavior)

My next words might seems harsh but your friend is not forcing you to have these conversations. Nor does she prevent you from praying or anything. That is something you will have to look at yourself and say what can I do better so that I don't disturb my salah or any other acts of ibadah.
I would suggest not calling her all the time or if she is calling you then perhaps keep the conversation short. All of us sometimes talk about some useless thing here and there but if that is the dominant part of the conversation then bring some useful things in. For example she might be like blah blah blah and you can say hey do you want to go the masjid this weekend. Or perhaps wanna listen to this lecture. Or perhaps want to go play xyz sport, etc.
I will also say don't break relationship but just try to mend them and help the other person as well. Who knows what blessings are hidden between both of your friendship. There is trust there and a good bond between both of you. If you care for her then you will also try to help her not to waste time and try to make her a better person as well.

Have a nice day!
Answer: You do not need to cut off your friendship. Only your friendship, like anything else in life, should be managed. Everything in life needs planning and management. Sleep, food, entertainment, etc. in narrations in Islam introduce a good friend as a blessing. Sometimes a person needs to talk to a good friend. Have fun.
So try to manage your friendship and your time properly so that you are not harmed.


correlation-based effect size

Question:
how can a correlation coefficient of .40 be a "medium" effect size when r2 shows that the variables only have 16% common variance?  Seems like the 16% suggests a small effect size.  Jim
Comment: (correlation coefficient)$^2$ = r$^2$.
Answer: There is no absolute way to describe the strength of an effect - it is all relative. When you hear someone refer to a "small," "medium," or "large" effect size, they are referring to what effect sizes are commonly seen within their field of study and/or what is to be expected from the phenomena being studied.
When you hear things like "r = 0.1 is weak", "r = 0.3 is medium" or "r = 0.5 is strong" it generally refers to guidelines for the social sciences. This is because humans tend to be very complex compared to the methods used to study them (i.e. data from humans is noisy). So effect sizes tend to be smaller. However, we would expect higher effect sizes in a field such as industrial design, where the phenomena being studied can be controlled to a much greater extent.
Answer: Yes and no. Effect size meanings depend on what they measure. For example, if you measure an effect of a drug on weight loss, you will end up with some distribution describing the weight changes in your experiment group. In this case, the (mean standartized) effect size will be the ratio of that distributions mean and standart deviation. It will be a real number - not nescesarily between 0 and 1. It will also be a practical number meaning the actual effect on weight distribution shift in its standard deviations. In the case of correlating things, you can use the r2 for comparing different model "fit" to the data. Also note that r2=1 means that the datapoints are ideally represented by the model. In practical cases very high r2 is an indication of overfitting. Real data is always noisy.

correlation-based effect size


How to create a field that shows results based on another field's selection?

Question: I'm building a form for signing up to car services. I want to set up a choice field that shows value-based results depending on the user's selection in the first choice field. To be more specific; If first field choice (Car Manufacturer) is "Audi", second field (Car Model) shows only Audi models (because there are many of them, all Audi models have been assigned a value "1".
Answer: I'm a developer with Cognito Forms.
We do not offer a way to hide or disable choice field options at the moment, this is a feature on our Idea Board.
You can set up several Choice fields that only contain car models for the different car manufacturers. You can then use the 'Show When' logic and check to see what choice field option was selected. You can then have your different car model Choice fields show up when the car manufacturer option they relate to has been selected.
Comment: Well, that's a bummer. I've already inserted all the models and assigned them values in my choice field, because I thought there was a way to write a custom value to make this possible. Considering there's about 60 choice fields for car models in my form, will I be able to display them in the correct position, because whenever I insert new choice field it appears in full-page width in the editor instead on the right side, where I want it to have?
Comment: Never mind, I just figured a workaround for this. I added fields to the left side of the form and set their visibility value to "Never" and then just added choice fields for car models to the right side. Now it all displays correctly. Thanks for your assistance!


Unable to turn knob on Rheem hot water heater to pilot

Question: I have a Rheem heater (Model# PROG50-38N RH60). The pilot has gone out. This tutorial suggests I must turn the knob to pilot to start the process of relighting the heater. When I try to turn my knob to pilot, I am unable to do so. Is there any trick to getting the knob into pilot mode? I don't want to break the heater by forcing things.
Here is the knob on my heater
Comment: What's the model number of your unit? Maybe you have to press and turn like a child safety cap for medicine.
Comment: @monkeyzeus that should be an answer I think just about all gas valves have to be depressed to or the button depressed to go into "pilot" where gas is flowing without the thermocouple/ flame eye being made.
Comment: @EdBeal Thanks, I see that OP updated their post with a model number . I added an answer accordingly.
Answer: Below is a picture of the lighting instructions for your water heater taken from Rheem's website. Make sure to follow the lighting instructions carefully and do not skip any steps. This same instruction set should be available as a sticker on your unit.
It looks like you do in fact have to depress the knob in order to turn it so avoid using force.
If you are unsuccessful with the instructions then it is a good idea to call a professional.
Page 17: https://cdn.globalimageserver.com/FetchDocument.aspx?ID=1109693C-C799-48A7-9045-F812119FBDF8
Comment: @FreeMan If it ain't broke don't replace it! I wish I could light mine (2019 Rheem) with a long lighter. Previous one was a 2008 and it too used piezo-electric.
Comment: My water heater is a different brand, but it works exactly the same - you must press the "pilot" button in order to be able to turn it further. I believe that the design is to get you to stop at the "pilot" setting to get the pilot lit before advancing the knob to "on". This way there's only a small bit of gas coming out of the pilot burner instead of the full burner pouring gas into the combustion chamber as you approach with a lit match. Helps keep the house from going boom.
Comment: @FreeMan If you are actually able to reach your pilot light with a lit match on a modern water heater then I am pretty sure you have voided the warrant and absolved the manufacturer from the consequences of your actions.
Comment: I installed my water heater 10-15 years ago and just had to relight the pilot last week. I used to do it with long "camp fire" matches, but since we've used them all up, I did it with a long "fire starter" lighter. Our heater doesn't have any sort of piezo-electric sparker to light it with. I guess that means that 10-15 years old isn't "modern". :(


How to hide complete domain information?

Question: I came across a domain name pagalworld.to. When I try to pull whois details for this domain I do not get any information from whois providers and I tried on multiples. How he did it?
Comment: This is called "Whois Privacy", and is available either for free or for an additional fee, from your registrar.
Answer: This registry does not provide a detailed whois output:
$ whois -h whois.tonic.to pagalworld.to
Tonic whoisd V1.1
pagalworld ns1.serverhide.com
pagalworld ns2.serverhide.com

IANA whois server also says for .to:
remarks:      Registration information: http://www.tonic.to/

If you go there and read their FAQ you can see:

Does Tonic offer a whois service ?
Tonic does not maintain a whois database that provides registrant
  information, as many of our customers consider the public display of
  this information invasive of their privacy. In fact, we will never
  sell a mailing list of our customers.
We also do have a web-based facility similar to whois, that lists DNS
  and other domain name info, without revealing the customer name. Try
  for instance: http://www.tonic.to/whois?best.to. There is also a whois
  server on port 43 of whois.tonic.to.
To verify your .TO domain names are available worldwide, you can use a
  tool like nslookup or dig.

If you try with your domain you get marginally more data than from command line:
Domain:               pagalworld.to
Created on:           Thu Jan 02 05:36:21 2020
Last edited on:       Fri Feb 07 04:01:40 2020
Expires on:           Sat Jan 02 05:36:21 2021
Primary host add:     None
Primary host name:    ns1.serverhide.com
Secondary host add:   None
Secondary host name:  ns2.serverhide.com

END

So in short, the registry either does not handle contacts at all (called a thin registry, exactly like .COM today) or never outputs them in public API whatsoever.
This all boils down to the fact that each TLD is free to implement whatever business rules it wants, also based on its own local rules. Only gTLDs are under contract with ICANN and hence have some requirements.
So there is no "Whois Privacy" here (a very bad naming in fact, even if everyone uses it), but it is true that in many TLDs and specially in gTLDs, registrars will offer, or sell, a Privacy option in order not to send the real contact data to the registry and hence the registry whois server will never be able to output real contact. What you can or can not do or hide depends on the TLD and which registrar you use, so in all generic way your question can not be answered. The above is just an explanation about the specific .to case you gave.
PS: "When I try to pull whois details for this domain I do not get any information from whois providers and I tried on multiples"
1) when you say so in a question, you should list which "whois providers" you did try
2) but in fact you should try none, only the registry (as above) and if the registry has registrars then only the whois server of the registrar, not any other one.


How to fix this bug or something in Facebook messenger

Question: I'm using fb messenger and all of my incoming new messages are gone. I don't know what I did, all I did to this group chat was just seen.  "For an example. Today is Wednesday, my friends chat at the group chat yesterday. But the messages that I only see if from last  week Monday. All the messages from yesterday were gone". Pls help me pls there are important messages I need to see
Answer: Because your your text messages sms mms voicemail and all emails are being forwarded to someone you live with or close to you that has access to your cell phone that can make changes to your settings . Please don't take me as a vigalanty or some terrible person  but this happen to me for a very long time and I thought I was being ha led as . A result. Till Google and Facebook saidI was being abused.


max USB length for power supply

Question: I know that normally usb 2.0 limit is 5m, but is there any difference how I use that cable? Can I simply extend cable longer than 5m if no data or audio transfer is required, just want to feed really small usb speakers?
Comment: Depends on the port you use and quality of cable. With right components connections over 30m is entirely possible ( and done in real life applications )
Comment: There is no ports(if you mean PC), just a 5v power supply with USB output  for charging smartphones, tablets and other devices. And I don't want to use extra components(if you mean hubs, active cables). I want simply extend ~10m long cable that carries electricity only. Is it possible?
Comment: On wikipedia you can read _"The primary reason for this limit is the maximum allowed round-trip delay of about 1.5 μs. If USB host commands are unanswered by the USB device within the allowed time, the host considers the command lost"_. The first it is a problem of comunication. But, more long is the cable more electrical resistance it will do, more power you will dissipate (there is a max output you can give from each device), more the ending voltage will decrease... if you go below 4.45V you should start to experience problems. It depends from the  port you use and quality of cable.
Answer: Consider a different solution: install an USB power adapter close to the speakers and use it to supply the power to the speakers. <code>:-)</code>
Image from wikipedia .

Q1: Is there any difference how I use that cable?
A1 (Short): Yes, there are problems of communication over the 5mt [1],[2] (see below), and of maximum power deliverable.
(The longer or thinner the cable, the lesser the final Voltage [3],[4]).
For example some HDD drives need good cables (short or with a good section of the copper cable) in order to work properly, because their absorption is close to the limit of the port.
Q2: Can I simply extend cable longer than 5m if no data or audio transfer is required?
A2: (Short): It depends.
If you use only to "deliver power" it could work if it is not involved the communication aspects.
Note that if the Voltage is too low for example the battery circuit of a mobile can work not properly.
(Nowadays many battery, for example, decide if they are charged checking their temperature that depends from the amperage and voltage with which they are charged: this can change their life expectancy. Moreover they can decide
that the voltage is too low to have a proper charging cycle and don't start at all, or even worst to continue to switch between the charging status and the not enough to charge status)..
Q2B ...I just want to feed really small usb speakers...
A2B: It depends, again.  If the audio arrives through a different cable, you should only experience a lower final volume and some distortion.
Note that with new compliant cables (USB Power Delivery, "PD") and devices some limits are overcame. Again you can read more about  on the usb site[5] and on wikipedia [6].

Some words more
From Wikipedia [1] you can read

USB 2.0 (standard) provides for a maximum cable length of 5 meters for devices running at Hi Speed (480 Mbit/s). The primary reason for this limit is the maximum allowed round-trip delay of about 1.5 μs. If USB host commands are unanswered by the USB device within the allowed time, the host considers the command lost. When adding USB device response time...

From the Cables and Long-Haul Solutions of the usb faq on the usb.org site [2] you can read

I want to build a cable longer than 5 meters, why won't this work?

A2:   Even if you violated the specifications, it literally wouldn't get you very far. Assuming worst-case delay times, a full speed device at the bottom of 5 hubs and cables has a timeout margin of 280ps. Reducing this margin to 0ps would only give you an extra 5cm, which is hardly worth the trouble.

I really need to put a USB device more than 30 meters away from my PC. What should I do?

A4:   Build a USB bridge that acts as a USB device on one side and has a USB host controller at the other end. Use a long-haul signaling protocol like Ethernet or RS-485 in the middle...
Comment: Installing adapter closer to speaker is something I want to avoid. Distortion is not problem, because the sound is lofi by default, thought volume level is important. I think it's worth to try at least. Thanks.

max USB length for power supply


How do you render background image through transparent object?

Question: I tried rendering an object that has a mixed glass and diffuse shader and also a background image but after adding a holdout shader in image 2 to make the object transparent to see the background image the glass shader becomes darker.
Image 1:
Image 2 :
Without transparent shader:
Nodes for background image:
With transparent shader :
Answer: That's because the way you have it set up, it's going to be transparent on the edges and solid in the middle. Switch the top and bottom slots, and it should fix it!
EDIT: The Holdout shader also only uses what you have set for your world background. It's going to show up as a basically a hole to show the background through, with no consideration for any other object or faces behind it. If you simply want transparency, use the Transparent node instead of Holdout.
(It's doing what you you want, this is just how it looks in preview; see how it looks in render, then switch the top and bottom slots to see if it looks better, as well as also hookup up your mix factor back into your original mix; it can hook up to more things at once!)
EDIT 10/19: By switch the slots, I mean the sections that say 'shader'. When you use a mix factor, it's telling Blender to make all the white one of the shaders and all the black the other shader. Any mix is a combination of the two. Fresnel as a mix mask looks black where it's facing the camera, and white where it's angled away, and a fairly short falloff between the two. This means if it looks funny, you might simply have it hooked up opposite from the way you want, where it's hooked into the little green dots that say 'shader'.
To further this note, you don't have the same mix factor in your addition with the holdout. You just moved it to the second mix. For better results, plug the Fresnel Fac into the the gray dot that says Fac on both mix shaders.
Comment: Thank you for responding Lee. I'm not sure what you mean by switch the top and bottom slots. Using the transparent shader doesnt seem to solve the problem. I've updated the question so you can see what happens when I add the transparent shader.
Comment: Updated; did that help? I'll reword as much as you need me to. This is a pretty complicated subject, but once you get the hang of it, it'll seem much easier.
Comment: Basically all I want is for the object to be glass/plastic like and let the background image be visible through it. I know this is a simple fix but I just cant seem to get it. I followed what you said but it doesn't seem to work. Here's a link to the file if you ever have time : http://pasteall.org/blend/index.php?id=50526
Comment: Alright, I don't know what's going on with that file, but I can't seem to even select your lightbulb. However, if all you want is a nice glass material without fussing about all the rest, try using a principled shader, and playing with the transmission slider (that's transparency). It calculates refraction and fresnel automatically!


Responding to reviewer comments in IEEE conference

Question: My paper was accepted into IEEE COMPSAC (a comp sci conference). As far as I can tell, it was a straight accept and not "conditional acceptance". The reviewers had some comments/questions on my paper. However, I can't find a means to reply to comments anywhere on the website and the notification email didn't mention the need/mechanism to respond to comments either. Do I still need to respond to reviewer comments?
Comment: You take on board useful comments.   There is no need to reply to comments.  I'm aware of conferences that function more like a journal; not too sure about your conference though.
Comment: Thanks for the quick response!
Answer: There are some computer science conference that have a so-called rebuttal period, in which the authors get a chance to reply to the comments by the reviewers. However, this happens before the decision to accept or reject the paper.
Once your paper reached the "accepted" stage, there is no need to reply to the reviewers. The paper has been approved with the expectation that when you prepare the final version of the paper which will be published, you take the reviewer comments into account in a careful way.
This does not mean that each and every change request by the reviewers need to be implemented. Those requests that you believe make the paper worse can be ignored by you, without a need to mention this anywhere. If the paper changed a lot (for the better) because of detailed feedback, it is customary to thank the reviewers for their suggestions in the acknowledgements. There is no obligation to do so, however.


Learn a new language in between the non speakers environment (Same native language as mine)

Question: I am planning to learn French as my third language. I am native Hindi speaker and my second language is English. I was going through few websites how to learn. Then I came to this video How to learn any language in six months | Chris Lonsdale | TEDxLingnanUniversity and it states - Use new language as a tool to communicate from day 1. Secondly he says you should know how they other person communicate by oserving their body language, the mouth and the facial expressions. The problem is I am surrounded by people who are not speakers of French. So what should I do?
Answer: You could watch french youtubers. Youtubers speak the language you'd listen in the street and you can see their body language and expressions.
Also you could watch this:
Easy Languages - French
Comment: wow! how this simple thought didn't came into my mind. BTW thank you.


Play .ogg on command line

Question: How can I play a <code>.ogg</code> music file on the command line? On Linux I can use ogg123, but what about on Mac?
Answer: You can still use ogg123 through the The Ogg Vorbis CODEC tools, installed through the MacPorts Project.
Comment: It's seems good, i installed the vorbis-tools so how i play now? afplay not play and have no command ogg123.
Comment: On the first link I give you says that there's a configuration argument which is: `--enable-ogg123`. I guess you'll need to use it.
Comment: understood :), i dont know the macports very well, i try pass the argument like as follow: "sudo port install vorbis-tools configure.args=--enable-ogg123" but dont works, its correctly?

Play .ogg on command line


applications sometimes keeps bouncing, won't open and won't respond to force quit

Question: Most of the time my macbook air works fine. Only problem is that when I just turned on my pc and want to open some applications , often these applications won't open and force quit does not work. Currently, I just wait a couple of minutes and then everything works just fine, but actually I don't want to wait, so I was wondering how to solve this problem. Any suggestions?
Comment: Welcome to Ask Different. It would help us if you provided additional info, such as the types of devices, OS, etc.  Also let us know what you've already done to solve the problem yourself.  Please see [ask] for how to ask good questions that have a better chance at being answered. - From Review
Answer: Try nvram reset
If didnt help
Reinstall those apps
Worked for me


Buying online ticket Berlin-Gliwice

Question: I live in Canada and try to buy online two day time train tickets from Berlin to Gliwice Poland  For May 03 .  I can't purchase it online for some reason but I am not comfortable to travel to Europe without reservation on train and not having tickets purchased.. what should I do ?
Answer: Did you try bahn.de ? I was able to find a few (good) connections that you can buy directly, specifically if the connection only involves EC and IC trains and not local ones.
For example leaving at 9.37 in the morning takes about 7.5 hours and with a price starting at 40 Euros. The 12:37 was even less: only 30 Euros. You may have to create a Deutsche Bahn account to book this, but it's a free account.
In general you should have no problems buying this directly at the train station at the date of departure, trains almost never sell out completely and if worst comes to worst, you just take the next one: there are around 20 daily!
However, same day tickets are typically more expensive since you can't make use of the substantial early booking saver rates.
Comment: Be aware though, that the few connections you can book online seem quite inconvenient. With the 12:37 connection, you will have to change trains four times, while many of the 'unbookable' connections only have one transfer. It is also not possible to book a print-at-home or digital ticket. You will have to get the paper tickets sent by mail.

Buying online ticket Berlin-Gliwice


Chipset supports 8gb of RAM but computer is 32bit?

Question: I have a Compaq Pressario SR1222NX that I am looking to upgrade the RAM on.  So the max supported RAM is for my computer is 4 GB.  This makes sense to me as the 32 bit address limit is 4GB.  However... According to intel, the chipset of my computer will support up to 8GB.  So I dug around a little bit more and found This document from intel that specifies that "[8000MB] exceeds a 32-bit address limit of 4 GB. In a 32-bit system, only the first 4 GB of memory will be
accessible".  Apparently, all I have to do is install a 64bit OS.  I am very doubtful of this as my computer has a 32bit Intel Pentium 4.  So, I am wondering if the 8gb of ram will work in my computer without modifications, and if not, what modification would I have to make?
Comment: Just because the chipset supports 8gb does not mean the bios will.
Comment: The statement in the document from Intel is simply incorrect. The 4GB limit on 32-bit operating systems is a virtual address limit, not a physical memory limit. They are frequently confused because some 32-bit operating systems also have a 4GB physical memory limit, but they are totally different limits. It's very unusual to see this kind of mistake on an Intel tech document though.
Answer: 32 bit systems have supported more than 4 GB of RAM for well over a decade, through the use of PAE.
That said, the specs say that your computer's maximum supported memory capacity is 4 GB, so it's 4GB, and what the chipset supports doesn't much matter.  It might be a BIOS limitation, it might be that the system board only supports a maximum DIMM size of 1GB, it might even be that the system is so old they hadn't considered the existence of larger DIMMs.  Regardless, the better approach is to buy a new computer, rather than throwing money away upgrading this one.  It's over 10 years old, FFS.  That's beyond geriatric in computing terms.  It's almost an antique.
Answer: The chipset supports some 64 bit chips, and if you had a 64 bit capable chip you certainly could. This chipset's around the time intel made the transition, and from checking a random sampling many of the chips it supports are 64 bit.
However at the time the system was released, 64 bit windows wasn't really a thing. I suspect most systems ran xp, and 64 bit support for XP was not too good.
That said, if its ddr2 some systems have issues with 2gb sticks, and you'd need 4 slots (so 4x2gb) to max it out IIRC.
So, it might work or it might not. However its a reasonable bet that if you have the slots, and the right type of ram, detected in the bios, and a 64 bit OS, it should work fine.
Answer: Compaq Presario SR1222NX will support only 4 GB ( 2 x  2 GB) despite what the chipset can support. The memory controller can hold up to 2 GB on each of the two slots. 8 GB is not possible with your system even with 64 Bit OS.


Why do all the aliens turn to dust when they die?

Question: In the film, I Am Number Four, every time an alien dies, they turn to dust.  The manner of death doesn't seem to matter, as we see this happen to aliens who are stabbed, shot, etc.  The film suggests that we're seeing many different species of alien, from many different planets.  And yet, any non-human in the movie turns to dust when dead.  Is there some explanation for this?
Comment: Cuz you can't leave bodies behind for the government to dissect.
Comment: Well the visual effects were great :)
Answer: The Loric do not turn to dust (they did in the movie but that was wrong), only the mogadorians do. This is because they had evolved with rapidly decaying genes, it is briefly touched upon in The Lost Files: Nine's Legacy - Sandor uses the IMog which uses the dna of a mogadorian to track them however Nine mentions that they constantly have to refill it, so to speak, becasue it decays so quickly.
Answer: I think BBlake is right.  I haven't seen or heard an in-universe reason for it.  I think it's a combination of "so there are no bodies for the government to find" and "this makes the aliens look extra alieny".


Using data from an Excel spreadsheet in QuickTest Pro

Question: I have been trying to figure out how to do this for a little while.. Here is my situation:
I have an Excel spreadsheet (lets call this "workbook.xls" and I have two sheets that I need to use for my script. One sheet has a column of data "columnA" and I am trying to put cell A2 (A1 is a header) into my QTP script to use.
I want to be able to use this specific value and then process some data and then use the next cell, A3 to process another procedure/process, and so on.. Is this possible?
In other languages, I know that I could use a for loop to iterate through the data, but I am getting stuck on trying to process the data and then going back through the loop to get the data.
For example:
Excel may have A2 as "1" and A3 as "2". I want to be able to put the value of A1 into an input field on the browser.. Then I want to be able to do some actions (clicking, writing to another file, etc) with this value.. Then I want to move onto the value A3 and put the value of A3 into that same input field as before and then do some other actions (that may not be what I did with A2). I am wondering how I could achieve this scenario.
Thanks in advance.
Answer: Yes, it's possible. Assuming I understood your question correctly you could do something like this:
Set xl = CreateObject("Excel.Application")
xl.Visible = True  'set to False for production

Set wb = xl.Workbooks.Open("C:\path\to\workbook.xls")
Set ws = wb.Sheets(1)

firstRow = ws.UsedRange.Rows(1).Row
lastRow  = firstRow - 1 + ws.UsedRange.Rows.Count

For i = firstRow+1 To lastRow
  val = ws.Cells(i, 1).Value   'get value from cell
  'do stuff with val
Next

wb.Close
xl.Quit

Answer: A test's DataTable is an Excel spreadsheet. You could import your data into your test's DataTable in QTP - in the default sheet(s) or add your own - and then access them in code:
Set sheet = DataTable.GetSheet "Sheet Name"
numRows = sheet.GetRowCount

For index = 0 To numRows
    value = sheet.GetParameter(index)
    'Do something
Next


Legal consequences and conviction for celebrities

Question: I know that may be this present question can show a little bit of naivety and the answer can be somehow obvious and trivial, but since I'm not sure about these issues, I'll be asking it anyway.
Are celebrities subject to the same laws as poor people such as, let's say, not paying taxes or any other equal-level crime?
Comment: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/99856/discussion-on-question-by-abdul-legal-consequences-and-conviction-for-celebritie).
Answer:
Are celebrities subject to the same laws as poor people such as,
  let's say, not paying taxes or any other equal-level crime?

Yes. Sometimes laws are enforced less harshly as a matter of law enforcement, prosecutorial and judicial discretion against the rich, famous and powerful, than the poor, but they are subject to the same laws and the authorities have the same power to enforce those laws against a celebrity or other rich or powerful person, as they do against anyone else.
Most criminal laws provide that factors such as whether someone is gainfully employed, whether they pay restitution for an offense, and whether someone has otherwise good character and be considered as grounds for leniency in sentencing someone for a crime of which that person is convicted, so that can systemically benefit such people at sentencing.
Also, the famous, rich and powerful may be seen as particularly credible in a trial by jurors.
They may be able to afford and support highly competent and exhaustively thorough legal representation, while the poor often get an overworked public defender with very little time or resources to devote to their case, or only a very inexpensive private criminal defense lawyer who similarly has limited resources and is rarely the most highly competent person in the field.
Similarly, the rich and famous can typically more easily be released on bail or on a personal recognizance bond pending trial, and being at large, rather than in jail, prior to being convicted, greatly reduces the pressure to plead guilty, the harm caused by the charge if there is an acquittal, and the ability of the defendant to mount a defense to a charge.
But, that doesn't change the fact that the same law applies to everyone, although this too has some bias inherent in it, as this famous aphorism illustrates:

The law, in its majestic equality, forbids the rich as well as the
  poor to sleep under bridges, to beg in the streets, and to steal
  bread.

-- Anatole France (16 April 1844 – 12 October 1924), born Jacques Anatole François Thibault, a French poet, journalist, and novelist, in Le Lys Rouge [The Red Lily] (1894), ch. 7 (In the original French, the quote is "La majestueuse égalité des lois, qui interdit au riche comme au pauvre de coucher sous les ponts, de mendier dans les rues et de voler du pain.").
Anatole France's point is true for somewhat deeper than the somewhat flip expression of the idea in this famous quotation suggests.
As a general rule, economic harms to others that people who cause them can usually remedy by actually being able to pay money as a result of a judgment in a civil lawsuit, are usually not defined as crimes. For them, the threat of a civil lawsuit is a sufficient incentive to modify their behavior.
In contrast, economic harms to other that the people who cause them usually lack the ability to remedy by paying money to someone who brings a civil lawsuit seeking a remedy for the harm, are often defined as crimes, because the threat of a civil lawsuit does not adequately deter their economically harmful conduct.
Likewise, one of the reasons that authorities choose to pursue a matter with criminal charges rather than leaving it to the people involved as a civil matter is the reality in cases where charges are brought that a civil lawsuit would be a futile means to attempt to punish a defendant for clearly improper conduct that harms others.
Answer: NOTE: While I have been very critical of the initial wording of the OP, since the ammended version is acceptable and the poster has not reverted the edition, I will try to answer it.

In general, in most Western countries, the law is equal for everybody1. But that does not mean that every criminal is equal. For the purpose of example let's use Cristiano Ronaldo (as you already mentioned him) and a bank robber.

The law: Obviously, not all the crimes are equal. CR's tax evasion is a crime that has some penalties set, the bank robbery is a different crime that has different penalties set. How these penalties are decided is a political issue, and it is not the judge's role to amend it even if he thinks them unfair2.
It is unlikely that CR will get caught robbing a bank (probably that is a net loss of income when compared with other activities) so the kind of crimes he is likely to commit is a different one, which will affect the legal consequences he risks.
Additionally, not all the legal codes are the same. In some countries tax fraud may be seen as less of a crime (or a "victimless crime") while in others it is a more serious offense. You cannot just compare the sentences among different countries3.
The crime: The bank robber enters a bank and openly performs a clearly illegal action. But a white collar crime like tax fraud does not happen openly: there will be attempts to disguise the crime as a legal operation. It does not even CR to actually perform the action, it can be ordered to some underlying, and there may be no single action that is illegal per se but just its combination.
As a result, once the bank robber has been identified and evidence collected the case is rather straightforward, but in the white collar crime it can be difficult to establish even that a crime has happened at all, not to mention who is actually responsible for it. This gives an incentive to prosecution to reach a settlement4
The means: The bank robber probably will have to do with some part-time lawyer (or just with overburdened free legal counsel), CR will have a team of top lawyers specialized in the crime he is accused for5. This is somewhat unavoidable unless you take away the accused freedom to chose their lawyers, which is a troubling proposition. Of course, this is another incentive for prosecutors to reach a settlement.

In short, to answer your question, celebrities are under the same legal system than common people. But if you want to compare their sentences to common people's one, you have to do some fine tuning to adjust for the kind of crime that a celebrity is likely to commit.
All of the above does not mean that the legal system is impervious to social influences. The legal system runs on persons, and persons do have a mind, prejudices and quirks6. It would be naive on my side to claim that someone's public status would never affect anyone involved in the legal proceedings; but the laws applying to them are the same.
But the celebrity status may be a double edged sword: it may also attract public attention and force prosecution and judges to show a harsher stance7.

1 There are some exceptions that may affect elected officials and heads of state, but those are counted and most times only mean that some extra steps may be necessary before a trial begins.
2  If you wonder why the legal code is "harsher" with the bank robber than with the tax evader, then you have a question for https://politics.stackexchange.com.
3 As I commented earlier, that a two year sentence for a first offender gets suspended/commuted into a fine is not that unusual in Spain.
4 And remember that in that a tax fraud case it means that the state recovers the money that it was earned plus fines and interests.
5 If that bothers you, remember that CR also has access to more and probably better doctors.
6 You can find some notorious examples in some sentences related to the Civil Rights of black people in Southern USA. Not that they are the only examples or the worst, but they are rather well publicited.
7 For what is worth, I did read some news about an association of tax collection personnel claiming that CR had had it easy when compared with a similar case that involver F.C.Barcelona's Lionel Messi. But:

Lionel Messi was not jailed either and the charge was that CR's fine should have been higher.
This reinforces my point that the accused celebrity can work against him, by inviting a higher level of scrutiny by the mass media/public.
Comment: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/99855/discussion-on-answer-by-sjuan76-legal-consequences-and-conviction-for-celebritie).


Block Naming Issue

Question: I used Theme Developer module to find the candidate name for a block that I'm using and it gives me this candidate name: block__menu_block__1 But it doesn't take action when I name as block--menu-block-1.tpl.php . I've tried several other variations to no avail, and I have cleared my cache.  What would I name this block?
Answer: Checkout the template suggestions: http://drupal.org/node/1089656
It should be: block--menu-block--1.tpl.php
Answer: When translating from a suggestion to a template filename, Drupal replaces every underscore with an hyphen; in this case, "block__menu_block__1" becomes "block--menu-block-−1.tpl.php" (there is a hyphen more than you used).
The code that converts underscores in hyphens is in drupal_find_theme_templates().
<code>if (!isset($info['base hook']) && !empty($pattern)) {
  // Transform _ in pattern to - to match file naming scheme
  // for the purposes of searching.
  $pattern = strtr($pattern, '_', '-');
  // …
}
</code>

Block Naming Issue


git - only fetch the files, not the history

Question: when I am running git pull or git fetch, I obviously retrieve both history and files. For huge projects, that takes very much time. I wonder how this process could be sped up, as for some projects I am only interested in the source code and not in the history. Is there a way to tell git that I only want to fetch the current snapshot of the files and not the whole history as well?
Comment: To the best of my knowledge, this isn't possible. Actually it's not what version control is all about.
Comment: Git 1.9/2.0 (Q1 2014) will be much more efficient with shallow cloning: http://stackoverflow.com/a/21217267/6309 and http://stackoverflow.com/a/21217326/6309
Answer: You probably want to look at the --depth option in git clone--called a "shallow clone".  In particular, you probably want:
git clone --depth=1 <url>

If the project is on GitHub, you can always use the download links from there.  Note, there are some catches to using a shallow clone:

Create a shallow clone with a history truncated to the specified number of revisions. A shallow repository has a number of limitations (you cannot clone or fetch from it, nor push from nor into it), but is adequate if you are only interested in the recent history of a large project with a long history, and would want to send in fixes as patches.

But that sounds like something you can live with.
Also, as positron pointed out, you can do this with git archive as well.
Comment: @jszameister Git simply doesn't support the concept? I think you've misunderstood.
Comment: I completely forgot about the remote option to `git-archive`!
Answer: If there is a webview like gitweb or cgit, you can very well take a snapshot. But I don't think fetch of the code alone is possible. Because fetch is working on your git objects and not the code.
git archive --format=tar --remote=gitolite@server:repo.git HEAD | bzip2 > repo-snapshot.tar.bz2

Comment: That sounds good, however it looks like it's not supported by github. +1 anyway.
Answer: You can use a shallow clone:
git clone --depth=1 git://url/of/repo

However you won't be able to commit/push changes made in a shallow clone.


If Spell Vamp affects almost every single ability, why do only AP mages buy it?

Question: I heard a lot of people saying this, but I still don't get it. If Spell Vamp affects every single damage ability, why do I see it only on the ap carries?
Comment: I think spell vamp used to be built on melee carries that used skills to do the bulk of their damage, as opposed to their auto-attacks, but ever since Riot has started replacing AP (*ability* power) coefficients on abilities with AD coefficients, it's lost its usefulness since you can't get spell vamp without getting AP focused items, so it becomes a waste of gold.
Answer: Spell vamp is highly useful, but, excepting runes or champion-specific abilities (such as Morgana, Olaf, or Lee Sin), it is very hard to find on items.
The only item in the game with spell vamp is the Hextech Revolver and the items it builds: Hextech Gunblade and Will of the Ancients.
Hextech Gunblade is an expensive waste of itemization for any non-hybrid champions (like Akali, Jax, or Ezreal), and Will of the Ancients provides a straight AP bonus, which means it too is wasted itemization for non-AP champs.
In short, most AD champs that could benefit heavily from spell vamp (such as Urgot or Lee Sin), won't benefit from the AP that comes with it, meaning there are better items to spend gold on.
If there were pure AD + Spell Vamp itemization, you'd see spell vamp on a lot more champions.
Answer: Spell vamp only affect skills that deal magic damage. This includes most skills but there are numerous skills that do attack damage. Also not everyone need's spell vamp. To get anything from spell vamp you must first do quite a lot of damage. If you are an AD carry who for has a skill which does magic damage you'll be investing into AP instead of AD defeating the purpose of being an AD carry. Lifesteal would be a better effect for that AD carry.
Comment: Spell vamp also affects skills that do physical damage, it affects any damaging skills. In contrast, lifesteal only affects autoattacks.
Comment: Nearly correct, Spell Vamp affects all skills that do not apply on-hit modifiers with the exception of Poppy's Devastating Blow. The real reason is that the only spell vamp items in the game also give AP, and are more useful on AP style champions who can benefit from the stat. Lifesteal can be bought directly.
Comment: @Lortian Except those that modify your auto-attack, like Decisive Strike. But you're right. **Many physical damage abilities, like Volley, benefit from spell vamp.**
Answer: Since spell vamp scales off the damage of your skills, usually the champions that do the most damage through skills are AP carries.
Also, all items that give spell vamp currently also give AP, which would be wasted on non-ap scaling heroes.
And finally, since AP carries generally are the ones that revolve around using their skills as their main source of damage, and spell vamp helps to keep them safe while doing so by providing a sort of offensive defense.
Answer: Take a look here: Do any on hit effects from any champion abilities or items get affected by Spell Vamp?
Sometimes, you can get spell vamp as support to help your team (Will of the ancients).
When a NON-ap carry get it, you lost one slot in your inventory. Even an ad carry can get spell vamp, Take a look here: Spell vamp / Life steal and AD scaling abilities
You have only 6 slots. You need the best set to your champions, and even Spell vamp being a good thing, there are others even better.


Tessart4j on unix machine

Question: I am using tess4j.jar to extract text from scanned PDF file (OCR files) in my java application.It is working fine with gsdll32.dll,liblept168.dll,libtesseract302.dll on windows machine. Now i have to deploy my java application on windows machine ,there i can't depend on .dll files . Is there any way to workout tess4j on unix machine.
Answer: Download Tesseract source and compile it. Tess4J will work with the built shared library objects.

Tessart4j on unix machine


How to calculate mixing ingredients to a certain fat percentage?

Question: Given two ingredients, one with 42% fat and one with 3% fat, how can I calculate how much I will need of each to get 9% fat?
Comment: I'm voting to close this question because it's really just math.
Answer: As a matter of arithmetic, what you want is for the weighted average fat content to be 9%.  We can say
42X + 3Y = 9
where X and Y are the fractions of the whole that are from each of the two components.
X+Y=1
as the parts add up to the whole, so
42X+3(1-X)=9
leading to
39X=6
This means that a mixture of 2/13 42% fat plus 11/13 3% fat will make 9%.
It's important to be consistent.  If your fat percentage of both ingredients is by weight, then work in weight throughout, if by volume, work in volume.
To put this into practice, let's say both are by weight, and we want 100g in total.
2/13×100g = 15.4g
11/13×100 = 84.6g
You can't measure that accurately, so round to 15g of 42% fat and 85g of 3%, and you'll have 100g of 9%
Answer: This is really more of a math question than it is a cooking question. However, I love math questions, so here we go.
If we have two ingredients, A and B, which contain a% and b% (respectively) of something (here, fat), a mixture of the two consisting of x% A and y% B will contain (xa + yb)% total fat. Note that this works because a, b, x and y are all percentages. To find out the exact quantities of A and B you need, we use x + y = 1 (assuming two ingredients only and 100% = 1, i.e., we work with proportions/fractions rather than percentages).
Thus, to obtain an end result with z% fat, substituting y = 1 - x
we find xa + (1 - x) b = z, which simplifies to x = (z - b) / (a - b).
For your specific example, we have a = 0.42, b= 0.03 and z = 0.09, which gives x = 0.06 / 0.39 = 0.154. In other words, about 15.4% of your end product should be A (the high-fat ingredient).
PS. It seems that math formatting is not enabled on this site; but perhaps I am mistaken. If I figure out how to format the above using MathJax, I will update the answer.


Flex socket crossdomain

Question: I am trying to connect to a socket server from flex.
I read, on adobe's documentation, the client automatically sends a "request-policy-file" xml element to the socket before allowing it to be opened, and should receive a policy file.
The client sends the xml element as expected, My server receives it (on the port I want to use, port 6104) and replies on the same port with:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
  <site-control permitted-cross-domain-policies="all"/>
  <allow-access-from domain="*" to-ports="*"/>
</cross-domain-policy>

To the best of my knowledge, this should be the most permissive policy available on a socket.
The flash player logs indicate a timeout looking for the socket policy file, although I know my socket returned the response immediately.
What should I do ?
Comment: How do you know the socket "returned the response immediately?" Are you monitoring this on the machine with the Flash app?
Answer: Try using master-only.
Master-only is saying it's using one policy file as a master.
"All" is saying, all domains need a policy file, so it will
keep looking for policy files. Use his and see if you get a timeout.
Cross Domain Policy "master-only"
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
  <site-control permitted-cross-domain-policies="master-only"/>
  <allow-access-from domain="*" to-ports="*"/>
</cross-domain-policy>

Reference
http://jodieorourke.com/view.php?id=108&blog=news

Flex socket crossdomain


How do I control a conveyor to start and stop in same location using optical rotary encoder

Question: I am a complete novice at arduino. I just want to know if this is possible before I start investing in components. I need to start and stop a chain drive conveyor {can't slip} powered by a 12 volt motor in the exact same place each time I manually start the cycle. I want it to stop automatically. The controller would have to power a relay to power the motor due to high amp draw of motor. This is on a piece of equipment without access to any other power supply but a 12 volt battery. I am looking at an optical rotary encoder to count the revolutions of the shaft. I would count the revolutions the shaft makes between my start and stop point and I assume enter that in the program. Is this possible?
Thanks
Comment: definitely possible .... it would be more reliable to sense the conveyer belt itself, in case there is slippage between the drive and the belt
Comment: That sounds fine. Just note that when powering up the system, you don't know the position of the conveyor. If you need that, you'd have to add something to manually "home" the conveyor, or add another sensor to find the "home" position of the belt. Ffor example adding a magnet to the belt, or a piece of reflective tape, and using a hall-effect sensor/photo-reflective sensor to find the "home" position. After that you only need to count rotations of the rotary encoder.
Comment: Would a hall sensor work in a dirty or wet environment?
Answer: Although your solution would work, it seems open to problems such as missed clicks, starting at a different place etc.
A better, more robust and error free solution might be to use a hall sensor.
Essentially what a hall sensor does is close a switch when a megnetic force is applied. So all you have to do is add a magnet to your conveyor/chain. This way, you can easily control where you want it to stop just by moving the magnet, and it doesn't matter what the starting position is because it will always stop as soon as the megnet reaches the sensor.


android unit testing ui recorder a'la VS2010

Question: I wonder, is there a UI recorder out there to automate unit test creation for android projects. I know the android SDK includes JUNIT support. I'm looking for tools that automate the process of creating test scripts. VS2010 has a built in recorder for instance that allows the automation of gui testing by recording the use of the application. This can then be saved as a test script and rerun after any changes are made to the application. So is there something similar for android using JUNIT or s similar testing framework?
Answer: Bitbar has developed a tool for that, it's on Alpha now so anyone can test it for free. You can record the test on a real device and it will output Robotium tests from it.
bitbar.com
Comment: This sounds interesting. I'll check that out, thanks for the info


Do I really need all these Certificate Authorities in my browser or in my keychain?

Question: There are lots of strange looking Certificate Authorities in my keychain as well as Firefox. I am sure they are legitimate CAs (as they are the same on my Mac and PC and other computers I checked). And by strange I mean they seems to be specific to same other countries or organizations that I am sure I have nothing to do with, is there a way to safely remove these unnecessary CAs? Is there a list for regular US users or a way to disable them and enable them when they ar needed?
Comment: Keep in mind a US site can use a cert from a non-US issuer. They aren't geographically restricted.
Answer: The Web is worldwide. That you are a "US user" does not mean that you will only look at US websites.
You can remove any CA certificate that you do not wish to trust. That's your prerogative. The only consequence of removing a CA certificate is that the machine will cease to automatically accept as valid any certificate issued by the said CA. Translation: some HTTPS Web site may begin to trigger scary warnings, which you can always bypass, but which are scary nonetheless (and training yourself to bypass scary warnings might not be a good idea anyway).
The truth is that, as a user, you have very little information on which you could base your decision of trusting or not trusting any particular CA. Ideally, you would trust only those CA for which you can establish a clear responsibility path down to you: the CA which will give you a lot of money in case you get swindled due to a mistake made by the CA. However, there is no such CA. Instead, what you have is a list of "default CA" who made a deal with the OS vendor (Apple, in the case of Mac OS) so that the OS vendor accepts to include them as "default CA". These CA, and Apple, are way too smart, legally speaking, to give you money in case of any problem (as a Mac user, your money relationship with Apple rather flows in the other direction). Yet, if one of the "default CA" begins to behave improperly, that's Apple public image which is at stake.
So my advice would be to let things as they are. This is what almost everybody does. Remember that, in any case, the point of the CA is to validate the certificate, which does not mean that the corresponding site is maintained by honest and trustworthy people; the only thing that the CA guarantees is that the Web page you are looking at really came from the Web site whose name is in the URL bar.
Comment: In addition to that: let go of the notion that PKI makes things secure automatically, and the CAs are not a problem anymore :-)
Comment: Someone did an experiment and deleted all but chosen 10 CAs from his browser. He used that setting for a few months and was still able to surf the web like he used to - almost all the sites he visited still worked. I don't remember the details of the experiment though, but it clearly showed that casual web user does not need that many CAs.
Comment: "the only thing that the CA guarantees is that the Web page you are looking at really came from the Web site whose name is in the URL bar" This is inaccurate since any trusted CA can produce a fraudulent certificate for any domain that will be accepted by the browser.  Evil CA can trick your browser into thinking that you're securely connected to amazon.com's server when you could be connected to another (DNS poisoning) and be looking at a fraudulent certificate.
Answer: You don't require them : it's just a legacy habbit. Take a look at Project Perspectives
Comment: The only security without compromises is the one [Mordac](https://dilbert.wikia.com/wiki/Mordac_the_preventer_of_Information_Services) promises. For the rest of us, it is really a "pick your poison" situation. But thanks for pointing out that interesting initative.
Comment: agreed! The only unhackable system is the one that does not exist. Others can be hacked - **all** of them, it's just a question of time, effort, resources elaborated et cetera. Security in a real world is always a compromise
Answer: The set of https connections you will encounter breaks down into two disjoint subsets:

Those you care about: financial sites, email, work, cloud storage for your backups … any site where a compromised connection will cost you money, data, time, aggravation, compromise of other sites (the main reason email is on the list — password resets), etc.
Those you don't care about: most of the sites out there, where security is not an issue and they could just as easily use plain http for all you care.

For those you care about, you can click on the padlock icon in the address bar and see what CA is certifying this connection. You can even dig into the algorithms used, the dates of the certificates, and many other details, if you're interested.
For those you don't care about, well, you don't care! Session's been hijacked? Some CA controlled by an unpleasant government is messing with you? So what? There's no security issue and it doesn't matter.
So it really doesn't matter if all those CAs are there. When it counts, you can easily make sure that your connection is certified by a CA that you trust. The presence of all those others is irrelevant.
Comment: Not caring about the security of a site should not lead you to conclude that you don't care whether the CA used for that site is trustworthy.  A shady CA could manufacture a fraudulent certificate for the sites that you do care about (bank) and hurt you; you'd have no way to tell that this time you're not really connected to bank.com, but to a man-in-the-middle (no user can be reasonably expected to dig into certificate details every time he visits every important site). So the concern about the proliferation of CAs is valid.
Answer: You are lucky if you can identify which CA you could turn off or disable. Mostly letting it as is, is the best way to avoid any unnecessary problems for which you could encounter in the future if you disabled some CA.
If you are worried for any virus or alike, improve or get some good antivirus.


How to see how many new visitors from last week came back this week?

Question: Using Google Analytics, how can we see how many new visitors from last week came back this week?
Comment: You're in the right place. :)
Comment: Thanks, @JohnConde. Do you know the answer? :)
Comment: If I did I would be more than happy to provide it to you. But I don't, so I can't.
Comment: Just a heads up you're not allowed to add any identifiable information about your visitors into GA. So just be cautious and rather than asking people here about those terms contact Google. You use their servers, it's their terms.
Answer: Disclaimer: This is just top of the hat and I have not really tested this, yet.
The Approximate Approach
If you are OK with total returning visitors this week as compared to the new visitors last week, then it is fairly simple.

Select the time range (as a week) and also compare this to the previous period
In the Behavior section, check the new v/s returning visitors section
You should be able to see new visitors in last week as well as returning visitors in the current week

This might not be the exact solution which you are seeking for (since the returning visitors in the current period are not necessarily attributed only to the new visitors of last week, thats a subset of ALL the new visitors who have returned).
The Programming Approach
An alternative method is to add a Custom Variable for all the new visitors coming to the site, for this you will have to do a bit of cookie parsing. You need to parse the __utma cookie of GA and here's where you will find the structure of the cookies (you need to take the inital visit timestamp, compare it to today's date and if it matches, then this is a new visitor, set a custom variable for this visitor, let's say Week and assign it the value of the week number in the year (1 to 54).
Now that you have tagged New Visitors with the week number, all you have to do is -

Create an Advanced Segment with your desired previous week, so that GA will only display the visitors who have been tagged with that week number
Select your time range which matches your current week
Check the Returning Visits

Again, this can only work once you have done the programming bit and not for the data that already exists in your GA.