How to find what chord harmonizes with a given note in a given context?

Question: I was playing pink Floyd's Shine on you crazy diamond. The ending note of Syd's theme (famous 4 note melody) is high E but it harmonizes with C major chord. Also how are the chords relatively higher or lower like the notes?
Comment: Can you clarify your last sentence? I think you're asking how you choose the register of the chord you are playing, but I'm not too sure.
Comment: What I've found upto now is its all relative. But is there something like this chord is higher than that chord or something? I don't know what register is
Comment: Are you not sure why an E sounds good along with a C major chord?
Comment: Yes it's the third note on scale of C and forms a note in C major chord.
Comment: @ToddWilcox  I think Sudip is referring to the fact that there are many chords that will sound fine played over a sustained e note in the melody.  But it depends on the context which chord will be a better fit for a particular situation.  I think he is asking about how the context in which the note is used plays in to the decision of which chord works best in that particular context.
Comment: @Dom I think Sudip means that some chords sound higher or lower than the preceding chord in the same way a note will sound higher or lower.  But with chords there is probably some subliminal overtone thing going on which might cause you to perceive a chord going either direction depending on the context of the melody.  And I think the question is related to how the chord selection is influenced by the context of the melody note that is sustained over the underlying chord.  Like when you sing the same note and play different chords over the note, it changes the perception.
Answer: You have many, many options when harmonizing a melody. In this case, the E in the melody is the third in the chord used to harmonize the melody. Typically you would want to figure out what notes you are using in the melody and build your harmony around that. You would typically want to make most of your notes chord tones  of you're harmony, but it's not a requirement. For example a lot of melodies like to utilize the 9th even though it's typically not part of the harmony which is fine as it gives the melody a bit of additional color when put against the harmony.
As for how high or how low you play the chord (or the register you play it in), it's largely up to you and what instrumentation you are using and the feel you want. For example a lot of funk songs like to take advance of chord shapes high on the neck because it has the tone they want which includes the chord being  higher pitched while in country songs more open chords are used again for the tone and to take advantage of the lower register for that.
Comment: In the example OP provided the C chord is harmonizing with a single note.  The question seems to be about harmonizing a chord to play over a single note and choosing the chord based on the context.  And I think he means (although it's hard to describe) the relative pitch of a given chord being higher or lower than the preceding chord.  In other words does it/should it sound as if the next chord is higher in pitch or lower.  In the example, the C is perceived by me as a higher pitch chord than the preceding Gm - regardless of where each chord is played.
Comment: @RockinCowboy  in most cases you want the melody to be chord tones like I say in my post, whether it's only 1 note or many it's still valid. And I'm kind of confused by your last sentence as the chord itself should sound higher or lower based on how you lead to it. I can definitely find voicing of C to Gm where the Gm is higher pitched and sounds that way and there are reasons to write it that way and reasons why not to write it that way.
Comment: I'm just trying to decipher what OP is asking.  In the example used the C sounds higher to my ear when played after the Gm within the context of the underlying melody notes played on the guitar.  It sounds higher (perceived) regardless of the voicing or position you play the C in or the Gm.
Comment: @RockinCowboy I'd imagine that there are voicing that you would here the Gm as higher especially if for example you played the C open and the Gm above the 12th fret, but maybe you can try and help the OP by providing this general information in an answer form?
Answer: Very interesting question.  In the example you use, a C chord is chosen to harmonize over the e note which can be played on the open high e string on guitar.  So why was that particular chord chosen to harmonize with that particular note in this context?  And how do you go about deciding for other songs?
One thing that is important when harmonizing notes with chords is to be sure the chord contains most of the notes that are played at the same time as the chord. In your example, there is only one note being played under the C chord so it is critically important for that chord to contain that note.  The C major chord does contain an e - and in several chord voicings on guitar the melody note is in the chord at the same octave. But several other chords also contain an e.  So what makes the C major chord best in this context?
Looking at the context, we can get some clues.  The song in your example is predominately in the key of G minor.  The chord played in the progression next to the C major chord is a G minor (or Gm7).  One way that information can guide our chord choice is by following one chord in the progression with a chord that uses at least one note from the previous chord.  This will often help create a smooth natural sounding transitions between chords.  So in the example, the C major chord shares the g note with the adjoining G minor chord.  This is particularly helpful if you are modulating to another key or borrowing a chord from the parallel key.  In your example the C major may be borrowed from the key of G major which is the parallel key of G minor.
The chord played over a note will color it in a certain way or add a certain flavor (if you will).  The chord you use should support the overall emotion, feel, and direction of the song.
If the solos in the song and the melody pull heavily from a particular scale, that would influence your chord choice.  So if the song derives most of the melody notes in the solos from the G minor scale or G minor pentatonic scale, the chords you choose will probably fit better within the overall context of the song as a whole - if the chord contains notes that are in that predominate scale. In your example the C chord consists of notes that are found in the G minor scale (with the exception of the e which is required because that is our melody note).
The chord choices for harmonizing a melody will also be guided by the direction the melody takes the next chord.  Certain chords will transition better into other chords and the chord played over a melody of several notes should contain a few of those notes.  So if you have several choices of chord to play over a given section of the melody, first choose a chord that transitions well from the previous chord, then look at what the melody dictates for the chord which follows the one you are trying to solve, and choose a chord that also transitions to the next chord well.  In other words, the chord you are trying to choose to harmonize with your note, should transition well from the previous chord and to the next chord (if there is a next chord).
In many cases you can use the key of the song to dictate the most commonly used chord set for that key.  There are chord charts available on line for every possible key.  Your Pink Floyd example is not a good one because the C chord is not typically found in the key of G minor but may be borrowed from the parallel key of G major.  But most songs will fall into easily ascertainable keys and you can use the common chords for that key to help narrow down your choices.
Finally, to some extent, trial and error can work where strict methodology and formulas fail.  If you know what feeling the song should evoke, use the suggestions above to give you some options, and then try several of them and use your ear to judge which one gives you the desired effect.  If it sounds good, it is good.
For more detailed information about how chords relate to melody notes - read this:  How notes and chords fit together or this Choosing a melody to go with a chord progression
The second part of your question seems to be about chords sounding higher or lower than the previous chord.  With single notes, it is easy to hear if the following note is higher or lower.  With chords, it is not always obvious to the ear, especially with guitar chords.
With guitar, there may be several positions where you can play a particular chord and still hear the emphasis on the same root bass note.  Regardless of whether you play a C major chord in open first position, as a third fret A shaped barre chord, or as an E shaped barre chord on the 8th fret, it still sounds the same as far as relative pitch.
Whether a given chord sounds higher or lower than the previous chord, often depends on the context of how the chord is used to support the underlying melody.  Chords consists of several notes - and with guitar, several of those notes may be repeated in octaves.  Your mind will hear and perceive the relative pitch of the chord compared to the previous chord, based on which direction the melody is going.
For example - if the melody notes are going higher when you switch from a G chord to a C chord, your brain will hear the higher notes in the chord which match the melody notes and you will perceive the C as higher than the G.  If on the other hand the melody notes are getting lower as you switch from G to C, the opposite will happen.  Your brain will hear the C chord as it harmonizes with the lower notes and the chord itself may be perceived as lower than the G.
Or the perception can vary from one chord to the next on guitar depending on if the root note is in the bass and if the bass note of the voicing you choose is lower or higher than the bass note of the prior chord.
With piano, it's more straightforward.  If we don't consider inversions - on piano if you play the next chord at a position to the right of the previous chord, it will sound higher, to the left lower.


How can I search the bash history and rerun a command?

Question: Can I search history in bash and run the result?
Answer: Type Ctrl R at the command line and start typing the previous command.  Once a result appears keep hitting Ctrl R to see other matches.  When the command you want appears, simply press Enter
Note that while Ctrl R is the default, if you wanted the command (reverse-search-history) to be bound to Ctrl T you could configure that with the following:

bind '"\C-t": reverse-search-history'

There are a whole host of other readline bindable commands that are available to you as well.  Take a look at the bash man page.
Bash has many facilities to search and access interactive command history.  The most basic of which is the history builtin.  Typing just:

$ history

Will print a list of commands along with a numeric index, like:

$ history
1 clear
2 ls -al
3 vim ~/somefile.txt
4 history
$

You can then execute any of these commands using their numeric index by prefacing the index with a single !, as Mitch pointed out:

$ !1

Will execute the clear command.  The history builtin has many features itself, you can see more in the bash and history man pages.
You can also specify relative negative offsets when using the ! designator, so using our history list above, if we wanted to execute vim again, we could do:

$ !-2

Which is basically telling bash to execute the command you ran "two commands ago."  To run the previous command in the history list, we can just use !! (which is just shorthand for !-1).
The ! designator doesn't limit you to numerically specifying which command to run. hayalci showed that you can instruct bash to execute a command based on either the text it begins with (using !) or text within the command itself (using !?).  Again, using our example history list above, if we wanted to execute clear again, all we need to do is type:

$ !cl

and press Enter.  And what about vim?  That is as simple as:

$ !?some

The most important point from hayalci's response is the call to the shopt builtin:

$ shopt -s histverify

This will enable history verification so that commands that are matched by the !, !!, and !? designators are not blindly executed, but instead filled in on the command line so you can ensure they will do no evil before executing them.  This is even more important when you are executing commands as the root user.  This option can be set in your .bashrc startup file so that it is set whenever you log in.
As has already been pointed out, all of this information can be gleaned from the bash man page.  For the !, !!, and !? designators, take a look at Section 9.3 History Expansion.
Comment: +1 I have been Using Linux for over 12 years for all systems. I didn't know that existed. Wish I could +10 *how did I miss it??*
Comment: Also after pressing CTRL+R you can use CTRL+SHIFT+R multiple times to jump back to the previous command
Comment: On many systems, pressing the up-arrow does the same.
Comment: If somebody were to consolidate '!', '!!', '!?', 'history | grep', and 'ctrl-r' into a comprehensive answer, I would select it
Comment: `shopt` goes in bashrc, not bash_profile (or it won't be enabled for shells that aren't login shells).
Comment: You can also run `!!` to run the previously command. For example `sudo !!` to run the previous command with sudo.
Answer: You could also do:
history | grep "stuff"

it would return something like
num stuff

then you can type
!num

Comment: Explanation for `!num`
https://www.gnu.org/software/bash/manual/bash.html#Event-Designators
Answer: As an alternative to crtl+R, you can search history by typing
!text

This will search the history for the most recent command beginning with 'text'.
But I suggest you put this in your .bashrc to prevent execution of wrong command.
shopt -s histverify

This instructs bash such that, after any history actions (like !!:s/prev_text/after_text), it places the resulting line to the command prompt. Then you can review or edit the command, and press Enter afterwards.
Comment: Use !?text to re-execute the most recent command containing (as opposed to beginning with) "text".
Comment: If somebody were to consolidate '!', '!!', '!?', 'history | grep', and 'ctrl-r' into a comprehensive answer, I would select it.
Answer: I prefer to use history-search-backward over reverse-search-history. The former lets you type a few characters of the command then press the search key, as opposed to hitting the search key first then typing the search string.
By default on my system, M-p and M-n bind to similar functions but I prefer binding the arrow keys:
bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'

Answer: I have a really great alias, h. It's really just "history | grep", but I filter out previous "h command" entries with the "grep -E -v"
alias h="history | grep -E -v '^ *[0-9]+ *h ' | grep "

used like
h aliases
2003  less .bash_aliases

Comment: This can also be accomplished by adding the command to `HISTIGNORE`.
Answer: Excellent writeup, Sean!  I'd put this in a comment, but I'm a few reputation points shy.  :-)
Another related and useful technique is the ability to run a previous command while changing a word.  Say you typoed the directory name, or want to change the file name:
$ echo my name is bob
my name is bob
$ ^bob^jordan
echo my name is jordan
my name is jordan
Notice that the command is expanded, replaced, and output before the command is run, so if the wrong command is run you can see what bash thought it was doing.
Answer: As navigation through history using Ctrl-r is IMO cumbersome, you may want to consider hh:
https://github.com/dvorka/hstr
which makes navigation much simpler, straightforward and efficient - including running the command:
Comment: Once you install hh you can either use hh command OR bind it to any keyboard shortcut (typically Ctrl-r) as described in the documentation.
Comment: How to use it? Which keys to press to see this picture?
Comment: it binds to `ctrl + r` by default now
Comment: Reason to use hh: "As navigation through history using Ctrl-r is IMO cumbersome", How to use it: "Bind it to Ctrl-r" :- o
Answer: At the bash command prompt, type control-R, then type a few characters of the command you want and bash's readline facility will search through the command history for that command.
After you have started the search, you can type control-R again to jump to the next matching command.
Answer: If you have your shell configured to use vi key bindings (set -o vi or having set editing-mode vi in $HOME/.inputrc), then you search with <Esc>/some-command<Return> and hit n (next) or Shift-n (previous) to cycle through the command line history.
Comment: This one is the closest to vim users.
Answer: CTRL+R works just fine, like @John1024 suggested, but is somewhat tedious if many of your recent commands are similar and you want a quick way to scan them all. An alternative would be to use history:
$ history | grep keyword

Answer: I like HSTR, but I can't seem to be able to install it sometimes.
So I wrote an alias using fzf which mimics its behavior (hx, for "history execute")
alias hx='eval $(history | sed "s/^ *[0-9]* *//g" | fzf --tac --tiebreak=index --height=10)'

history : well, get the history
sed : remove the index column from the list (POSIX)
fzf : here is the magic, allows you to fuzzy-search the list interactively, move with C-J and C-K, and pick a command with Enter.
--height : set the numbers of lines shown.
--tac : revert list (more logical for a history)
--tiebreak=index : keep the history order when fzf updates the results
Answer: I have no idea why this is still not mentioned yet. You can set it in your per-user inputrc file like that:
nano ~/.inputrc

# Respect default shortcuts.
$include /etc/inputrc

# Use Shift+Up/Down to search history
"\e[1;2A": history-search-backward
"\e[1;2B": history-search-forward

Super easy, clean, per-user and flexible. Works without any major permissions and will be auto-applied on login.
Comment: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Comment: Or use `"\e[1;3A"` and `"\e[1;3B"` for Alt+Up/Down
Answer: # USAGE: find.history cd
# filter commands in shell history by a search term and execute the selected command
function find.history {
  eval $(history | grep "$1" | tail | awk '{$1=""}1' | tail -r | peco)
}

You will need to have peco installed.
https://github.com/peco/peco
[$]> brew install peco


How do I get the IP address of a switch

Question: I have a wireless AP+switch which I configured years ago, before moving, and haven't used for a while. Now I want to reconfigure it for my new network, but have no idea what I set as its IP address(It was probably something 192.168.xx.yy). What is the best way for discovering its IP? A script to spam the whole address space?
Comment: Does it have a reset button so you can just switch it back to the factory defaults?
Answer: If you can't remember the IP/subnet, you're likely not going to remember the security/authentication settings and passphrase either, so I'd just reset it to factory default.  There's likely a reset button on the back and some combination of power cycle/holding it down that you can find by googling the AP model for a manual.
Comment: +1 - nice observation.
Answer: The nmap command can quickly ping any address range. For example,
<code>nmap -sP 192.168.0.0-254
</code>
Comment: nearly -1... not so fast if you dont remember the subnet ;)
Comment: nmap -sP 192.168.0-254.0-254
Answer: By "spam", do you mean "scan"? If so, then yes that's one way to do it. You can use something like Angry IP Scanner to scan your subnet for devices with ip addresses and then try them one by one.
Answer: Can't you simply connect your PC to the AP/Switch with a direct cable and obtain the IP from your IP settings of this PC (Gateway)?
Comment: Switch has dhcp disabled.

How do I get the IP address of a switch


Why do drumsticks break?

Question: I understand that drum sticks are supposed to be hit with the tip, and the only reason you hit the drum set with the shaft is to do a rim shot- so technically it would take a lot of rim shots to break a drum stick.
How does a drumstick break then?
Answer: As any material, wood/plastic/carbon fiber will become more and more breakable when they take some damages. You don't only hit the drum with the shaft when you do a rimshot. On cymbals (crash or charleston), you can have differents sounds by hitting with the different parts of the drumstick. If your stick is already weakened, then sometimes even one little hit can be enough to cut it in two.
Keep in mind that when you are playing, sometimes you are so much concerned by your music that you forget how strong you can be and how loud you can play :) That's usually how I break drumsticks, playing some songs I love in live, or doing solos.
Answer: At the end of the day its all down to technique and placement. You can always expect to hit the bladed side of cymbals when the swing up and down from hits which acts as an axe to cut through your sticks gradually. If you are playing metal for example that is a lot of hits in a short space of time. Its wood verses metal the sick will lose.
The best way to prevent a stick from breaking is to make sure the contact is flat surface to surface on cymbals and try avoiding hitting the rims of drums during fills and progressions. because I tend to find I hit toms and snares heavier than symbols. One heavy rim shot can break a stick.
I also noticed that its mostly my hi-hat stick that wears quicker (in my case right handed would lead on the HH. Obviously it's swapped for lefties).
Answer: Drumsticks are not designed to take impacts over a small surface area. (that is, all of the force of your strike placed either at the tip, or along the shaft of the stick)
Good drumming ergonomics require the proper setup of your drums and cymbals.
Toms and the snare should be positioned so that the drums make contact with a large surface area of the stick.  Listen to what your rack toms sound like when you hit them first with only the tip, then hit them with as much of the stick, still getting a center-hit.
The cymbals are the same way.  They should be tilted slightly toward you, and it should be easy for you to strike the lathed edge across the cymbal, instead of hitting it dead-on.
To say these hits are the only ones you should make with your set is foolish.  The entire stick should be used.  And you will have passages in music where bashing is a requirement.  But bashing straight on and down shouldn't be your only mode.  Unless you like buying a lot of sticks.

Why do drumsticks break?


Hybrid vs introgression zone in natural populations

Question: In the book An Introduction to Molecular Ecology, the authors say that

Introgression is the diffusion of alleles from one population or
  species into another as a result of interbreeding or hybridization
  between them.

And that hybridization is (roughly) the breeding of two distinct species.
I thought that when we were talking about introgression zone and hybrid zone, it was the same thing.

But here is my interpretation:
See the image below. Across an area, you would have 2 populations of 2 species (A-E). They could interbreed in the middle, this would be called the hybrid zone (in C). But the change of allele (or the transfer of allele) between two populations is not only done by hybridization (B vs C). It can be done by a new hybrid breeding with a non hybrid (backcross, in B). Then, B to D would be the introgression zone.
I don't really know what would happen in that case when 2 hybrids breed together for the colours!
So my question is: What is the difference between introgression zone and hybrid zone (is my interpretation correct?)?
Answer: I think you're correct. See Harrison, R.G. and E.L. Larson. 2014. Hybridization, introgression, and the nature of species. J. Hered. 105: 795–809. Also see https://www.differencebetween.com/difference-between-hybridization-and-vs-introgression/
Interesting that you're received no responses to this. It's an interesting (and I think important) question.


Logic 8 - Creating Drum Tracks using MIDI

Question: What is the best way to setup drums in Logic 8 when using MIDI?  Is it better to split all of the different drum parts into separate tracks like base drums, cymbals, high hat etc.?
Answer: This isn't specific to Logic or MIDI, but I like to have all of the different drum sounds on different tracks so that they can be processed independently.  This isn't a necessity unless the sound you want is based on having this separation (for example, some electronic music where you might want to put a special effect on the hihats but not the kick and snare) but I find it to be useful in general for EQ and editing.
The tradeoff is in complexity and processing power: more tracks means more things to keep track of, more things to check if something goes wrong, and of course more computer power to process the extra audio, although this last concern isn't really a big deal until you use lots of effects.  Just summing audio is not very computationally expensive.
Comment: I use ToonTrack's EZDrummer and it will output the "mics" to separate tracks -- saves on CPU because you still have one MIDI line triggering one VSTi, but lets you compress, EQ and add effects to each drum mic just as you would if you were multi-tracking a live kit.
Comment: @Ian That's a pretty slick way to do it, if you're using a plugin for drum sounds!  It's much cleaner than having a a MIDI track and plugin instance per drumhead IMHO.
Answer: I tend to make specific "packs" of hits, using NI Battery or Logics Sampler I'll build one pre-set of 10 or so kicks, another of high-hats, another of snares etc.....
I find it handy to help develop my own sound (I write electronic stuff), my template project opens with the plug-ins loaded and ready to go.
Then if I need to I can still separate the individual drums.
I'll often process and re-sample loops I come up with, chop them up and re-sequence.
I also run each channel to a drum bus, so I can add some processing to the drums as a whole before they go to the outputs.
For my Novation Drum Station I've got individual inputs into Logic, and the same idea with a summing bus, sequence, experiment, record and process. then resample etc...
Answer: You really want to have everyone of your sounds separated in a different track so it can have its own EQ, Compressor, etc..  You can then send groups of your tracks to a common bus to add the same reverb to all your hi hats or stuff like that.
One of the best Batterys out there is Logic's UltraBeat (i am not shure if it is only available for logic pro)
It is also very easy to have all your different tracks processed independently:

You have to select a multiOutput
instance of UltraBeat.
Create some
auxiliary objects in the environment.
Open UltraBeat and select a different
output for the tracks you are using
(next to its name)
Select your auxiliary's inputs as UB 1-2, UB 2-3,
Etc... (remember to set your tracks
to stereo)

Hope this helps!
Answer: I would use UltraBeat and use the multiple outputs.  Make sure you get the multi output version when you pick it - or you can change it at any time without losing settings.  To get to those outputs, look at your UltraBeat in the mixer or environment, there will be a little plus sign which will add aux tracks for your additional outputs.  Then you select the output on the left side of ultrabeat per sample.
Ok, that's how you do it, but why would you?  UltraBeat has quite a bit of processing inside of the plugin, so you can get pretty far without complicating things.  If you want external plugins on something, follow the directions above and you'll be set up in a minute or two.
You'll probably want to route all those outputs back to another bus so you can effect all the drums as a group.


Does having more enabled modules make the site slower?

Question: Does having more enabled modules make the site slower?
I have installed 30 modules for my site, and I am afraid that it will become too slowly.
Answer: Yes.
However, 30 is nothing to worry about. You're in trouble when you go over 100 ;)
Install a bytecode cache (APC or XCache) to eliminate most of the slowdown of including many files, and make sure to periodically remove unused modules (usually every project gathers modules that get unused at some point during development)
Comment: I see that Commerce Kickstart uses 96 contrib modules.
Comment: Installing XCache made my pages render in half time. Thanks.
Answer: Having more enabled modules makes the Drupal bootstrapping slower, as more files are loaded and parsed. Apart that, having more enabled modules doesn't automatically mean to have a slower site, as not all the modules execute code for every requested page.
For example, if you have installed Views and you only enabled the front page view, Views will not be executed when the requested page is a node page. Although, the Views module implements hook_menu_alter(), and that is executed even if you have not enabled any view, but the Views module is enabled. Any implementation of hook_menu_alter() is invoked when the menus are rebuild, and that doesn't normally happen on every page request.
Comment: Having lots of modules that do "nothing" does make the site slightly slower. It has to do to the way the hook system works; Drupal does a [module_hook](http://api.drupal.org/api/drupal/includes--module.inc/function/module_hook/6) call for every module installed, every time a hook is ran. All of these checks can add up. On our site, module_hook gets called 13,000 times and that took 168ms; every little bit adds up.
Answer: In complement to both responses of @Bojan Zivanovic & @kiamlaluno which are right you should care about module interactions. Having a lot of modules increase the risks of bad modules interactions (like drug interactions). I would say having more than 50 modules becomes dangerous, and that you should check early that you do not use several modules for the same task domains.
As an example building pages with blocks, views, panels, fields containing views, blocks containing views, blocks containing panels containing views containing ... The idea is to get something that a normal brain can understand (how do my different pages are composed). This can have big impact on performances when several complex loading behaviours are hidden and chained. Another example is adding several ACL rules from several modules for each content.
If you fear for performances, always use profiling modules and track differences after each new module addition. Sometime a small hook with some SQL inside or a custom template will save your website time generation.
Comment: Is drupal made for "normal brain" ? :)
Answer: three things to keep in mind during site building that can speed up your drupal site are:

Reduce the number of modules
Check your mySQL query log for slow queries and tweak code / add indexes as necessary.
Caching (and hoping most of your users are not authenticated)

and regarding the module part obviously greater number of module slower the speed will be, as they required a larger RAM to process..
still 30 to 60 module wont be affecting your site so much .
the ration for time of site loading and number of module is like 100 module ll delay the site by 350ms to 650ms .
hope for u next site you wuold be keeping those points in mind..:)


Etherchannel between Cisco Catalyst 3548 and Linux box

Question: We have a Cisco 3548XL switch.
Fa0/1 and Fa0/2 are configured with the:
<code>    port group 1
</code>
option.
This gives me this:
<code>    switch#show etherchannel summary
    Flags:  d - default     D - down
            I - in use

    Group Ports
    ----- -----
    1     Fa0/1(I) Fa0/2(Id)
</code>
The trouble is, I am unsure which bonding driver option to use on the linux box.
The linux box is connected to Fa0/1 and Fa0/2 with eth0 and eth1 respectively. The bond is up with 802.3ad (LACP) selected as the driver option.
I am now of the understanding that the version of IOS on the 3500 series of switches doesn't support LACP.
My questions are:

Does the 3548 switch use PaGP natively
Should I use a different bonding method on the linux box such as balance-rr (0)
If I use a bonding method such as balance-tlb (5) that doesn't require any special switch support on the linux box, should I disable Etherchannel on the switch?
Shall I just find a switch that supports LACP 802.3ad such as a 2950 with IOS12.1 release 22?

On another note, I tried to configure the new port group on this switch using this command:
Regards,
Chris
Answer: You should be using bonding mode - 4.


Is there a maximum amount of protein the human body can absorb a day?

Question: Assuming I workout on a regular basis and I'm in constant need for protein for recovery.
Answer: I recently stumbled on a great article that talks about protein consumption for the purposes of building muscle (recovery included).  It's "The Myth of 1g/lb: Optimal Protein Intake for Bodybuilders".  To make a long story short, there was a clinical study to determine how much protein was necessary to build muscle.  It is still based on body weight, but the end number they came up with which even supported the highest demands in the study was:

0.82g/lb is the upper limit at which protein intake benefits body composition (Phillips & Van Loon, 2011)

Note that this number is for people who are trying to build muscle.  There are other benefits to having protein intake higher than this amount, but they are not related to recovery or building muscle.
If you aren't lifting heavy weights regularly, your protein demands will be lower.  If you have no renal issues (no kidney problems), you can safely consume 2g/lb protein.  The extra will be converted to energy through a Calorie intensive process or will be defecated out.  In short, there is no harm in consuming more protein than your body can absorb, but the benefits aren't related to recovery or building muscle.
Comment: Just note that @BerinLoritsch means 2g protein per pound of body weight. Not that you absorb 2g of protein for every pound you consume. He is also correct in stating (barring renal disease) over consumption of protein doesn't cause any harm. You will just pee it out. Therefore if you are just pouring Protein Powders into your body it is a waste.
Comment: (Plus insulin effects and ketoacidosis.)
Comment: Keto anything is kept in check by carbs.  Insulin response is not necessarily a bad thing, but understanding it will help you make decent decisions in light of your more global eating plan.  In fact, in healthy individuals insulin helps control ketone and glucose levels in the body.  http://en.wikipedia.org/wiki/Ketoacidosis
Comment: So thats like 0.36g/kg?
Comment: You applied the conversion the wrong way.  Per the artical:  As you can see, 1.8g/kg (0.82g/lb) is the point at which additional protein intake ceases to yield any benefits.
Answer: FWIW, I've been reading the book "Fitness for Geeks" recently, and it says on page 61:
The ability of the body to properly metabolize protein foods diminishes at an
intake of about 35 percent of calories, which is why you are not advised to go
crazy on protein intake and try to get the majority of your calories from it.
(Emphasis theirs).
The book cites Shabne, Bilsborough and Neil Mann, "A Review of Issues of Dietary Protein
Intake in Humans," International Journal of Sport Nutrition and Exercise
Metabolism, 2006, pp. 1, 129 as the source of that statistic. A Google search for that article led me here.
Protein is about 4 calories per gram, so on a 2000 calorie diet (which would be low for most strength trainers) getting 35% of your calories from protein would mean 2000 / 4 * 0.35 = 175 grams of protein.


ROC curve interpretation

Question: I trained a CNN model and a combined CNN-SVM model for classification. I wanted to compare their performance using ROC curve but I was confused which model is better. How to interpret the given ROC curves ?
Comment: Your second curve looks unusually regular, it's as if there wasn't enough points to calculate it with precision.
Comment: You mean by enough points the test data ?? Actually in the test data the the number of samples for each class are not equal.
Comment: it's not about the points in the data strictly speaking, but it could be related. the ROC curve is made of the points which correspond to the different possible thresholds in the trade-off between precision and recall. for some reason there seems to be very few of these points in the 2nd case (maybe even only one actually). maybe the method doesn't output a numeric value to be used as threshold?
Answer: If you hear from the area under the curve (AUC), you can find that the first classifier is better as AUC of the first curve is more than the second classifier. To know more about AUC you can find this post useful.
Answer: Some other answers alluded to a simplistic interpretation of the ROC curve: The higher the area under the curve, the better the model is at separating positive and negative groups.
The terminology can apply to any two labels, but positive and negative are most commonly used.
So what does the ROC curve plot? From the ROC curve you can measure the ability of the model to tell the two groups apart. Suppose the model produces a prediction $\hat{y}_i \in \mathbb{R}$ for some data. Based on this prediction you should make a decision to label that data as positive or negative. The ROC curve shows the false- and true positive rates of the model, depending on where that threshold is put.
Take for example a perfect model, which can fully separate the two group. There will be a band of possible thresholds $t$ where all of the $\hat{y}_{i \in -} < t$ and $\hat{y}_{i\in+} > t$. In this case, there will be no false positives, while having all true positives. The ROC curve will go through the point $(0,1)$.
If the model is not perfect, when there is overlap between the predictions of the two groups, there will be no threshold $t$ where the true positive rate is 1, and the false positive rate is 0. This means that the curve doesn't go through the left-top corner, but instead forms a curve. The area under this curve shows how good the model is, but that's not all. We can also use the shape of the curve to read what the model struggles with.
There is after all more than one way the data might overlap. If for example, the negative group has a very long tail that overlaps with the positives, that's different from two identical distributions.
Suppose the negative group has a long positive tail so that only the tail overlaps with the positive group. There still is a large part of the negative group that we can correctly label. Similarly, we can catch 100% of the positive group, at the cost of an elevated false positive rate due to that tail. This will be reflected in the ROC curve's shape. Because of this assymetric distribution of classification errors, the ROC curve will be assymetrical as well.
This is a scenario that looks similar to your second curve (with the two labels swapped). If this curve is correct, instead of a possible misspecification like @Erwan commented, You might be dealing with a relatively widely spreaded group that partially overlaps with the other.
Answer: The ROC curve shows you the number of items that are correctly classified as being in the positive class versus the number of items that are labeled as positive but are actually negative.
In general, you want to choose the model that has a higher True Positive Rate at a lower False Positive Rate or the ROC curve that converges to 1 the quickest, which means you'd choose the first model.
AUC is a good way to evaluate many ROC curves if they all have a similar shape, but when the AUCs are the same (which I've never come across in practice but could occur) then the shape of the ROC curve becomes important.
Answer: One additional view point i would like to add is that AUC is a ranking metric (what matters is the score order but not the score value itself). so if you order your scores before evaluating it with roc auc metric you can boost your score. Read more about here https://towardsdatascience.com/an-interesting-and-intuitive-view-of-auc-5f6498d87328
Comment: I don't understand what you mean by "so if you order your scores before evaluating it with roc auc metric you can boost your score."

ROC curve interpretation


Where can I find the number of banks by country?

Question: Seeking an open dataset listing the number of banking institutions that exist, and the country/countries they exist in?
Answer: Commercial bank branches (per 100,000 adults)
Data is collected by the International Monetary Fund, Financial Access Survey. Data has a friendly license.
On the right you will see a big DOWNLOAD button (CSV, XML or XLS)

If, for some reason, you don't want the data per capita, but instead total bank branches, then you can use this data set to get the population of each country.
Population, total
Answer: If you want the number of bank "companies" per countries, then you can harvest this data from Wikipedia
On the left menu-bar of every Wikipedia page is a link to "Wikidata Item". You can then use a Wikidata query tool to programmatically collect the data. See other questsions or do an internet search about Wikidata or SPARQL query language.

Or, use this website Banks by country for EU banks (including offshore territories).


Is it possible to mix a D-Link router with other adapters since my D-Link adapter won't work on Windows 7?

Question: I spent several hours yesterday on line and on the phone with (very rude!) D-Link tech support only to have them tell me that something was wrong with my new Windows 7 drivers.  I am returning my D-Link adapter today.  However, I have been running this router and adapter on my other two computers running XP for quite some time with great success and don't want to (can't afford to) change all that set up.  Can I find some other adapter that will work on my new computer or is it cheaper to buy a card to put inside or another wired modem from my cable company?
Answer: The brand of the wifi adapter does not matter. You can mix all sorts of router and wifi brands (so long as you're using the standard b/g/n speeds and not the boostmax/superboost/etc...)
Since you're having issues with your dlink adapter and windows 7. I'd suggest just going online and purchasing a
Answer: I think I know what happened. The modem you got from your cable company is a hybrid which means is part modem and part router and then you put the CAT cable to your router. There could have happened double NATing or something else that prevented it from working fine. D-Link tech should have caught that. My preference would be just a modem (if you can get it from your cable company) and then put Bufallo router after it. All other devices should work fine with it.


Does the U.S. have any remaining economic or diplomatic ties with North Korea?

Question: After North Korea's provocative activities recently, the United States announced they would put further sanctions on North Korea. Does this mean the U.S. still has any sort of economic or diplomatic ties with North Korea?
Answer: Seemingly, not many:
Diplomatic Relations

As North Korea and the United States have no formal diplomatic relations, Sweden acts as the protecting power of United States interests in North Korea for consular matters.

More about it can be read here.
Economic Relations
From this page you can see that:

Most forms of U.S. economic assistance, other than purely humanitarian assistance, are prohibited. The United States has provided food and other emergency aid to North Korea during times of famine and natural disasters. The United States has also assisted U.S. NGOs in providing aid to fight the outbreak of infectious diseases and to improve farming practices and agricultural output in rural areas.

and

The United States imposed a near total economic embargo on North Korea in 1950 when North Korea attacked the South. Over the following years, some U.S. sanctions were eased, but others were imposed. In the wake of the DPRK's cyber-attack targeting Sony Pictures Entertainment, Executive Order 13687 imposed new sanctions against the government of North Korea and the Korean Workers' Party, effective January 2, 2015. U.S. economic interaction with North Korea remains minimal.
Comment: Thank you for making me aware of the second part, Philipp.
Answer: South Korea has factories in North Korea staffed by North Korean workers. South Korea pays the North Korean government for this labor, not the workers. The U.S. buys some of the products from these factories. It's called the Kaesong Industrial Complex. It may be closing down now, but the U.S. took advantage of the North Korean labor for a long time.
https://en.wikipedia.org/wiki/Kaesong_Industrial_Region
Answer: I don't think there is...
Here is the source from NPR..
Samantha Power says, from 4:20~"I mean, interestingly, they haven't been willing to rely...", so if you listen to the all the radio, well, you can see
Kim Jung Un, or North Korea is going their way regardless of what the U.S does...haha. ( Sorry).
Thank you.


Updated my jailbroken iPhone 4s to 6.1.3, stuck in Recov. loop

Question: My iPhone 4s was jailbroken, I think at 5.something or 6.0. I wish I remembered. I tried to update it to 6.1.3 via my phone in the settings menu. It restarted and told me to connect to iTunes.
I connected to iTunes to restore and got a 3194 error. I tried tinyumbrella but I cant kick my phone out of recovery mode. I went into DFU mode and used tinyumbrellas "fix recovery" options with no luck, iTunes returned a 21 error. I went back into DFU mode and tried to restore my phone through iTunes again, but now that I'm in DFU mode, I'm getting a 1600 error.
I updated iTunes to 11.0.2 (latest) and tried to restore again. Instead of immediately throwing an error, it's now downloading the iPhone software update and has 75 minutes remaining.
Not sure if this will make a single difference when it actually tries to install it, but in the meantime does anyone have ideas?
Answer: If you jailbreak then update with the OTA function, your phone will have serious problems. I hope everything works out for you.
Comment: To whomever downvoted this, what did I say wrong?


How do I get more Spoils of War?

Question: After a (lost) match, in the XP/GP reward screen, I also got a "Spoils of War", a rare Datanode chance pack, obviously a random reward item. What's the mechanic there, how do I get more spoils?
Answer: In the before times, you'd always get a datanode after a match, but that has been changed long before this answer. Recently (August-ish), there was a short special event that rewarded players with a 'Spoils of War' pack after a match.
That being said, you no longer get datanodes or datanode packs for playing a match.
However, the datanode chance packs can still be purchased with Zen or GP from the marketplace.
Now it appears that any post-match rewards are called 'Spoils of War'. This includes things like GP tokens for completing daily missions.

How do I get more Spoils of War?


windows server 2008 scripting on loss of network

Question: ok the idea is to run a script (pref either powershell or vbs) on the event that there is a network failure (e.g. when a network cable gets unplugged for whatever reason).
This possible? im going to guess so but how?
cheers
Answer: You can do this from a .net application, as there are a couple of hooks that can be used to trigger it when the network cable is unplugged, in particular Shell Notifications, which in theory could be accessed via Powershell, as its .net based. However the problem is that your application/script would need to be running when the event is trigged, to catch the event and do something.
I guess what your wanting is just to have a script called when the network cable is removed without anything else running in the background. I don't think this will be possible without have some application, even if its just a stub service that will then run your script, waiting for the event to happen.
That said, someone might have an ingenious solution I hadn't thought of.
Comment: thanks yeah ill just create a service which will hook in.
Answer: You can create a task in the task scheduler that will be triggered whenever a particular event is logged. If you can figure out what event ID is logged when the network connection is lost, you can have that task run your script.
Answer: Okay, there's a simple Powershell code to start with. Note you can use DNS name instead of IP Address. You can change {Write "Working"} block for {} (do nothing), but it'll ping too much times a second. So use Sleep commandlet inside the block. Replace {write "Failure!"} scriptblock for the actions you need to do in case of failure.
You can extend that script to ping the array of addresses sequentially, or you can set some counter to throw your action not for the first lost ping, but after a bunch of them are lost. You can even use some case statement to take different actions for different failed hosts. Ask if you need some further assistance in scripting.
<code>while ((get-WmiObject Win32_PingStatus -filter "Address='192.168.1.1' ").Statuscode -eq 0) {Write "Working"; Sleep 2};{write "Failure!"}
</code>


Looking for a quality pitch shift plugin for Logic 9

Question: I'd love to get some high quality pitch shifting plug that can be automated and sounds really good...any tips? I'd love to put my 192k recordings to a good use :-)
Answer: Izotope Radius, specifically made for Logic. One of the best sounding algorithms in my experience.
EDIT: If you are looking at varispeed, Logic's tool does the job - using classic mode
Comment: what do you mean by classic mode?
Comment: @Bartosz In the Time & Pitch Machine (select Region > Sample Editor > Factory > Time & Pitch Machine) select 'Classic' under the 'Mode' menu.
Answer: Serato Pitch n Time Pro is considered a very good choice


Why is cyclopentadiene anion is aromatic but cycloheptatrienyl anion is not?

Question: I just can't seem to figure this out. The cyclopentadienyl anion (1) is aromatic, but the cycloheptatrienyl anion (2) is not, though its cation (3) is. Why?
Answer: That happens because of Huckel's rule of aromaticity. The cycloheptatrienyl anion has 8 electrons which translates as 4n electrons, not the 4n+2 as implied by Huckel. If you are about to construct the MOs for both cycles, you'll find that putting 4n electrons will rise in a diradical molecule, not stable as it already sounds. A quick trick for doing that is using Frost's circle. All you need to do is inscribe the correspondent polygon in a circle and make sure that you have a vertex touching the circle as low as possible. The vertices will give you the qualitative energy of the MOs.
Comment: "That happens because of Huckel's rule of aromaticity. "No, it doesn't happen because of this rule. The rule is a tool to predict aromaticity/antiaromaticity in very simple systems.
Comment: Agree. Indeed pseudo-Jahn-Teller effect is present in molecules like cyclobutadiene and distorts the geometry from square to a rectangular. It may also happens in cycloheptatrienyl anion.
Comment: Ground state O2 is a diradical and is pretty stable. I'd say it's just a form of a Jahn-Teller distortion - a nonlinear molecule with incompletely filled degenerate orbitals.
Answer: Aromaticity exists when there are $4n+2$ (i.e. 2, 6, 10, 14...) electrons in a planar, cyclic pi system. Planar, cyclic pi systems that have $4n$ (4, 8, 12, 16...) electrons are antiaromatic.
In the case of the cyclopentadienyl anion, there are 6 electrons in the pi system. This makes it aromatic. The cycloheptatrienyl anion has 8 electrons in its pi system. This makes it antiaromatic and highly unstable. The cycloheptatrienyl (tropylium) cation is aromatic because it also has 6 electronics in its pi system.
Answer: Cycloheptatrienyl anion(tropylium anion) has 8 pi electron system, therefore it must be antiaromatic but the extra lone pair on the one carbon would cause that carbon to be become sp3 hybridized and put those extra elctrons in one of the sp3 orbitals. This would make it non-planar and non-aromatic.
Answer: It's quite simple, really. Aromatic rings have all their relatively stable electronic orbitals filled and unstable ones empty.  The 4n+2 rule just says that a conjugated ring will have an odd number of stable pi orbitals to be filled, that is 2n+1 orbitals to be occupied by two electrons apiece for some whole number n.
When you try to put 4n (or 4n+4) electrons into the ring as in cycloheptatrienyl anion, you have filled and empty states at the same energy level; that's what the Frost circle tells you.  Sometimes molecules do that, but they generally are not as stable as what you get with all the filled states well below all the empty ones.  The latter is what the proper 4n+2 electron count does.


How to reduce power consumption? - Honor 7

Question: so I have an honor 7, had it over 2 years now. It has seen better days, I need a new phone however don't have the money as of yet. The phone must always be connect to a charger, using a fast charging source and cable (I've got decent power bank). If it isn't charging it will turn off almost instantly - always says the power is at 100% - and if it's charging with a non-fast charger, it also turns off. However even while connected to a fast charger if i use it too much (15min) it gets very warm and again, turns off.
I'm looking for as many ways to reduce power consumption as much as possible, but will still allow me to use my phone normally - e.g snapchat -
I'm happy to root my phone if it's needed to turn off certain stock apps for example.
Any and all help/advice would be greatly appreciated.
Thanks
Comment: Tried Greenify?
Answer:
I'm happy to root my phone if it's needed to turn off certain stock apps for example.

If the problem is related to apps then the battery drain will not be instantaneous as in your case .
It looks like a battery problem to me, try replacing a new battery and it think it should fix the problem


For which problems Krylov subspace methods are preferred over multigrid methods?

Question: As multigrid methods are known to have grid independent convergence rates with $O(N)$ computational cost, then why would one be interested in using Krylov subspace methods at all, for which convergence rates deteriorate with grid refinement? Are there any problems where Krylov solvers perform better than MG methods?
Comment: @artificial_moonlet Could you elaborate on your comment? I was under the impression that multigrid methods can be used as preconditioners for Krylov based solvers (as noted in an answer by @JesseChan). Do you disagree?
Comment: To date, multigrid methods have not been (and maybe can't even be) applied to matrix functions.
Comment: How does preconditioning work for $f(A)b$?  In general, this is an open problem.  You can certainly approximate $f(A)$ with quadrature or some other rational approximation and then apply multigrid on each resulting linear system, but such techniques only work for certain classes of matrix-function pairs.
Answer: The answer depends somewhat on the discretization; for example, some boundary integral discretizations result in very well-conditioned matrices, for which a Krylov solver works just fine without having to introduce the multi-level machinery of multigrid.
For ill-conditioned matrices arising from finite difference or finite element methods, Krylov solvers are almost always paired with a preconditioner, for which multigrid methods can work very well.
Comment: An extra nice feature of Krylov methods is that you can get information about the spectrum of the system, e.g. max/min eigenvalues. You can then leverage this knowledge for multigrid. For example, if you use Chebyshev smoothers, you want to have some advance knowledge of where the spectrum of the operator lives in the complex plane. Krylov methods and multigrid methods can both benefit from each other.
Answer: This question is pretty well discussed in literature. However, there are lots of questions concerning multigrid on SciComp, so I decided to compose more or less detailed answer.
I. When multigrid DOES work fine as a stand–alone solver
MG works fine for rather simple elliptic problems. In fact, both MG and PCG (with MG cycles as inner iterations) usually give similar results for such problems in terms of iterations / working time and stay robust as you refine the mesh.
I solved diffusion–reaction 2D problem
$$
  -\epsilon \, \Delta u + u = f, \quad \mathbf x \in \Omega, \\
  u|_{\Gamma_D} = g_D, \\
  \left( \epsilon \, \nabla u \cdot \hat{\mathbf n} + u \right)|_{\Gamma_R} = g_R
$$
with CATS' PDEs on hierarchy of triangular meshes $\Omega_1 \subset \Omega_2 \subset \dots \subset \Omega_8$ of unit square with P1 FEs.
I obtained the following results:

$\text{MG(V)}$ and $\text{MG(W)}$ are V– / W–cycles as stand–alone solvers; $\mathbf P_{\text{MG(V)}}\text{CG}$ is preconditioned conjugate gradient with one V–cycle as an inner iteration; $\mathbf P_{\text{ILU(0)}}\text{CG}$ is preconditioned conjugate with incomplete $(\mathbf L + \mathbf I) \, \mathbf D \, (\mathbf I + \mathbf L^T)$ preconditioner (zero fill–in).
I used 2 pre– and post–smoothing SSOR iterations inside MG–cycles.
Numb of DOFs on the coarsest grid: 17; numb of DOFs on the finest grid: 656 897.
In the table: "numb of iterations, $m$" / "solving time (in seconds), $t$." I always started with a random initial guess $\mathbf x_0$ in order to introduce components of different frequencies in the initial error vector $(\mathbf x - \mathbf x_0)$; I stopped solving when $||\mathbf r_m||/||\mathbf r_0|| < 10^{-12}$.

Here's comparison in terms of time $t$ as system size $n$ grows:

Indeed, you can see that $\text{MG}$ allows you to solve this problem in $O(n)$ time; so does $\mathbf P_{\text{MG}}\text{CG}$, but there is no difference between them in this case. I think this makes people ask questions like

As multigrid methods are known to have grid independent convergence rates with $O(n)$ computational cost, then why would one be interested in using Krylov subspace methods at all […]?

II. When multigrid DOES NOT work fine as a stand–alone solver
Consider the following cases.
II.1 More complex elliptic problems
It is usual to have jumping coefficients. For one, consider the following magnetostatic Poisson problem
$$
 \nabla \cdot \left( \frac{1}{\hat{\mu}} \, \nabla A_z \right) = \mu_0 \, J_z.
$$

It is natural to have different values for magnetic permeability $\hat{\mu}$ for a magnet (gray box on the picture above) and air; current density $J_z$ is only nonzero within wires (red and blue squares on the picture above).
MG as a stand–alone solver loses its robustness (or even diverges) with respect to jump sizes for such problems, although the configuration is very simple. However, it still works nice as a preconditioner for Krylov solvers. If I have some free time, I will add a similar table for this problem.
There are lots of simple elliptic problems for which MG does not work. It is useful to look through a paper I mentioned in this answer in order to get a deeper understanding.
II.2 "Real–life" problems
Complex real–life problems involve different physics, several unknown fields and so forth. From the algebraic point of view it usually means block structure of the resulting (non-)linear systems. (Consider, for one, Stokes or Oseen problems, fluid–structure–interaction models typical for haemodynamics, thermoelasticity etc.)
It turns out that MG is in general a poor choice for such kind of problems. However, these problems usually "contain" some kind of "diffusion" (read: elliptic / Laplace blocks in the matrix), and one usually keeps this in mind while constructing preconditioners. Indeed, one often uses some kind of MG–cycles to approximate actions of inverses of elliptic blocks. One example I mentioned in this answer.
In order to get a better understanding, it is useful to check this lecture by @wolfgang-bangerth.
Comment: Is MG *generally* unreliable for problems with large jumps in coefficients? Or does it depend on the discretization/coarsening strategies? (I am thinking of FV solvers with operator interpolation, like [Black-box Multigrid](https://scholar.google.com/scholar?cluster=9677111252995040828), and [transmissibility upscaling](https://www.google.com/search?q=transmissibility+upscaling) in in oil-reservoir simulation.)
Answer: There are multiple answers to your question.
For one, as others have said, multigrid (MG) and krylov based solvers can work really well together, so this is a good reason to still use krylov solvers.
A second good reason to use krylov solvers is if the matrix to be inverted is ill conditioned ( for example due to discontinuous material properties ). In this case, MG does not guarantee convergence whereas Congugate Gradient method (e.g.) will.


Exactly what kind of radios are prohibited for passengers inside an aircraft?

Question: I know that passengers are asked to put their cell phones on flight mode. But some carriers allow use of WLAN on-board. So, what radios should passengers refrain from using?
Also, if a person uses a GPS receiver on his/her mobile phone (on flight mode), would it interfere with the aircraft communication system?
Comment: Regarding GPS, it's a `receiver`
Comment: @PriyankGupta: The basic way to receive a GPS signal (or any other radio signal) is to extract the modulation from the modulated-carrier. This is usually done by an intermediate [heterodyne operation](https://en.wikipedia.org/wiki/Heterodyne) which adds a RF signal to the signal received. This operation itself creates a RF signal of low power. This signal, or any of its by-products can create interferences to (badly designed) receivers. This is why we need to see all receivers as potential low power emitters until determined they are harmful.
Comment: Pure GPS is receive-only, however most mobile communication devices that have it use a combination of various location-sensing techniques as the device's "location service" (cell towers, known WiFi hotspots) which are faster but less precise, and it's sometimes impossible to specify that you only want to use the pure GPS component.
Comment: FAA now [allows nearly everything](http://www.faa.gov/about/initiatives/ped/) but voice communication with cell phones, based on [220-page report](http://www.faa.gov/about/initiatives/ped/media/ped_arc_final_report.pdf) which analyzed PED interferences and concluded that there are none.
Comment: I've never understood this.  A good buddy of mine is an avionics trainer for my local airline.  He states, and pilots state, that they can often hear the cell negotiation from phones over the intercomm audio.  I cannot grasp why official reports are concluding that there is no problem.
Comment: I know GPS devices are receivers, but when I asked a pilot, he said "of course GPS interferes with aircraft communication, and you shouldn't use it.". Since they only receive data, I don't think there should be any problem if anybody uses it on-board.
Comment: @PriyankGupta are you sure he didn't confuse GPS with GSM or something?
Comment: @MikeFoxtrot : Well, I clearly remember I said "GPS", but I am not sure what did he hear
Comment: @mins That's general electronic devices. *Radios* have other rules; for instance, an amateur radio may not be operated on an aircraft without permission from the PIC.
Comment: It seems people often mix up GPS and GSM. Crime series on TV often claim that they try to locate a phone / it's owner via GPS, though they clearly show they're using GSM station info. They even often don't know GPS is receiving only, e.g. because it's faster with Internet (GSM) on their phone. I don't know if all pilots know GPS is a pure receiver. However, I like to track my flights and see where we are and what's that structure below us.
Comment: @simon probably because the intercom is not only not shielded the same way the avionics are, but the intercom wiring runs into the cabin, unlike avionics.
Answer: There is actually a simple answer, but it probably isn't exactly what you are looking for:  Refer all questions about what is allowed to your specific airline.
Each airline has to come up with their own list of allowable electronic devices, and submit that list to the FAA with appropriate documentation in order to gain approval to allow passengers to use them during flight.
Some airlines allow almost everything as long as it can be put into a non transmitting mode (airplane mode), while some still require ALL electronic devices to be completely powered down at all points during the flight.
Because of this, every airline is a little different and you are required to follow their rules while on their flights.
The GPS receiver would not cause problems, but this doesn't mean that you are necessarily allowed to use it, and there are other things in your phone that could cause a problem though.
In general, no electronic device that has a transmit function may be used because of possible interference though, unless specifically approved.
Comment: Actually I wanted more technical answer. Also, for example, multiple airlines are ordering A320s from Airbus. Now what sense would it make to have different rules for the same A320s that are being sourced from the same company, i.e, Airbus.
Moreover, I think Airbus/Boeing should decide what gadgets should be allowed on-board, since they know the best about their aircrafts.

If you would, please tell me what other things in a phone can cause problems.
Comment: While that would make sense, that is not how the rules are written, and each airline does indeed have their own policies which must be individually approved by the FAA and the manufacturer is not involved.  The transmitters in a cell phone are what they are concerned about and why it should be put into airplane mode or turned off, depending on airline policy.
Comment: @pri Actually, equipment configurations and flight procedures for specific aircraft models vary from airline to airline, and the airline chooses who does maintenance and upgrades, both of which may be done by companies other than the original aircraft manufacturer. Thus the airlines themselves are the authority on this. There may also be non-technical reasons for prohibiting specific uses of personal devices, such as not wanting phone conversations to inconvenience other passengers, or having hard objects that could be damaged able to fly about the cabin at certain points in the flight.
Answer: The simplest answer to your question is, none that have not been specifically approved for use by the FAA. The FAA, in U.S.-controlled airspace, has pretty much all the power and responsibility for ensuring civilian air travel is safe, and they operate with an abundance of caution in all things, because that draconian code of rules and regulations is what keeps the agency itself from taking blame for a plane crash; if everyone followed all the rules and the plane still went down, it's the government's butt on the line.
So, the FAA has, for decades, maintained more or less a blanket ban on operation of devices with a transmit feature, even as modern airframes (and by "modern" I mean practically anything in the sky today) are well-shielded against radio interference, and consumer devices available for purchase and casual use do not transmit on frequencies anywhere near those used by aircraft for communication or navigation. The reason is simply that it is possible for a device to cause interference with aircraft systems, whether directly by pirating the frequency or indirectly through intermodulation or other artifacts of radio carrier wave dynamics, and it was simpler, easier and cheaper at the time for the FAA to ban them all than to evaluate every device or device type against every airframe in commercial aviation, verify empirically that it does not cause interference, and educate flight crews and the general public about which device types, makes and models specifically are or are not allowed.
The FAA has since changed tack; it has worked with the FCC beginning in the 90s to develop a set of joint rules for both device and aircraft systems design that, if complied with by the manufacturers, will guarantee the device will not cause interference. Devices meeting these criteria, including practically any smartphone or tablet on the market today, can be used during "non-critical" stages of flight (all usage of potentially-interfering devices is still restricted during takeoff, landing or at any time by instruction of the flight crew) while onboard an aircraft certified for use of such devices while airborne (meaning the airframe complies with rules for shielding/isolation of sensitive electronics; this certification, including any needed retrofits, can be done during scheduled maintenance on each airframe).
Answer: @PriyankGupta was heading in the right direction. Back when more people carried portable FM/AM receivers to listen to music, there was a problem with the receiver local oscillators causing interference. For example, If I wanted to listen to an FM station at 105.1 MHz, the local oscillator was 10.7 MHz above that frequencies so it was operating at 115.8 MHz. Leakage from the local oscillator could and did interfere with the aircraft receivers operating in that band. Of course, now days, almost no one uses portable FM broadcast receivers. However, the concept is the same for the various types of receivers and transmitters. The radios themselves may not interfere directly but one of the signals that gets mixed with another signal might. In modern commercial aircraft, they have multiple different systems so the likelihood of an airplane being severely compromised by a cell phone in the passenger section is very small but not zero. I always turn mine to airplane mode. I don't my family reading in the newspaper that the cause of a plane crash I was killed on was my cellphone being on.


Kohanim and the Third Temple

Question: Are there any organizations that provide ongoing preparation for Kohanim to immediately assume their priestly duties upon the arrival of Moshiach? I would imagine that performing the sacrifices and mixing the incense would require some hands-on experience in addition to reading Jewish texts.
Answer: There's a really great website called: http://kehuna.org/ that contains a lot of materials online.
There is another organisation in Israel called the Temple Institute
http://www.templeinstitute.org/
They are extremely right wing, and regularly promote Jews going to pray on the Temple Mount, which most Rabbanim don't allow. They have prepared many Kelim for the Beis Hamikdash, however, and there are no other organisation quite as involved.
As for (more contemporary classic) texts:
The Chofetz Chaim urged Kohanim to learn these Halachos to be prepared for Moshiach to come. His son in law wrote Avodas Hakorbonos. The Aruch Hashulchan also penned a work, Aruch Hashulchan Heasid.
Comment: Thanks Zvi for your response. I will check out your links.
Comment: "Extremely right wing?"
Comment: they're not exactly mainstream if they regularly promote Jews going to pray on the Temple Mount when the vast majority of Rabbinic authorities decry it.

Kohanim and the Third Temple


Customer Verification

Question: My question is about customer verification when they come to customer service( by call or chat). The customer service agents always do the verification by asking 2 or 3 questions (email, home address etc) in order to avoid fraud. This is useful. But I dont think it must be done every time. When a customer asks about their order status by giving the order ID verification is not necessary since the orderID is enough to verify them. I think, do the 2-3 questions (or more) verification if only it is related to financial issue or more serious matters. Am I right? or is there any better idea for customer verification system ? Thank you
Comment: Well, if make a guess at an order number and ring up and ask "Do you have my address right? Where are you going to deliver it?" what happens? The agent tells me and I know where to burgle.
Comment: @Shieryn No, once you have the orderID, you have the address **of the person who ordered it.** You don't have **my** address, and I don't think it would be difficult to get the service agent to divulge the orderer's address, which I don't know. "Is it still in the warehouse? Oh: you already delivered it? Where to? ***I*** never got it!" (Which is true; I never got it, the orderer did. I want to know where he is.)
Comment: If your system requires verification for most parts then it's probably a very bad idea to drop verification in any area - once the caller has bypassed verification at one of your "low security" entrances what will stop them from being transferred through to a "high security" area without further verification?
Comment: @Leach. Once I have the orderID, I have their address and an agreement to deliver the product to that address. Customer often calls to find out the status ; whether it is on delivery process or still in warehouse
Comment: @Martin okay I got it. Are we talking about making a level of security? higher level needs more verification. Just say the customer ask for general info of product, then verification is not necessary, but when he/she ask more, and entering "high security" level, then we do the verification.. is that it?
Comment: @Leach. We use courier service. we will have the data where,when and who got it from the courier who delivered it. if something goes wrong, it's possible to do the tracking. I forgot to say : the one who order the product must sign up first. We have all customer data. the address they input while sign up is the same address we will deliver the product. We will deliver after the payment is done and proved. Sort of e-commerce. Anyway thanks for your response :)
Answer: This is a double issue, which should not be taken lightly: user experience versus security.  A trade-off should be found. The constraint is that a minimal standard of security has to be met.
The method to find the best balance requires that you step back and make a little risk assessment.

What is the nature of the threat? Clearly, you want to avoid fraudulent impersonation, but what is the context? (This is not the same if you are within a corporate firewall or outside. I suppose your service is accessible from everywhere with chat or phone. But if you have a small circle of users your staff can get to know personally, this is different from a large one; also it depends how your framework is already protected from wiretapping, hacking, etc. Also, could you be targeted by hackers for particular reasons?).
What is the frequency (volumes per day, etc.)? The question is not the same if you have 5 users a day or 10'000. On a similar line, can we assume the interaction should be as short as possible, from 5 to 30 minutes? Or are sessions allowed to be long, up  to 1 hour or more? Also, is it expected that the users call you often, or should it be an exceptional circumstance?
What is the impact if the threat (fraudulent impersonation) materializes? Try to evaluate it in terms of (as applicable):

Financial: Direct financial loss
Operational: Wasted time and resources
Legal: payout to client, fines, court cases, etc.
Reputational: Public image (is your brand already very popular, etc.?)
Others?

What are your resources to defend against the threat? In particular what data or indicia do you already have concerning the caller's identity? (Phone caller id can be useful, but as long as you use it as a weak indicia, not a strong one, etc.). What do you have in your toolkit (e.g. double authentication with a mobile phone, ), etc.? What is your company willing to spend (next to nothing, or do you have a budget)?

That may sound complicated but it could take ten minutes. Hopefully, the issue should become crystal clear after that and -- within your resources -- you might find your bright idea to make the user experience better.
(Plus, if you have taken notes of this an put it in a good place, you may able to defend your company and yourself against accusations of negligence, should something bad happen).
Answer: How about verifying the user based on the phone number they're using? Ideally, the call center brings up the caller's data when the call center agent answers the phone.
This should cut down on the questions needed to avoid fraud.
Comment: I would hazard against this. It is possible (and not terribly hard) to spoof a phone number. See [this article by the FCC](https://consumercomplaints.fcc.gov/hc/en-us/articles/202654304-Caller-ID-and-Spoofing). It's certainly illegal, but that doesn't mean a social hacker won't use it to "prove" who they are.
Comment: @nobi : We do this also. we verify by : phone number, home address , email address etc. but we feel that verification is not always necessary. You dont need to be verified if only ask a general info of product
Comment: Maybe I was too lazy in my explanation - when a call arrives, the system can detect the incoming phone number and look up this number in the database, to already present this customer's data when the agent takes the call. And yes, @Daniel, it can be spoofed, but it's one indicator about who's calling. Depending on the value you talk about (i.e., product information vs. bank details), you may need additional indicators.

Customer Verification


Can I use the ® symbol in the play store for a trademark registered in the Benelux?

Question: When publishing an app in the Google Play store, I would like to use the ® symbol for the name of a product that is not registered as a trademark in the USA, but it has been registered as such in the Benelux. Is it fine to use the ® symbol there?
Answer: Yes, it appears that you can. In § 906.01 of the Trademark Manual of Examining Procedure (TMEP) it states:

In addition to the United States, several countries recognize use of the symbol ® to designate registration.  When a foreign applicant's use of the symbol on the specimens is based on a registration in a foreign country, the use is appropriate.

Crucially, the country it is registered in must provide for the use of the ® symbol in its law. A discussion of this can be found in the Trademark Trial and Appeal Board case Brown Shoe Co. v. Robbins (PDF, pg. 14-15).
Since the TMEP lists the Benelux countries as providing for the use of the ® symbol, your use would be appropriate.
Comment: What does the TMEP have to do with the Google play store?
Comment: @phoog Submissions to the Google Play store have to comply with U.S. law (which I believe the OP knew by asking this question). The TMEP is USPTO's manual on examining trademarks and trademark disputes and as such is a source for adjudicating trademark disputes in the Google Play store. For more information, see the [TMEP's introduction](https://tmep.uspto.gov/RDMS/TMEP/Apr2016#/Apr2016/introductiond1e1.html)


Sleeping Barber algorithm (with multiple barbers)

Question: The Sleeping Barber Problem is a classical synchronization problem that many of you may be familiar with or at least heard of.
It's based on the premise that a barber (a thread) sleeps when there are no customers (each customer is a thread) in the waiting room (which is a semaphore). If there is someone, he cuts his hair (symbolizing some processing) and the costumer leaves. If, then, there is no one in the waiting room, the barber goes to sleep. When another customer arrives, he then must wake up the barber.

I have made a implementation of this using the following basic-idea
(although the actual code is in C, I wrote the following pseudo-code without much care for the syntax for sake of problem-understading, only using sem_wait and sem_post1 for smoother reading)
Semaphore Customers = 0;
Semaphore Barber = 0;
Mutex accessSeats = 1;
int NumberOfFreeSeats = N;

Barber {
    while(1) {
        sem_wait(Customers); // waits for a customer (sleeps)
        sem_wait(accessSeats); // mutex to protect the number of available seats
        NumberOfFreeSeats++; // a chair gets free
        sem_post(Barber); // bring customer for haircut
        sem_post(accessSeats); // release the mutex on the chair
        // barber is cutting hair
    }
}

Customer {
    while(1) {
        sem_wait(accessSeats); // protects seats so only 1 thread tries to sit in a chair if that's the case
        if(NumberOfFreeSeats > 0) {
            NumberOfFreeSeats--; // sitting down
            sem_post(Customers); // notify the barber
            sem_post(accessSeats); // release the lock
            sem_wait(Barber); // wait in the waiting room if barber is busy
            // customer is having hair cut
        } else {
            sem_post(accessSeats); // release the lock
            // customer leaves
        }
   }
}

However, now that I'll implement this problem with multiple barbers, my head got stuck. I went on Wikipedia to see if I could find something about it, but the only thing that I found there was this

A multiple sleeping barbers problem has the additional complexity of coordinating several barbers among the waiting customers.

and I couldn't figure this out by myself 2.
What changes would I have to do in my code? Where would I need an extra semaphore here?
1sem_wait() locks the semaphore. sem_post() unlocks it
2Disclaimer: Although I have asked this in programmers.stackexchange aswell, I did not have reached a desired answer and my question still persists.
Comment: Maybe you could mix it with the producers/consumers problem. Anytime a client arrives, it's assigned to a FIFO structure protected by semaphores. The barbers will "consume" the clients from the FIFO. I'll try to take a look at the code later on....
Comment: [Here](http://www.albahari.com/threading/part4.aspx#_Wait_Pulse_Producer_Consumer_Queue) is the best explanation I've seen of a producer/consumer queue.  It is written in C#, but you might have luck translating it to C.
Comment: The exact details of the coordination among barbers and customers are going to be heavily dependent on what you mean by "haircut".
Answer: The code as written will manage any number of barbers without any additional semaphores.  Simply start a Barber{} thread for each barber in the shop.
The problem referenced in the Wikipedia remark is this: just because you have M barbers in the "barber is cutting hair" state and M customers in the "customer is having hair cut" state, there's no guarantee that some barber isn't trying to clip more than one customer, or that some customer doesn't have several barbers in his hair.
In other words, once the proper number of customers have been allowed into the cutting room, how do the barbers and customers pair off?  You can no longer say "barber is cutting hair" and "customer is having hair cut"; you have to say "barber is cutting hair of customer C" and "customer is having hair cut by barber B".
// Assumptions about the meaning of 'haircut':
// each thread has a unique PID
// each thread can get its own PID via system.info.PID
// a barber uses a customer's PID to cut that custmer's hair
// a customer uses a barber's PID to get his hair cut by that barber
// Assumptions about the operating environment:
// a semaphore releases threads in the order that they were queued

Semaphore Customers = 0;
Semaphore Barbers = 0;
Mutex AccessSeats = 1;
int NumberOfFreeSeats = N;
int SeatPocket[N];  // (or 'PID SeatPocket[N];' if PID is a data type)
int SitHereNext = 0;
int ServeMeNext = 0;

// main program must start a copy of this thread for each barber in the shop
Barber {
    int mynext, C;
    while(1) {
        sem_wait(Barbers);  // join queue of sleeping barbers
        sem_wait(AccessSeats);  // mutex to protect seat changes
        ServeMeNext = (ServeMeNext++) mod N;  // select next customer
        mynext = ServeMeNext;
        C = SeatPocket[mynext];  // get selected customer's PID
        SeatPocket[mynext] = system.info.PID;  // leave own PID for customer
        sem_post(AccessSeats);  // release the seat change mutex
        sem_post(Customers);  // wake up selected customer
        //
        // barber is cutting hair of customer 'C'
        //
    }
}

// main program must start a copy of this thread at random intervals
// to represent the arrival of a continual stream of customers
Customer {
    int myseat, B;
    sem_wait(AccessSeats);  // mutex to protect seat changes
    if(NumberOfFreeSeats > 0) {
        NumberOfFreeSeats--;  // sit down in one of the seats
        SitHereNext = (SitHereNext++) mod N;
        myseat = SitHereNext;
        SeatPocket[myseat] = system.info.PID;
        sem_post(AccessSeats);  // release the seat change mutex
        sem_post(Barbers);  // wake up one barber
        sem_wait(Customers);  // join queue of sleeping customers
        sem_wait(AccessSeats);  // mutex to protect seat changes
        B = SeatPocket[myseat];  // barber replaced my PID with his own
        NumberOfFreeSeats++;  // stand up
        sem_post(AccessSeats);  // release the seat change mutex
        //
        // customer is having hair cut by barber 'B'
        //
    } else {
        sem_post(AccessSeats);  // release the seat change mutex
        // customer leaves without haircut
    }
    system.thread.exit;  // (or signal main program to kill this thread)
}

Answer: This code is written by me with slight modifications from the algorithm defined by Breveleri which simulates the Multiple Sleeping Barber problem quite efficiently. I had written it for simulation purpose for my OS Assignment. I would like to get ay suggestions from your side. I'm using "declarations.h", "SleepingBarber.c" and a "makefile" for a better coding structure.
declaration.h
#include <unistd.h>          //Provides API for POSIX(or UNIX) OS for system calls
#include <stdio.h>           //Standard I/O Routines
#include <stdlib.h>          //For exit() and rand()
#include <pthread.h>         //Threading APIs
#include <semaphore.h>       //Semaphore APIs
#define MAX_CHAIRS 10        //No. of chairs in waiting room
#define CUT_TIME 1           //Hair Cutting Time 1 second
#define NUM_BARB 2           //No. of barbers
#define MAX_CUST 30          //Maximum no. of customers for simulation

sem_t customers;                 //Semaphore
sem_t barbers;                   //Semaphore
sem_t mutex;                     //Semaphore for providing mutially exclusive access
int numberOfFreeSeats = MAX_CHAIRS;   //Counter for Vacant seats in waiting room
int seatPocket[MAX_CHAIRS];           //To exchange pid between customer and barber
int sitHereNext = 0;                  //Index for next legitimate seat
int serveMeNext = 0;                  //Index to choose a candidate for cutting hair
static int count = 0;                 //Counter of No. of customers
void barberThread(void *tmp);         //Thread Function
void customerThread(void *tmp);       //Thread Function
void wait();                          //Randomized delay function

SleepingBarber.c
#include "declarations.h"

int main()
{
    pthread_t barber[NUM_BARB],customer[MAX_CUST]; //Thread declaration
    int i,status=0;
    /*Semaphore initialization*/
    sem_init(&customers,0,0);
    sem_init(&barbers,0,0);
    sem_init(&mutex,0,1);
    /*Barber thread initialization*/
    printf("!!Barber Shop Opens!!\n");
    for(i=0;i<NUM_BARB;i++)                     //Creation of 2 Barber Threads
    {
       status=pthread_create(&barber[i],NULL,(void *)barberThread,(void*)&i);
       sleep(1);
       if(status!=0)
          perror("No Barber Present... Sorry!!\n");
    }
    /*Customer thread initialization*/
    for(i=0;i<MAX_CUST;i++)                     //Creation of Customer Threads
    {
       status=pthread_create(&customer[i],NULL,(void *)customerThread,(void*)&i);
       wait();                   //Create customers in random interval
       if(status!=0)
           perror("No Customers Yet!!!\n");
    }
    for(i=0;i<MAX_CUST;i++)        //Waiting till all customers are dealt with
        pthread_join(customer[i],NULL);
    printf("!!Barber Shop Closes!!\n");
    exit(EXIT_SUCCESS);  //Exit abandoning infinite loop of barber thread
}

void customerThread(void *tmp)  /*Customer Process*/
{
    int mySeat, B;
    sem_wait(&mutex);  //Lock mutex to protect seat changes
    count++;           //Arrival of customer
    printf("Customer-%d[Id:%d] Entered Shop. ",count,pthread_self());
    if(numberOfFreeSeats > 0)
    {
        --numberOfFreeSeats;           //Sit on chairs on waiting room
        printf("Customer-%d Sits In Waiting Room.\n",count);
        sitHereNext = (++sitHereNext) % MAX_CHAIRS;  //Choose a vacant chair to sit
        mySeat = sitHereNext;
        seatPocket[mySeat] = count;
        sem_post(&mutex);                  //Release the seat change mutex
        sem_post(&barbers);                //Wake up one barber
        sem_wait(&customers);              //Join queue of sleeping customers
        sem_wait(&mutex);                  //Lock mutex to protect seat changes
          B = seatPocket[mySeat];    //Barber replaces customer PID with his own PID
          numberOfFreeSeats++;             //Stand Up and Go to Barber Room
        sem_post(&mutex);                        //Release the seat change mutex
                /*Customer is having hair cut by barber 'B'*/
    }
    else
    {
       sem_post(&mutex);  //Release the mutex and customer leaves without haircut
       printf("Customer-%d Finds No Seat & Leaves.\n",count);
    }
    pthread_exit(0);
}

void barberThread(void *tmp)        /*Barber Process*/
{
    int index = *(int *)(tmp);
    int myNext, C;
    printf("Barber-%d[Id:%d] Joins Shop. ",index,pthread_self());
    while(1)            /*Infinite loop*/
    {
        printf("Barber-%d Gone To Sleep.\n",index);
        sem_wait(&barbers);          //Join queue of sleeping barbers
        sem_wait(&mutex);            //Lock mutex to protect seat changes
          serveMeNext = (++serveMeNext) % MAX_CHAIRS;  //Select next customer
          myNext = serveMeNext;
          C = seatPocket[myNext];                  //Get selected customer's PID
          seatPocket[myNext] = pthread_self();     //Leave own PID for customer
        sem_post(&mutex);
        sem_post(&customers);         //Call selected customer
                /*Barber is cutting hair of customer 'C'*/
        printf("Barber-%d Wakes Up & Is Cutting Hair Of Customer-%d.\n",index,C);
        sleep(CUT_TIME);
        printf("Barber-%d Finishes. ",index);
    }
}

void wait()     /*Generates random number between 50000 to 250000*/
{
     int x = rand() % (250000 - 50000 + 1) + 50000;
     srand(time(NULL));
     usleep(x);     //usleep halts execution in specified miliseconds
}

makefile
all:    SleepingBarber
SleepingBarber: SleepingBarber.o
    gcc -pthread -o SleepingBarber SleepingBarber.o
SleepingBarber.o: SleepingBarber.c declarations.h
    gcc -c SleepingBarber.c
clean:
    rm -f *.o SleepingBarber


Wiener process proof

Question: Can someone prove to me how $dW_t=W_t-W_s$, where $t=s+1$, the difference of the Wiener process eventually equates to  $dW_t=z*(dt)^{(1/2)}$ where $z$ is standard normal, $N(0,1)$ in the following SDE: $dS_t=S_t μ dt+S_t σdW_t$?
Comment: The question could use a little rewording.  You should define what "eventually equates" means.  Anyway, I think the point is that the drift term decays at a faster rate than the volatility.
Answer: I think this question might be asking for the central limit theorem.
If we consider a process W which varies as a series of independent random steps, then the Central Limit Theorem tells us that after many steps, the value of W will be normally distributed.
Comment: I think this is the correct answer.
Answer: The question is not 100% clear.
If you set $X = W_t-W_s$ where $t-s = 1$ then this is equal in distribution to $W_1-W_0$ and the defining property of Brownian motion is that increments are normally distributed.
In the general case $W_t-W_s$ is $N(0,t-s)$, where the second parameter is variance.
If you set $dW_t = W_{t+dt}-W_t = Z \sqrt{dt}$, where $dt>0$ is not infinitesimal but just some positive real number and $Z$ is standard normal (mean $0$ and variance $1$), then the first "$=$" is a definiton and the second "$=$" is "equal in distribution".
Comment: ach okey it was supposed to be $(dt)^{1/2}$ ...

Wiener process proof


Getting visa to Japan from Shanghai

Question: I'm going to stay in Shanghai on a student visa from February to June. I want to travel to Japan while I'm in Shanghai. I'm a citizen of Kazakhstan, how can I apply for a visa to Japan in Shanghai? Is it possible? What are the requirements?
Answer: I realise this isn't a full answer to your question, but I hope it helps.
I had a look on the Shanghai embassy of Japan page, which doesn't say either way. However, the Japanese embassy in the UK sheds some light on the matter, and so this may apply to you.
If you have a long term visa for the UK (i.e. you aren't a tourist) then you can apply for a Japanese visa from the local UK embassy. This would suggest if you have a non-tourist visa for China (which you do as a student) then you can apply at the Shanghai embassy.
If you are in the UK as a tourist then you can't apply for a Japanese tourist visa as a foreign national - you need to apply through the Japanese embassy in your own country.
Whether or not the same rules apply at the Shanghai embassy, I can't say. I'd suggest you (or a Chinese friend) contact them on email@example.com, or on 010-8531-9800.
However, as you're not in China yet I'd suggest applying for a tourist visa now through the Kazakh-Japanese embassy - see http://www.kz.emb-japan.go.jp/visa-tourism/visa.htm.
Comment: The Japanese embassy in Singapore only allows visa applications from residents of Singapore as [explained here](http://www.sg.emb-japan.go.jp/visa_eligibility.htm). Chances are that China will be the same, and that any application will have to be done through the Japanese embassy in Kazakhstan prior to going to China.
Comment: In that case, almost certainly better to do ahead of time!
Comment: Then again, depending on the residential status while in China, it's possible that being there as a student could count as a resident and make it possible to apply there. I would recommend calling your Japanese embassy in Kazakhstan and asking them. Usually they are very helpful (and should speak your language).

Getting visa to Japan from Shanghai


Products do not show up in front end

Question: As shown in the picture i have a category speakers having one item(product - Mini Car Speaker) and one category that is empty.

But when i try to access this from the front-end it does not show up. See:

and
Answer: You need to ensure the following:
-the product is assigned to a category
-the product is assigned to a store view.
-the product is In Stock
-the product has a qty assigned
Once this has been done, flush the store cache and the product will appear.
Comment: Nopes, but still thanks for trying
Comment: In some lesser cases, the attributes may be set on a store level. I've had several instances of products set to disabled for specific stores, where the default values were overridden.
Comment: You might need to reindex data also.
Comment: Anyone know me what's issue when i set manage inventory no for magento website?
Answer: The checklist for whether items are in stock follows. Some will seem stupid until the first time you spend an hour trying to figure this problem out:

The products must be Visible in Catalog.
The products must be Enabled.
Product must have a stock Quantity.
The product must be set to In Stock.
If the product is set not to track stock, it still has to have a stock Quantity and be set to In Stock.
The product must be assigned to the target Category.
If using multi-website mode (or if you imported the products through Data Flow), the products must be assigned to the target Website.
You must refresh your Cache / Indices, just to make sure.

Welcome to Magento. Hope that helps!
Answer: You need to make sure that the quantity of the product is not 0 and also that the product is listed available in stock. Because by default the products not in stock are not listed and also by default the quantity of the product is 0 when added.
So what you have to do is go to Catalog->Manage Products Click on your product and edit it, Go to inventory in the left bar and then change the quantity to more than 0 and also change the stock availability to in stock.
Comment: @sr_magento I am sorry, but when i posted the question i was unaware about the answer; it just got struck in my mind and i came up with a solution. I am sorry :P
Answer: The product has position 0. This can cause the product to disappear. I had the same issue and resolved it by changing the position to a number higher than 0. You can still order your products with the numbers but simply don't use 0.
Comment: I don't think this is it. I'we worked on a lot of projects that did not have positions set to products
Comment: Can you back up this claim with some code or an example?
Comment: Ok, so this might be a bug in my install? I thought it could be helpful but correct me if I'm wrong. I'm quite new to Magento and noticed this "quirck" in my install.
Answer: if you have it in custom block or even category block that inserted manually  , then be sure that you have created permission  for that block from system >> permissions >> blocks, that have been a real problem on recent versions of magento 1.9.x

Products do not show up in front end