Finding the order of permutations in $S_8$

Question: Consider the group $S_8$. What is the order of $\sigma = (4,5)(2,3,7)$ and $\tau = (1,4)(3,5,7,8)$?
My book says I should just use a trick by the order of a permutation expressed as a product of disjoint cycles is the least common multiple of the lengths of the cycles.
I don't understand the trick very well and would like to see how the counting process here actually works. I can count for non disjoint ones like say $(1,2,3,8)$ has order 4
I don't know how to count $\sigma = \begin{pmatrix}
1 &2  &3  &4  &5  &6  &7  &8 \\
1 &3  &7  &5  &4  &6  &2  &8
\end{pmatrix}$
EDIT Just so I am clear, the answer for the order $\sigma$ is 6 and $\tau$ is 4. I am still confused as to how they got this
I have an extremely poor understanding of this subject so please help me! Thank you
Comment: It's not a trick, it's a perfectly respectable, efficient, elegant way to determine the order of a permutation, and learning about it will teach you a lot more than winding your way through numbers by brute force.
Comment: No I am asking the question because I want to know how on earth did the answer come up with this conclusion in the first place
Answer: So take $\sigma = (4,5)(2,3,7)$. The order, by definition, is the the smallest natural number $n$ such that $\sigma^n = (1)$ (i.e. the identity element in the group, i.e. the element that sends every number to itself). Since the cycles $(4,5)$ and $(2,3,7)$ are disjoint you have
$$\begin{align}
\sigma^n &= (4,5)(2,3,7)(4,5)(2,3,7)\dots (4,5)(2,3,7)(4,5)(2,3,7)\\
&= (4,5)(4,5)\dots (4,5)(4,5)(2,3,7)(2,3,7)\dots (2,3,7)(2,3,7)\\
&= (4,5)^n(2,3,7)^n
\end{align}$$
(note that the two elements $(4,5)$ and $(2,3,7)$ commute).
So the order of $\sigma$ is exactly the smallest natural number $n$ such that $(4,5)^n = (1)$ and $(2,3,7)^n = (1)$ (think about this fact for a moment).
But what is the order of a each of $(4,5)$ and $(2,3,7)$?
Well, the order of $(4,5)$ is two exactly because $(4,5)^2 = (4,5)(4,5) = (1)$. The order of $(2,3,7)$ is $3$ because
$$\begin{align}
(2,3,7)^1 &= (2,3,7) \\
(2,3,7)^2 &= (2,7,3) \\
(2,3,7)^3 &= (1)
\end{align}
$$
Now it is not to hard to see that the order of $\sigma$ is exactly the least common multiple of $2$ and $3$ (since we need both $(4,5)^m = (1)$ and $(2,3,7)^m = (1)$ and the smallest $m$ where this happens is exactly the least common multiple). Hence the final answer is $6$.

Addendum: I just wanted to add a bit about orders of these elements. First note that for example the element $(4,5)$ is just the element
$$
(4,5) = \begin{pmatrix}
1 & 2 &3 & 4 & 5 & 6 & 7 & 8 \\ 1 & 2 & 3 &5 & 4& 6 & 7 & 8
\end{pmatrix}.
$$
(Hence $4$ maps to $5$ and $5$ to $4$). So when you compose (multiply) the element with itself, then you get
$$
\begin{align}
(4,5)(4,5) &= \begin{pmatrix}
1 & 2 &3 & 4 & 5 & 6 & 7 & 8\\ 1 & 2 & 3 &5 & 4& 6 & 7 & 8
\end{pmatrix}\begin{pmatrix}
1 & 2 &3 & 4 & 5 & 6 & 7 & 8\\ 1 & 2 & 3 &5 & 4& 6 & 7 & 8
\end{pmatrix} \\ &= \begin{pmatrix}
1 & 2 &3 & 4 & 5 & 6 & 7 & 8\\ 1 & 2 & 3 &4 & 5& 6 & 7 & 8
\end{pmatrix} = (1)
\end{align}
$$
(I usually write the identity as $(1)$).
This means that the order of $(4,5)$ is $2$. Likewise you find that
$$
(2,3,7) = \begin{pmatrix}
1 & 2 &3 & 4 & 5 & 6 & 7 & 8\\ 1 & 3 & 7 &4 & 5& 6 & 2 & 8
\end{pmatrix}.
$$
Comment: There's a typo on $(237)^2$ should be $(273)$ not $(173)$.
Comment: @kub0x: Nice catch
Answer: Prove that easy lemma: the order of a permutation expressed as a product of disjoint cycles is the minimal common multiple of the lengths of the cycles.
To prove the above you may want to use the fact (also easily provable) that two disjoint cycles commute...
Comment: Easy is in the eye of the beholder.
Comment: The OP claims to "have an extremely poor understanding of this subject."
Comment: Indeed: I'm trying to push forward the OP into trying his strength since, imo, the beholder here is anyone having a minimal good understanding of cycles and their orders.
Comment: Yes, he does...and thus he needs to make an effort to enhance that understanding of his of the basics, otherwise it'd be like he's expecting to get a complete class on this subject here, which imo would be non-realistic.
Comment: One further hint for the OP: in any group $\,G\,$, if there are two elements $\,x\,,\,y\in G\,$ that *commute*, then $\,(xy)^n=x^ny^n\,\,,\,\,\forall\,n\in\Bbb N\,$
Answer: Also we find order of permutation by the formula ......
If p,q be the permutation then
 o(pq) = L.C.M (length of p , length of q )
For exam:- (1 4) (3 5 7 8 )
Here length of (1 4 ) is 2 and length of (3 5 7 8) is 4
So , order of (1 4) (3 5 7 8 )= L.C.M (2 ,4 )= 4


Are Python dictionaries literals evaluated in order?

Question: When I run this
import itertools

bar = itertools.count(1).next

print {'a': bar(), 'b': bar(), 'c': bar()}

on CPython, I get {'a': 0, 'b': 1, 'c': 2}. Is this consistent across implementations and/or documented anywhere? Will a, b and c ever be assigned values out of order?
Comment: I don't think so.  Considering that dictionary keys are not guaranteed to be in any order in the first place, I don't think you can make any guarantee as to what other the interpreter builds a dict literal.  It's an interesting question though. Nope, apparently from some of the answers below the Python docs do make a prescription on this, though that's good.
Comment: I'm not sure it will always work for you. Maybe if you initialize it inline like in your example it works. I'm pretty sure that if you create a new dict and assign the values in the same order, it won't  be kept
Answer: The answer to your question can be found here (I do not have enough reputation to add this as a comment).
In sum, "Dictionary evaluation order should be the same as written, but there is a outstanding bug where values are evaluated before the keys.'
Comment: Here, have an upvote so you can leave a comment next time.
Comment: Commenting level unlocked - I see bright days ahead. Thank you! :)
Comment: That's fine. My question is whether the **pairs** are evaluated in order.
Comment: And another from me.
Answer: From Python Docs (emphasize mine):

If a comma-separated sequence of key/datum pairs is given, they are evaluated from left to right to define the entries of the dictionary: each key object is used as a key into the dictionary to store the corresponding datum....

So, pairs will always be evaluated in order. But don't get confused with the order of the elements.
Answer: Interesting question. A better test would be to use integers, as these hash to their own values, and to use them out of order in the literal, so that you can see which order they were evaluated in. When you do that, you see:
>>> print {1: bar(), 3: bar(), 2: bar()}
{1: 1, 2: 3, 3: 2}

which implies that they are evaluated in order from left to right, even though they are not stored in the dictionary in that order.
Comment: That still has nothing to do with the order in which the dictionary literal is evaluated by the interpreter.
Comment: Yes it does: the point of the bar() function is that it returns the incrementing counter, which shows the order it was called. Here we see that 1 was called first, then 3, then 2, so the literal was evaluated left to right.


Improvising blues chords

Question: I understand the concept of the blues scale and its blue notes flat 3rd flat 5th and flat 7th, my question is: What chords can you use to accompany the blues because I'm tired of just staying on the I IV V.
In other words the major scale has a chord scale match up in the key of C:   C, Dmin, Emin, Fmaj7, G7, Amin, Bminflat5.
What would be the chords for the blues scale in C? C?, Eflat?, F? Fsharp?, G?, Bflat?
Comment: When I listen to someone like McCoy Tyner play a simple I IV V blues the bass could be playing a simple I IV V progressions but Tyner is playing a different chord with every beat!  4 different chords a measure sometimes more! What is he playing?
Comment: Thanks guys for taking the time to answer, I am definitely going to explore some of these ideas
Answer: Tonal harmony does provide some ways to further develop harmonic patterns in blues, but with some specificities.
The secondary dominant is a concept borrowed from classical harmony that's widely used in jazz blues. This may be taken an additional step further with the commonly used in Jazz ii-V-I progression.
So, for a basic 12 bar blues progression
I   I   I   I
IV  IV  I   I
V   V   I   I

We can introduce a ii-V-I (applied to the concept of secondary dominant, secondary sub-dominant or, more generically "local key") for each change in harmonic function:
I      I      I     ii/IV V/IV    <--- ii-V-I to approach the subdominant
IV     IV     I     I
ii     V      I     I       <--- here we already have V-I, just add the ii before the dominant

Further harmonic development can be:
I      IV     I     ii/IV V/IV    <--- simple I-IV-I- progression
IV     IV     I     V/ii          <- secondary dominant to approach the ii
ii     V      I     ii V      <--- introduce "turnaround" with ii-V-I of the tonic proper

This is, I think, some times called a "basic blues progression", to distinguish from the more simple, so more generic blues progression.
As I understand, so far we have only used techniques that could have been used by any composer of the classical period, to introduce harmonic development and increase harmonic rhythm. As I said, secondary dominants, passing chords, and the ii-V-I progression is nothing more in essence than a circle of fifths progression.
The blues specificities come of course from the generic use of 7th chords in all scale degrees and chords, and the voice leading applied. Not that the general classical rules of voice leading (keep common tones, move by steps, etc.) are not generically followed, but because of the special focus given to the so called guide tones (the 3rds and 7ths of all chords).
So, to be clear, let's put the example in chord names, for example in C, rather than roman numerals:
C7    F7    C7    Gm7 C7 <-- C does not function here as tonic but as dominant of F
F7    F7    C7    A7      <-- A is dominant of D
Dm7   G7    C7    Dm7 G7  <-- initial Dm anticipates the coming of the dominant proper, G

Harmony can be further enriched by chromatic substitutions, again, the same basic idea as in classical harmony: finding chromatic neighbours for passing chords, etc. But I'm afraid I'm still trying to make my self at home with that part myself..
Answer: E pentatonic blues scale is
E-G-A-B-D

which as a harmonized scale in sevenths would be

    Em7 G7 Am7 B7 Ddim7

but blues being the forgivingly dissonant beast that it is would also accept, depending on the melody:

    E7 G7 A7 B7 D7

Depending on the context, you could also have success constructing chords out of whatever pentatonic notes take your fancy.
So instead of
 (E-G#-B) (A-C#-E) (B-D#-F#)

you could try
(G-B-D) (E-A-D) (D-G-A)

Don't overthink it.  Avoid playing chord notes that are a tone or less away from the melody notes--unless you want to hear that tension--and have fun.  There's a reason why the pentatonic scale is universal and that reason is simplicity.
Comment: Pentatonic blues? You've discussed the minor pentatonic. The blues scale, in this key, must have the b5  - Bb. Minor blues contains minor pent notes plus b5. Minor pent has just the 5 minor notes.
Comment: "Must"? Strong words for rural folk music of the fin du siecle.
Comment: Do a bit of research, please.
Answer:
I understand the concept of the blues scale and its blue notes flat
  3rd flat 5th and flat 7th

Hmmm... I don't think it's quite that simple. IMO Blues playing is conceptually more about exploring ranges of the octave than being just a set of fixed notes like the major scale:
What's the difference between the tritone and the blue note?
https://music.stackexchange.com/a/31073/18896

my question is: What chords can you use to accompany the blues because
  I'm tired of just staying on the I IV V. In other words the major
  scale has a chord scale match up in the key of C:   C, Dmin, Emin,
  Fmaj7, G7, Amin, Bminflat5. What would be the chords for the blues
  scale in C? C?, Eflat?, F? Fsharp?, G?, Bflat?

It sounds like you're in the mindset where you think you have to choose a scale, and then make both your chords and your melodies from the notes in that scale. You don't! That idea is often taught to beginners as it's easy to make something that 'works ok' if you stay within that, but it's not a "rule" of music.
Even 'standard' theory gives you plenty of routes out of that box - joseem has mentioned some of them. Speaking more informally, modern blues/pop/rock often seems to use a kind of 'hybrid' of the major, minor, and mixolydian scales, and adds a blues 'between the notes' sensibility, which leads to all kinds of possibilities of chord borrowing and bending things to 'make them fit'.
Robert Cray is an example of a blues musician who explores some less standard chord progressions; take a listen to the tracks Already Gone and Out Of Eden if you can find them. You might find them somewhat soul-tinged; indeed, soul music (and even motown) might be a good place to look for chord progressions that work with bluesy melodies.

Improvising blues chords


Como consultar disponibilidade de domínios (whois) com php?

Question: Como consultar a disponibilidade de um domínio nacional (.br) e ou outros usando PHP?
Existe alguma classe php pronta para isso?
Answer: Este modelo além de mostrar disponibilidade tem um modal com todas as informações .
<!DOCTYPE html>

    <link rel="stylesheet" type="text/css" href="/colorbox/colorbox.css">

    <?php
    error_reporting(E_ALL & ~ E_NOTICE);
    #######################################################################
    #               PHP Whois Lookup Class
    #   Script Url: http://99webtools.com/php-whois-script.php
    #   Author: Sunny Verma
    #   Email: firstname.lastname@example.com
    #   Website: http://99webtools.com
    #   License: GPL 2.0, @see http://www.gnu.org/licenses/gpl-2.0.html
    ########################################################################
    class Whois{
    private $WHOIS_SERVERS = array(
    "com"               =>  array("whois.verisign-grs.com","whois.crsnic.net"),
    "net"               =>  array("whois.verisign-grs.com","whois.crsnic.net"),
    "org"               =>  array("whois.pir.org","whois.publicinterestregistry.net"),
    "info"              =>  array("whois.afilias.info","whois.afilias.net"),
    "biz"               =>  array("whois.neulevel.biz"),
    "us"                =>  array("whois.nic.us"),
    "uk"                =>  array("whois.nic.uk"),
    "ca"                =>  array("whois.cira.ca"),
    "tel"               =>  array("whois.nic.tel"),
    "ie"                =>  array("whois.iedr.ie","whois.domainregistry.ie"),
    "it"                =>  array("whois.nic.it"),
    "li"                =>  array("whois.nic.li"),
    "no"                =>  array("whois.norid.no"),
    "cc"                =>  array("whois.nic.cc"),
    "eu"                =>  array("whois.eu"),
    "nu"                =>  array("whois.nic.nu"),
    "au"                =>  array("whois.aunic.net","whois.ausregistry.net.au"),
    "de"                =>  array("whois.denic.de"),
    "ws"                =>  array("whois.worldsite.ws","whois.nic.ws","www.nic.ws"),
    "sc"                =>  array("whois2.afilias-grs.net"),
    "mobi"              =>  array("whois.dotmobiregistry.net"),
    "pro"               =>  array("whois.registrypro.pro","whois.registry.pro"),
    "edu"               =>  array("whois.educause.net","whois.crsnic.net"),
    "tv"                =>  array("whois.nic.tv","tvwhois.verisign-grs.com"),
    "travel"            =>  array("whois.nic.travel"),
    "name"              =>  array("whois.nic.name"),
    "in"                =>  array("whois.inregistry.net","whois.registry.in"),
    "me"                =>  array("whois.nic.me","whois.meregistry.net"),
    "at"                =>  array("whois.nic.at"),
    "be"                =>  array("whois.dns.be"),
    "cn"                =>  array("whois.cnnic.cn","whois.cnnic.net.cn"),
    "asia"              =>  array("whois.nic.asia"),
    "ru"                =>  array("whois.ripn.ru","whois.ripn.net"),
    "ro"                =>  array("whois.rotld.ro"),
    "aero"              =>  array("whois.aero"),
    "fr"                =>  array("whois.nic.fr"),
    "se"                =>  array("whois.iis.se","whois.nic-se.se","whois.nic.se"),
    "nl"                =>  array("whois.sidn.nl","whois.domain-registry.nl"),
    "nz"                =>  array("whois.srs.net.nz","whois.domainz.net.nz"),
    "mx"                =>  array("whois.nic.mx"),
    "tw"                =>  array("whois.apnic.net","whois.twnic.net.tw"),
    "ch"                =>  array("whois.nic.ch"),
    "hk"                =>  array("whois.hknic.net.hk"),
    "ac"                =>  array("whois.nic.ac"),
    "ae"                =>  array("whois.nic.ae"),
    "af"                =>  array("whois.nic.af"),
    "ag"                =>  array("whois.nic.ag"),
    "al"                =>  array("whois.ripe.net"),
    "am"                =>  array("whois.amnic.net"),
    "as"                =>  array("whois.nic.as"),
    "az"                =>  array("whois.ripe.net"),
    "ba"                =>  array("whois.ripe.net"),
    "bg"                =>  array("whois.register.bg"),
    "bi"                =>  array("whois.nic.bi"),
    "bj"                =>  array("www.nic.bj"),
    "br"                =>  array("whois.nic.br"),
    "bt"                =>  array("whois.netnames.net"),
    "by"                =>  array("whois.ripe.net"),
    "bz"                =>  array("whois.belizenic.bz"),
    "cd"                =>  array("whois.nic.cd"),
    "ck"                =>  array("whois.nic.ck"),
    "cl"                =>  array("nic.cl"),
    "coop"              =>  array("whois.nic.coop"),
    "cx"                =>  array("whois.nic.cx"),
    "cy"                =>  array("whois.ripe.net"),
    "cz"                =>  array("whois.nic.cz"),
    "dk"                =>  array("whois.dk-hostmaster.dk"),
    "dm"                =>  array("whois.nic.cx"),
    "dz"                =>  array("whois.ripe.net"),
    "ee"                =>  array("whois.eenet.ee"),
    "eg"                =>  array("whois.ripe.net"),
    "es"                =>  array("whois.ripe.net"),
    "fi"                =>  array("whois.ficora.fi"),
    "fo"                =>  array("whois.ripe.net"),
    "gb"                =>  array("whois.ripe.net"),
    "ge"                =>  array("whois.ripe.net"),
    "gl"                =>  array("whois.ripe.net"),
    "gm"                =>  array("whois.ripe.net"),
    "gov"               =>  array("whois.nic.gov"),
    "gr"                =>  array("whois.ripe.net"),
    "gs"                =>  array("whois.adamsnames.tc"),
    "hm"                =>  array("whois.registry.hm"),
    "hn"                =>  array("whois2.afilias-grs.net"),
    "hr"                =>  array("whois.ripe.net"),
    "hu"                =>  array("whois.ripe.net"),
    "il"                =>  array("whois.isoc.org.il"),
    "int"               =>  array("whois.isi.edu"),
    "iq"                =>  array("vrx.net"),
    "ir"                =>  array("whois.nic.ir"),
    "is"                =>  array("whois.isnic.is"),
    "je"                =>  array("whois.je"),
    "jp"                =>  array("whois.jprs.jp"),
    "kg"                =>  array("whois.domain.kg"),
    "kr"                =>  array("whois.nic.or.kr"),
    "la"                =>  array("whois2.afilias-grs.net"),
    "lt"                =>  array("whois.domreg.lt"),
    "lu"                =>  array("whois.restena.lu"),
    "lv"                =>  array("whois.nic.lv"),
    "ly"                =>  array("whois.lydomains.com"),
    "ma"                =>  array("whois.iam.net.ma"),
    "mc"                =>  array("whois.ripe.net"),
    "md"                =>  array("whois.nic.md"),
    "mil"               =>  array("whois.nic.mil"),
    "mk"                =>  array("whois.ripe.net"),
    "ms"                =>  array("whois.nic.ms"),
    "mt"                =>  array("whois.ripe.net"),
    "mu"                =>  array("whois.nic.mu"),
    "my"                =>  array("whois.mynic.net.my"),
    "nf"                =>  array("whois.nic.cx"),
    "pl"                =>  array("whois.dns.pl"),
    "pr"                =>  array("whois.nic.pr"),
    "pt"                =>  array("whois.dns.pt"),
    "sa"                =>  array("saudinic.net.sa"),
    "sb"                =>  array("whois.nic.net.sb"),
    "sg"                =>  array("whois.nic.net.sg"),
    "sh"                =>  array("whois.nic.sh"),
    "si"                =>  array("whois.arnes.si"),
    "sk"                =>  array("whois.sk-nic.sk"),
    "sm"                =>  array("whois.ripe.net"),
    "st"                =>  array("whois.nic.st"),
    "su"                =>  array("whois.ripn.net"),
    "tc"                =>  array("whois.adamsnames.tc"),
    "tf"                =>  array("whois.nic.tf"),
    "th"                =>  array("whois.thnic.net"),
    "tj"                =>  array("whois.nic.tj"),
    "tk"                =>  array("whois.nic.tk"),
    "tl"                =>  array("whois.domains.tl"),
    "tm"                =>  array("whois.nic.tm"),
    "tn"                =>  array("whois.ripe.net"),
    "to"                =>  array("whois.tonic.to"),
    "tp"                =>  array("whois.domains.tl"),
    "tr"                =>  array("whois.nic.tr"),
    "ua"                =>  array("whois.ripe.net"),
    "uy"                =>  array("nic.uy"),
    "uz"                =>  array("whois.cctld.uz"),
    "va"                =>  array("whois.ripe.net"),
    "vc"                =>  array("whois2.afilias-grs.net"),
    "ve"                =>  array("whois.nic.ve"),
    "vg"                =>  array("whois.adamsnames.tc"),
    "yu"                =>  array("whois.ripe.net")
    );
    public function whoislookup($domain)
    {
    $domain = trim($domain); //remove space from start and end of domain
    if(substr(strtolower($domain), 0, 7) == "http://") $domain = substr($domain, 7); // remove http:// if included
    if(substr(strtolower($domain), 0, 4) == "www.") $domain = substr($domain, 4);//remove www from domain
    if(preg_match("/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/",$domain))
    return $this->queryWhois("whois.lacnic.net",$domain);
    elseif(preg_match("/^([-a-z0-9]{2,100})\.([a-z\.]{2,8})$/i",$domain))
    {
    $domain_parts = explode(".", $domain);
    $tld = strtolower(array_pop($domain_parts));
    $server = $this->WHOIS_SERVERS[$tld][0];
    if(!$server) {
    return "Error: Nenhum servidor WHOIS apropriado encontrado para o domínio $domain!";
    }
    $res=$this->queryWhois($server,$domain);
    while(preg_match_all("/Whois Server: (.*)/", $res, $matches))
    {
    $server=array_pop($matches[1]);
    $res=$this->queryWhois($server,$domain);
    }
    return $res;
    }
    else
    return "invalido";
    }
    private function queryWhois($server,$domain)
    {
    $fp = @fsockopen($server, 43, $errno, $errstr, 20) or die("Socket Error " . $errno . " - " . $errstr);
    if($server=="whois.verisign-grs.com")
    $domain="=".$domain;
    fputs($fp, $domain . "\r\n");
    $out = "";
    while(!feof($fp)){
    $out .= fgets($fp);
    }
    fclose($fp);
    return $out;
    }
    }

    if ($_POST["dominio"]){
        $dominio=$_POST["dominio"];
        $whois=new Whois;

        $result= $whois->whoislookup($dominio);

        $result="
".$result."
";

        $pos = strpos($result, "invalido");
        if ($pos === false) {
            $pos = strpos($result, "No match for");
            if ($pos === false) {
                  echo "Dominio registrado";
                  echo "
Mostrar informações
";
                  echo "

".$result."

";
            } else {
                  echo "Dominio ( ".$dominio." ) disponível para registro";
            }
        }else{

           echo "Nome de dominio ( ".$dominio." ) inválido";

        }

    }
    ?>

    <form method="post" action="">
    <input type="text" name="dominio" size="30">
    <input type=submit value=Consultar>
    </form>

github biblioteca colorbox

caso não queira usar biblioteca colorbox pode usar um modal só com CSS

Neste caso retire as referencias e o script que está na seção head e coloque esse CSS
      .modalDialog {
      position: fixed;
      font-family: Arial, Helvetica, sans-serif;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
      background: rgba(0, 0, 0, 0.8);
      z-index: 99999;
      opacity: 0;
      -webkit-transition: opacity 400ms ease-in;
      -moz-transition: opacity 400ms ease-in;
      transition: opacity 400ms ease-in;
      pointer-events: none;
    }
    .modalDialog:target {
      opacity: 1;
      pointer-events: auto;
    }
    .modalDialog > div {
      width: 700px;
      height: 600px;
      position: relative;
      margin: 10% auto;
      padding: 5px 20px 13px 20px;
      border-radius: 10px;
      background: #fff;
      background: -moz-linear-gradient(#fff, #999);
      background: -webkit-linear-gradient(#fff, #999);
      background: -o-linear-gradient(#fff, #999);
      overflow: scroll;
    }
    .close {
      background: #606061;
      color: #FFFFFF;
      line-height: 25px;
      position: absolute;
      text-align: center;
      width: 24px;
      text-decoration: none;
      font-weight: bold;
      -webkit-border-radius: 12px;
      -moz-border-radius: 12px;
      border-radius: 12px;
      -moz-box-shadow: 1px 1px 3px #000;
      -webkit-box-shadow: 1px 1px 3px #000;
      box-shadow: 1px 1px 3px #000;
    }
    .close:hover { background: #00d9ff; }
    .child { position:fixed;}
    .parent { position:absolute; }

e a parte final do PHP substitua essas duas linhas
    echo "
Mostrar informações
";
    echo "

".$result."

";

Por
    echo "
Mostrar informações

X

".$result."

";

Comment: Leo, você tem um link de referência?
Comment: O link, bem como o autor e demais dados que interessar possam estão no próprio código.
Comment: Eu percebi. Estava faltando o .com. Obrigado vou ver se funciona
Comment: o código dele só te traz informações do domínio. Se é registrado ou não eu que implementei.
Comment: Muito boa a implementação. Vai ser bastante útil pra mim. Obrigado.


configuring default PYTHONPATH

Question: I have Django application and few Django commands that I would execute through cronjobs on CentOS 5.
Recently I updated my python-setuptools package, which in-turn update python-devel packages.
After performing this update, the default PYTHONPATH settings for the Django commands executed through cronjob are different from the Django application which I execute from shell. Because of this mismatch my old Django cronjobs fail since the required libraries are not in path.
How do I resolve this issue and ensure that both the cronjob Django commands and the Django application have the same environment?
Answer: I solved this issue.
When i had updated my python-setuptools and python-devel packages the default python interpreter configuration changed to the new updated version which has libraries in a different place compared to my old python interpreter.
This affected only the default python interpreter executed from the cronjob, i used absolute path of the old python interpreter in my cronjob scripts and the issue was resolved.
thanks
Shan

configuring default PYTHONPATH


Problem executing grep from PHP using --exclude-dir option

Question: I'm trying to run a grep search from my PHP application and am having trouble with one of the options.  The grep command is as follows:
grep -rn --exclude-dir={img,node_modules,vendor} -E "14847"

This command returns the expected results. However, if I open PHP interactively and run this line:
print `grep -rn --exclude-dir={img,node_modules,vendor} -E "14847"`;

I get results found within the node_modules directory.  Interestingly, if I remove the curly braces and commas and only exclude node_modules, then it works and excludes those results. I can also just list the --exclude-dir option separately for each directory to exclude (but let's ignore that for a moment). So it seems to be something with the handling of curly braces or commas.  I have tried escaping both with backslashes with no luck unfortunately.  Am I missing something in PHP's parsing of the execution operator?
Comment: What do you get for `print \`pwd\`;`? Is it what you expect?
Comment: Yes, it is exactly what I expect.  And the results from the command in my post are all correct with respect to the current working directory.
Comment: I did similar tests. The behavior is the same as the colleague described.
Answer: The {one,two,three} notation is a bash-ism, it's not expanded by either PHP or grep. When you run a command in backticks from within PHP, it runs that program via sh, not bash. Thus, you lose the possibility to use this type of expansion. As a workaround, you can just specify --exclude-dir more than once:
print `grep -rn --exclude-dir=img --exlude-dir=node_module --exclude-dir=vendor -E "14847"`;

Comment: Backticked command is not run directly, it is run with a default command interpreter, which is usually `sh`. Run `<?php echo 'echo \$0';` (replace quotes by backticks)


Javascript require() a file in tests several times does not create the object again

Question: I am writing some tests for a javascript API with mocha. I docker up my project before running the tests and I have realized that requiring a file to create an object in several tests, for example like these ones:
    it('should return false 1', () =>  {
      const testObject = require(./file.json)
      delete testObject.neededAttribute1;
      expect(function(testObject)).to.be.false;
    });

    it('should return false 2', () =>  {
      const testObject = require(./file.json)
      delete testObject.neededAttribute2;
      expect(function(testObject)).to.be.false;
    });

Javascript won't create the object testObject in the second test, but use the first one with the changes previously made, making my tests unusable if I don't manually restore the object with whatever I have changed after the test has been executed.
I understand Javascript does this to be more efficient not loading the same file all the time, but just once.
But how can I make my tests in which I have a file with a correct object and I want to introduce small modifications one by one in each test?
Any ideas?
Answer: clone the object.
Import your object in a before function
https://futurestud.io/tutorials/mocha-global-setup-and-teardown-before-after
Then in each function or in beforeEach function, clone that object with something like lodash's cloneDeep function.
https://lodash.com/docs/4.17.15#cloneDeep
Answer: There is a solution, even if more verbose, but it avoids cloning the object before each test because maybe is not necessary.
describe('Tests', () => {

  const baseTestObject = require('./file.json');

  it('should return false 1', () =>  {
    const testObject = Object.assign({}, baseTestObject, { attribute1: null });
    expect(function(testObject)).to.be.false;
  });

  it('should return false 2', () =>  {
    const testObject = Object.assign({}, baseTestObject, { attribute2: null });
    expect(function(testObject)).to.be.false;
  });

Merging and cloning the objects the following way
const testObject = Object.assign({}, baseTestObject, { attribute2: null });

Maintains the original testObject therefore not affecting other tests.


solving PDE equation like Helmholtz equation in 1D

Question: In my project I need to solve following equation analytically  could anyone help me ? As I read the other questions, my equation seems like   Helmholtz equation
$$
     \triangledown^2 u(x) - k_cu(x) =0 \quad  \\
       u(0) = 1
    \quad x \in [0,L] ,   $$
Comment: A linear PDE, with constant coefficients, and what appears to be periodic boundary conditions (at least in one of the variables, but I think there is a typo: the notations $u(x)$, $u(x, 0)$, and $u(0, x)$ are inconsistent: is $x$ the first variable or the second one?).  Also, you need to clarify what $\Omega$ is.

Have you tried the Fourier transform in the periodic variable?
Comment: sorry it was typo error. I corrected it
Comment: Now you don't have enough boundary conditions to specify a unique solution.
Answer: Just use the definition of the Laplace-operator in 1-D you get that:
\begin{align*}
 u''(x) = k_c u(x)
\end{align*}
This equation has three possible solutions depending on the sign of $k_c$-
If $k_c>0$ the solution is:
\begin{align*}
 u(x) = C_1e^{\sqrt{k_c}x}+C_2 e^{-\sqrt{k_c}x}
\end{align*}
Now inserting your initial value we have the constraint that $C_1+C_2 =1$.
If $k_c<0$ the solution is:
\begin{align*}
 u(x) = C_1\sin({\sqrt{-k_c}x})+C_2 \cos({\sqrt{-k_c}x})
\end{align*}
Again inserting your initial condition we have the constraint $C_2=1$.
If $k_c=0$ well that is left as an exercise ;o)


Is the Alternating group $A_5$ isomorphic to the external direct product $A_4 \oplus \mathbb{Z}_5$?

Question: I have been thinking about this question for a while.
The Alternating group $A_5$ is isomorphic to the icosahedron group which has order 60. $A_5$ is a simple group which means the only normal subgroups are the trivial subgroup and itself.
The group defined by the external direct product $A_4 \oplus \mathbb{Z}_5$ is not simple but it does have order 60. Can we still define an Isomorphism from a simple group to a non simple group?
I might be over thinking this question but are all groups of order 60 isomorphic to each other?
Comment: No, it isn't true. simpleness is invariant over isomorphism
Comment: There are two isomorphism types of abelian groups of order $60$: $C_{60}$ and $C_2\times C_{30}$. The only nonabelian **simple** group of order $60$ is $A_5$. There are lots of nonabelian solvable groups of order $60$ (e.g., $A_4\times C_5$, $S_3\times C_{10}$). There are no nonabelian nilpotent groups of order $60$.
Answer: Without solvability/simplicity, one can use the center. The center of $A_5$ is the trivial group $\{1\}$ while the center of $A_4\times C_5$ is at least $C_5$.
Answer: The group $A_4\times C_5$ is solvable, hence any homomorphic image of it is again solvable. Since $A_5$ is not solvable, there is no such isomorphism.
Answer: No, they are not isomorphic. In fact, the group $A_5$ is simple, so it cannot be expressed as the internal direct product (or even semidirect product) of two nontrivial proper subgroups. It could, however, be a Zappa–Szép product, but I'm not sure.
Comment: Sure, it's a Zappa-Szep product. If you take $H$ to be the stabilizer of a point to get a subgroup isomorphic to $A_4$ of order $12$, and $K$ to be a cyclic subgroup of order $5$ generated by a $5$-cycle (which is an even permutation), you get subgroups $H$ and $K$ with $|HK| = |H||K|/|H\cap K| = (12)(5)/1 = 60$, hence $HK=A_5$, so $A_5$ is  a Zappa-Szep product of $H$ and $K$.
Answer: The fact of being simple (and any other property that you can express without referring to the actual name of the elements or what they stand for in a particular case) is invariant under isomorphism.
As for your last question, God no, even if you consider only abelian groups, where the situation is extremely simple, there are more than one group of a given order $n$ as soon as $n$ is not a square-free number.


How should I tune a guitar with a Floyd Rose tremolo?

Question: A number of my guitars have a Floyd Rose tremolo system with the locking nuts near the headstock.
How can I effectively tune a guitar that has a Floyd Rose locking tremolo?
Comment: Double check your setting first (harmonic positions, bridge, etc).
:)
Comment: I've heard that a good string order to follow is 342516 ("DGABEE"), then repeat. My guess is that the middle two strings pull down the center of the bridge to a relatively stable height.
Answer: Loosen the lock screws at the nut.  Adjust the fine tuners (on the bridge) to the "middle" position, so you'll have room to fine-tune in either direction.
Ideally, tune one string at a time, with a tuner - trying to get the strings in tune with each other will be tough until everything's almost done, as tightening one string moves the bridge and throws the others out of whack.  After several passes over all 6 strings, things should stabilize.  Get things as close as possible before locking down, as the fine tuners have limited range.
Lock the screws at the nut, and (again with a tuner) use the fine-tuners to finish the job.
Comment: Another crucial step is to try to get the strings stretched out as much as possible before locking down the nut.
Comment: I usually adjust the fine tuners with a bias so that there is extra room to raise the pitch of the string, since as they are played they tend to go flat.
Comment: This specific hint http://www.ibanezrules.com/tech/setup/tuning.htm and the whole tech section of this site were extremely useful to me.
Answer: First, unscrew the the locking nuts. Now tune your instrument the usual way.
Second, screw again the locking nuts and use the tuning keys located on the Floyd Rose to fine tune.
Never use the standard tuning keys (i.e. the ones that are located on the headstock) while the strings are blocked or you'll get trouble! :)


Wordpress shortcode inside bootstrap popup

Question: Can i somehow insert a CF7 form shortcode inside bootstrap popover?
This doesnt work:
jQuery(document).ready(function(){
    jQuery('.toolbox_trigger a').popover({
    content: '[contact-form-7 id="1" title="Callback"]',
    html: true,
    placement: "bottom",
    trigger: "focus",
    });
});

Answer: I am not 100% sure but you can try with
content: '<?php [contact-form-7 id="1" title="Callback"] ?>' or  content: '<?php echo [contact-form-7 id="1" title="Callback"] ?>'
Comment: if you look at this article it explains it better that we can use PHP inside of JS if there is a requirement "http://wptricks.co.uk/include-php-variables-into-jquery/#.V-PiSEYrJhE"


Round sides of an input box and put in icons?

Question:
What rules would I use to round the sides of a text input like in the picture? Also, what is the best way to put in the icons for the search icon and the filter button? The filter button needs to be clickable, but the search icon does not.
Comment: Add code. No code no help!!
Answer: <code>input {
    border-radius: 3px;
}
</code>
That makes it slightly round. You can set it to 4px for a more conventional look, or a higher number for a more elliptical style.


Expectation of the maximum of n random variables?

Question: Let's say we have $n$ independent random variables, each variable equally likely to take any value in the interval $[0,1]$. What is the expectation of the maximum of these $n$ random variables?
Progress so far :-
I came up with a intuitive sort of solution. Looking for a rigorous one. On an average, we can say that the $n$ points would be equally spaced on the number line, as no variable is special and no point on the number line is special. Hence Expectation = $\frac {n}{n+1}$ as this is the right most point on an average.
Answer: HINT
If $X = \max(X_1,\ldots,X_n)$, then $X < c$ iff $X_i < c$ for all $i$. Probabilities multiply over independent events.
Comment: So we obtain P(X < c) = product of P(Xi < c). How do we compute expectation using this? Isn't expectation defined for the density function?
Comment: This hint helps find CDF. Take derivative to get PDF. Use PDF to find expectation. Do you know how to do these steps?
Comment: got it thanks !


Alarm, even if application is shutdown

Question: I have integrated a small to-do list in my WinForms application, where-in user can add tasks and set alarm for it. Is it possible to run timer (or alarm clock counter) in background, even if application is closed. I am using the AlarmClass written as answer here. The aim is only to show a MessageBox when the alarm time is reached and nothing else to do with the application. Also multiple alarm setting should be possible.
I am sorry if my question is not elaborated, coz I dont know wat other details I must include. But ready to reply your questions.
Thanks in advance.
Edit: Any comments on this link?
Answer: Short answer
No. If your application is shut down, there's no good way.
Long answer
Yes if you resort to clever hackery. You could:

Run your app in the system tray / background when the 'X' button is clicked
Run a scheduled task which launches your app in "alarm-checking" mode every N minutes
Write a windows service which launches your app for alarm events
Comment: @Niraj: The alarm clock app in your link is a good approach, and fits in well with Chris' first suggestion. It has a UI and shows how to park it in the system tray. Easier to implement than a Windows service (which doesn't have a UI).
Comment: @Niraj Looks good to me, however this approach does have its drawbacks. For example, you'll need to make sure the app is always running (auto-start). Furthermore if the user decides to kill it (on purpose or accidentally), no more alerts. I suppose you should probably leave that decision to the user anyway, so this seems like a good approach.
Comment: Thanks for input seed, I will dig more on these points and post queries if any.
Comment: Any comments on this [link](http://channel9.msdn.com/coding4fun/articles/Creating-an-Alarm-Clock-in-the-System-Tray)
Answer: I'm not sure, but can't you create a Windows application which only shows up in the Systemtray. Add the required keys to the registry to make sure it will automatically start when windows starts.
Otherwise you can split it up into two separate applications;
- Windows Application to manage the alert
- Windows Service to do the check in the background
Comment: That tutorial seems to be pretty easy. Of course it's a little bit too basic for your needs (i.e. multiple alarms) and you should definately store the alarms in a file/database. But its a good start!
Comment: Hmm good idea to separate application in two parts. I have never created a service before, I will try to find some literature and samples on it. Thanks
Comment: Any comments on this [link](http://channel9.msdn.com/coding4fun/articles/Creating-an-Alarm-Clock-in-the-System-Tray) ?

Alarm, even if application is shutdown


Is topology just the minimal mathematical structure you need to define on a set just to define continuous functions?

Question: I looked for a lot of explanations for the idea of defining a topology for a set to make a topological space, I found a lot of clever explanations but most of them seem like just "concrete explanations that may seem like the original idea but actually has nothing to do with it", and the worst of them who try to make an analogy between a topological space and a metric space by explaining them with a notation of semi-measures? which I guess has nothing to do with the actual idea behind the topology.
I think "but not quite sure that's why I'm asking" that the core idea of topology is in its definition of continuous functions, like if we take the donut and cup definition of two shapes: two shapes are the same topologically if there is no cuts needed to transform one of them to the other, and put two 2D surfaces in $\mathbb{R}^3$ , it's easy to see that they will satisfy this property if there is a kind of a continuous function and a continuous inverse between them, so in order to generalize that you need a minimal structure to define for sets so that you can define continuous functions, so is that it?
EDIT: It seems that the easiest way to make sense of topologies and there axioms at the beginning of studying the subject is basically through a generalization of continuous functions $f:\mathbb{R}^n\to \mathbb{R}^m$, in the simplest case of them $f:\mathbb{R}\to \mathbb{R}$ we can easily see that a function is continuous everywhere if the preimage of any open interval is also an open interval, if $f$ is discontinuous at some point say $x$ it's easy to see that you can make an open interval containing $f(x)$ but it's preimage will be half closed half open interval so it fails the condition of making the preimage of any open subset open, then the axioms of a topology can be seen as the properties of the set of open intervals, the union of 2 opens is open ...etc, so a topology is a generalization of the set of open intervals so we can define continuous functions for any set with such a structure topological spaces, this intuition seems also to be the direction of Munkres's topology book when he first introduce continuous functions.
Answer: I think the answer to your question is a qualified "Yes!". A topology is indeed in many ways secondary to the continuous functions that are defined on it and it often convenient to make the continuous functions primary and induce the topology using that.
A great example of this is the Zariski topology on, say, $\mathbb C^n$. The topology is defined in the following way: It is the weakest topology that makes all polynomial functions $f: \mathbb C^n \to \mathbb C$ continuous where we give the target the cofinite topology which corresponds to the intuition that we can tell when the polynomial takes a particular value. So closed sets are precisely generated by zero sets of polynomials.
This idea can be made more sophisticated by talking about sheaves and such things but the fundamental point always is that we care about the functions first, topology second.
In case of the standard topology on Euclidean space, it is perhaps not so clear what the continuous functions should be a priori which is why the answer to your question is a qualified yes. The other way of thinking about closed and open sets is that closed sets are the "answers to questions you can ask about the space".
That is, in the Euclidean topology, we can always know if a particular number lies in say $[0,1]$. We just compute the first few significant digits and check. On the other hand, we can never be sure that a particular number lies in $(0,1)$. Even if the number looks like $0.00000\dots$ with a million leading zeros, the next digit might be non zero. Of course this is superficially related to the representation of the number we are using but any "computable" representation will have this property.
This is related to the continuous functions point of view because the function "n-th digit of a number" is a function we would very much like to be continuous.
Comment: Let f:[0,1] -> N be the n-th digit function.
Give [0,1] the topology generated by the base
{ f$^{-1}$(n) : n in { 0,1,2,3,4,5,6,7,8,9 } }.  Behold,, as you wished @Asvin a continuous n-th digit function.
Comment: Your characterization of the Zariski topology is not correct. For example, it would immediately imply that the Zariski topology on $\mathbb{C}^1$ is discrete, which is not true. You could instead say it's the weakest topology that makes all polynomial functions $f\colon \mathbb{C}^n\to \mathbb{C}$ continuous, where we give the target the **cofinite** topology... But it's probably better just to characterize it as the weakest topology that makes all zero sets of polynomials closed.
Comment: Yes, you are right of course! I should have said we give the target the topology where singletons are closed, aka the cofinite topology.
Comment: Of course the $n$-th digit of a number is **not** a continuous function on $[0,1]$ nor the reals!, at least in its standard topology.
Answer: I like Asvin's answer a lot, but I would like to add an answer of a slightly different flavor.
I see the answer as "yes," because a topology is the minimum amount of structural information about a space that is generally used in mathematics to decide whether a function is continuous.
The definition of "continuous" was probably first given with respect to functions from $\mathbb{R}$ to $\mathbb{R}$ (or subsets thereof), and defined with respect to $\mathbb{R}$'s metric structure, although the definition predated the idea of "$\mathbb{R}$'s metric structure" so nobody would have described it that way. A function $f:\mathbb{R}\rightarrow \mathbb{R}$ is continuous at a point $c\in \mathbb{R}$ if for all $\varepsilon >0$, there exists a $\delta >0$ such that $|x-c|<\delta\Rightarrow |f(x)-f(c)|<\varepsilon$. (Notice that the metric structure of $\mathbb{R}$ is playing the key role here, as $|x-c|$ and $|f(x)-f(c)|$ are both measurements given by the metric.) A function $f:\mathbb{R}\rightarrow\mathbb{R}$ is continuous (no reference to a specific point) if it is continuous at each point $c\in \mathbb{R}$.
In this context, at some point it was noticed (and proven as a theorem) that $f$ being continuous on all of $\mathbb{R}$ is actually equivalent to the property that for any open set $U\subset\mathbb{R}$, the inverse image $f^{-1}(U)$ is also open. Working out this equivalence (for functions $\mathbb{R}\rightarrow \mathbb{R}$) is a very satisfying exercise.
Once this theorem was articulated and proven, it became possible to make the following profound observation: While the original definition of continuity made explicit use of distances like $|x-c|$ and $|f(x)-f(c)|$, actually it would be possible to determine whether $f:\mathbb{R}\rightarrow\mathbb{R}$ is continuous without being able to access these distances, as long as we still have access to whether or not any given set is open. In other words, the knowledge of which sets are open is enough information to determine continuity. Furthermore, if we changed how distances are measured but in such a way that it didn't change which sets are the open ones (for example by replacing $|x-y|$ with $2|x-y|$ as the distance between $x$ and $y$), it would not change which functions are the continuous ones. To summarize, while it initially appeared that the metric was intrinsically involved in determining if a function was continuous, the above theorem means that really it's just that the metric determines which sets are open, and the collection of open sets is really what determines continuity.
This is what paved the way for the definition of a topology. If knowing which sets are open is really what determines whether functions are continuous, then we can drop the metric from the definition completely and use the conclusion of the above theorem as a definition: if $X,Y$ are any spaces such that I know how to determine whether their subsets are open, then $f:X\rightarrow Y$ is defined to be continuous if for each open $U\subset Y$, the inverse image $f^{-1}(U)$ is open in $X$. Thus the information about which sets are open (i.e., the topology) is really the only info you need to determine continuity.
(I see this as analogous to the progression in learning trigonometry from (a) originally defining $\sin \theta$ as the ratio of certain sides in a right triangle, which only makes sense when $0<\theta<\pi/2$, but then (b) learning as a theorem that this definition of $\sin \theta$ coincides with the $y$-coordinate of a certain point on the unit circle, to finally (c) replacing the ratio of sides definition with this $y$-coordinate of the unit circle point as the definition, so that $\sin\theta$ can be defined even when $\theta$ is not in the interval $(0,\pi/2)$. Similarly, continuity is (a) first defined with respect to a metric, but then (b) it is proven as a theorem that the definition coincides with a criterion based only on open sets, and finally (c) the criterion based on open sets replaces the metric-based definition as the definition, allowing continuity to be defined even when there is no metric, as long as you know which sets are open.)
Let me add a comment relating this train of thought to William Elliot's answer, because it pulls in a somewhat different direction. William Elliot's answer foregrounds limits as the key idea of a topology, whereas this answer, and Asvin's, foreground continuity. I see this difference as essentially one of taste. Limits and continuity are deeply interlinked concepts. Indeed, the classical $\varepsilon$-$\delta$ definitions of the two notions (for functions $\mathbb{R}\rightarrow \mathbb{R}$) look almost identical. One can define either in terms of the other. So while my tendency (per the above) is to view continuity as the fundamental property that a topology abstracts from a metric space, I'm not really arguing against William Elliot's decision to view limits as the key thing being abstracted. It seems to me one can choose which way one prefers to look at it, and develop a complete theory from either starting point.
Comment: Two or three decades ago, I would have said that I never fail to be surprised by all the arcane and essentially unknown byways that exist in mathematics ([Example 1](https://math.stackexchange.com/a/3114828/13130) *AND* [Example 2](https://math.stackexchange.com/a/3030329/13130) *AND* [Example 3](https://math.stackexchange.com/a/2839927/13130) *AND* [Example 4](https://math.stackexchange.com/a/2803045/13130) *AND* [Example 5](https://math.stackexchange.com/a/2796960/13130) *AND* [Example 6](https://math.stackexchange.com/a/96965/13130)). I've seen too much now for this to still be the case!
Comment: *a topology is the minimum amount of structural information about a space that is used in mathematics to decide whether a function is continuous* --- Continuity can be defined for much more general "topological-like" spaces than topological spaces. In fact, one can define continuity for functions from $X$ to $Y,$ where the closure operator on each of these sets is an *arbitrary mapping* from the power set of that set to the power set of that set. See the bottom of p. 3 of [this manuscript](https://www.bioinf.uni-leipzig.de/~studla/Publications/PREPRINTS/01-pfs-007-subl2.pdf).
Comment: Lol, I had originally written that sentence with a hedge --- "generally used" instead of just "used" --- to hedge against this exact sort of thing! But I deleted the "generally" b/c I thought it made the sentence unwieldy. Perhaps I'll add it back.
Answer: Topology is an abstraction of nearness of two points which is used to define limits. whereupon one may define limits of sequences and continuity of functions. In metric spaces the distance function measures neatness. Within topological spaces, descending nests open sets are used.
However there is more to topology than continuous functions such as connected and disconnected spaces, bounded or unbounded spaces, topologically equal spaces. $[0,1]$ and $[0,2]$ are homeomorphic, ie topologically equal. Within metric spaces a space is bounded if its diameter is finite. Within topological spaces a space is bounded if it is compact.
Comment: As continuity @ZiadH.Muhammad, is based upon f(x) getting near to f(a) as x gets near to a, nearness is defined first. Adherence points are an example of being very near.
Comment: Manual line breaks look quite bad on most screens. I edited to remove them.
Comment: Makes sense to me, but weren't defining continuous functions for sets the main motive for defining topologies? like imagine if we are in some pre-topological mathematical era, I think *topologies* would come up naturally from trying to define continuous functions between sets right?


Using "ellipse" as gradient for IE-9

Question: I've created radial-gradient
background: radial-gradient(ellipse at center, #595959 0%, #000000 40%);

And as far as I know, this should help me to make it cross-browser
background: -webkit-radial-gradient(ellipse at center, #595959 0%, #000000 40%);
background: -moz-radial-gradient(ellipse at center, #595959 0%, #000000 40%);
background: -ms-radial-gradient(ellipse at center, #595959 0%, #000000 40%);
background: -o-radial-gradient(ellipse at center, #595959 0%, #000000 40%);
background: radial-gradient(ellipse at center, #595959 0%, #000000 40%);

However this isn't support IE-9 and after some searching, I found this:
Create a radial gradient for Internet Explorer 6/7/8 but this doesn't seem to work anymore. And well, I'm curious how to make my gradient work in IE-9. Thanks
Answer: I think I have bad news for you.
IE9 dropped support for the old IE-specific filter styles -- ie the ones that you pointed out in the other question you linked to.
The intention was that IE9 was supposed to be properly standards compliant, and those filter styles were non standard so they were dropped. At the same time, the idea was all the functionality provided by those styles was being replaced by standards-based CSS features.
Unfortunately, as you're finding, not quite all of the functionality was replaced with standard CSS in IE9. In particular, CSS gradients were a noticeable omission and have caused a lot of code to be written using awkward work-arounds.
The bottom line is that IE9 specifically has a particular blind-spot in this area, where newer IE versions and even the older ones do support this feature one way or another.
Your only real ray of light is that IE9 usage has dropped through the floor recently; hardly anyone is still using it. So my advice is that you can probably get away with having a fall-back solution that just uses a plain background colour; let IE9 have that and concentrate on the newer browsers that people do actually use.
Comment: Thank you for explaining this to me. BTW: In IE EDGE I have(ver. 11.0.9600.18283) when I use emulator in developer tools and emulate IE-9 this is working. Perhaps it's because of the older version.

Using "ellipse" as gradient for IE-9


I need to test the ballpark connection latency between two states - Any sites or easy ways to do this?

Question: I am in Kansas I need to test latency to Oregon. Assuming I don't know anyone in Oregeon or know what hosts are pingable and also in oregeon is there any handy tool for this?
It would be even better if I could select to arbitrary locations and get average latency times on the wire between hosts located in two geopolitcally seperated locations.
Comment: You know that the only thing ping really tests is whether or not ping works, right?
Comment: What exactly are "geopolitcally seperated locations"?
Answer: Physical locations don't correlate cleanly with network locations.  One carrier might take you from Oregon to Kansas via a single POP on each side and a dedicated circuit that happens to physically run directly between the two sites while another carrier might hand off to an intermediary transit provider that backhauls the traffic to Virginia to hand off to a carrier that routes through Texas to go back up to Kansas.  Best of all, either path could be valid at a given time depending on fault and traffic conditions.
Answer: You can test basic latency with ping, smokeping, iperf, et cetera.
If you don't know what the endpoint you're testing for is, then there's not much point in testing something else entirely. Your traffic could go through a completely different network somewhere and have wildly different results.


Continuous Time Markov Chains

Question: What are some techniques to convert Continuous Time Markov Processes into Discrete time Markov Processes? (for purposes of simulations)
Answer: Fix $h>0$ and consider $\xi_n=X_{nh}$ for every integer $n\ge0$. If $(X_t)$ is a Markov process with Q-matrix $Q$, then $(\xi_n)$ is a Markov chain with transition matrix $P=\mathrm{e}^{hQ}$. If $h$ is small one can hope to get some information on $(X_t)$ from the study of $(\xi_n)$.

Continuous Time Markov Chains


passagem por referência de struct não funciona (Fila dinâmica C)

Question: Estou tentando implementar uma Fila dinâmica. Quando eu inicializo o programa (inicio e fim = NULL), e em seguida coloco para enfileirar um valor(função enfileirar) o ponteiro "fim" recebe o novo item da fila, porém o "inicio" não, sendo que na função eu estou pedindo para o "inicio" e o "fim" receberem o novo item da fila.
Segue o código para teste:
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

struct no {
    int dado;
    struct no *prox;
};

void enfileirar(struct no **inicio, struct no *fim, int valor) {
    struct no *novoNo;

    novoNo = (struct no *) malloc(sizeof(struct no));

    novoNo->dado = valor;
    novoNo->prox = NULL;

    if (*inicio == NULL) {
        *inicio = novoNo;
    } else {
        *fim->prox = *novoNo;
    }

    *fim = *novoNo;
}

void mostrarFila(struct no **inicio) {
    struct no *aux;
    aux = inicio;

    printf("Inicio da fila -> \n");
    while(aux == NULL) {
        printf("%d\n", &aux->dado);
        printf("\n");
        aux = aux->prox;
    }
    printf("<- Fim da fila \n");
}

int main(int argc, char** argv) {
    struct no *inicio, *fim;
    int resposta, valor;
    bool sair = true;

    while(sair) {
        printf("\n");
        printf("************** MENU **************\n");
        printf("0 - Sair do programa\n");
        printf("1 - Iniciar Fila\n");
        printf("2 - Enfileirar\n");
        printf("3 - Mostrar fila\n");
        printf("**********************************\n");

        scanf("%d", &resposta);

        switch(resposta) {
            case 0:
                sair = false;
                printf("Saindo do programa...\n");
                break;
            case 1:
                inicio = NULL;
                fim = NULL;
                break;
            case 2:
                printf("digite o valor para inserir na fila:\n");
                scanf("%d", &valor);
                enfileirar(&inicio, &fim, valor);
                printf("%d\n", &inicio->dado);
                printf("%d\n", &fim->dado);
                break;
            case 3:
                mostrarFila(&inicio);
                break;
            default:
                sair = false;
                printf("Saindo do programa...\n");
                break;
        }
    }

    return 0;
}

Answer: São vários problemas no código.

Na função enfileirar() o parâmetro fim deve ser um ponteiro para ponteiro:
void enfileirar(struct no **inicio, struct no **fim, int valor) {
E isso obriga a colocar o ponteiro fim entre parênteses na atribuição:
(*fim)->prox = novoNo;
Na função mostrarFila() não há necessidade passar ponteiro para ponteiro já que não haverá alteração na lista
void mostrarFila(struct no *inicio) {
E atribuição para aux é simples:
aux = inicio;
O teste estava errado:
while(aux != NULL) {
E você quer imprimir o dado e não o endereço dele:
printf("%d\n", aux->dado);
Mesma coisa na função main()
printf("%d\n", inicio->dado);
printf("%d\n", fim->dado);
E chamada para mostrarFila() muda para:
mostrarFila(inicio);

Vários destes problemas foram detectados como warnings na compilação.
Comment: Obrigado resolveu meu problema =) Me falta estudo ainda...


Understanding "table margins"

Question: I'm working on a statistics quiz and asked the following:

What tables (with the same margins) would constitute stronger evidence of a gender bias effect in the calculation of the p-value using Fisher's exact test?

Using R I've calculated Fishers exact test with following results:
<code>fisher.test(table, alternative="greater")

#    Fisher's Exact Test for Count Data
#
# data:  table
# p-value = 0.2596
# alternative hypothesis: true odds ratio is greater than 1
# 95 percent confidence interval:
#  0.4173146       Inf
# sample estimates:
# odds ratio
#   2.838407
</code>
I'm unsure how to answer the question. What does "same margins" mean in this context? The closest I've found is this comment in relation to "margin totals" from Wikipedia's article on Fisher's exact test:

In this sense, the test is exact only for the conditional distribution and not the original table where the margin totals may change from experiment to experiment.
Comment: Please add the `[self-study]` tag & read its
[wiki](https://stats.stackexchange.com/tags/self-study/info).
Answer: The "margins" means the numbers along the right side and bottom of the table that indicate the sum of the elements in that row or column. You're being asked: "what kind of tables would indicate stronger evidence of gender bias given the restriction that there must be: 8 people promoted, 12 people not promoted, 12 males, and 8 females?"
For example, if the table looked like:
<code>         Promoted      Not
Male     8             4
Female   0             8
</code>
We can see clear evidence of gender bias in who gets promoted or not. So you're being asked to characterize all such tables that look "worse" in terms of gender bias.
Comment: +1, but please be cautious about providing complete answers to homework type questions, our policy is to engage & give hints (see the `[self-study]` tag's
[wiki](https://stats.stackexchange.com/tags/self-study/info)).

Understanding "table margins"


display a redmine wiki in another redmine wiki page

Question: Is there a way to display the content of a redmine wiki page in another page ?
I wish to write a unique page and display its content in different articles, instead of writing the article twice or just putting a link to the other wiki page.
Answer: Looks like it's already supported,
From http://www.redmine.org/projects/redmine/wiki/RedmineTextFormatting,
<code>include

    Include a wiki page. Example:

    !{{include(Foo)}}

    or to include a page of a specific project wiki:

    !{{include(projectname:Foo)}}
</code>
Comment: thanks, I didn't think it could have been in the "macro" section...which was pretty much where I stopped reading the documentation :S
Answer: In my case following code works:
<code>{{include(Foo_article_name)}}
</code>
(without !exclamation mark at the begin).


How should I construct a subclass using an instance of the superclass?

Question: Let's say I have the following code
public class SuperClass {
    protected int super_class_value;

    public SuperClass (int value) {
        this.super_class_value = value;
    }
}

public class Subclass extends SuperClass {
    protected int subclass_value;

    public SubClass(int super_class_value, int subclass_value) {
        super(super_class_value);
        this.subclass_value = subclass_value;
    }
}

However, now I want to be able to pass a SuperClass object into the SubClass constructor. How would I do that?
public SubClass(SuperClass super_class, int subclass_value) {
    //What do I do here?
    this.subclass_value = subclass_value;
}

Basically, I'd like to do something like this...
public SubClass(SuperClass super_calss, int subclass_value) {
    super(super_class.super_class_value);
    this.subclass_value = subclass_value;
}

But if SuperClass is more complex, I don't want to add each value to the super() call. Instead, I'd like to simply pass in an object that already exists, and use it as the super class.
I want to do this...
public SubClass(SuperClass super_class, int subclass_value) {
    super(super_class);
    this.subclass_value = subclass_value;
}

But I'm not sure if that's allowed?

Seems as though I can do the above, if I add a constructor to the SuperClass definition.  But what would that look like?
public class SuperClass {
    protected int super_class_value;

    public SuperClass (int value) {
        this.super_class_value = value;
    }

    public SuperClass (SuperClass super_class_object) {
        //What is done here?
    }
}

Comment: Currently your code looks fine... What exactly do you want to do with the `super_class` reference??
Comment: can you not pass it in subclass like you did `super(super_class_value);`?
Comment: Why do you want to pass the super class object?
Comment: Are you asking how you would pass in the `int` to the super call when you only have an instance of the `SuperClass` instead of being passed an `int` for the super class?
Comment: In reply to your current update, _I'd like to simply pass in an object that already exists, and use it as the super class._ well that is not really possible.  What you _could_ do is make a constructor in your super class that makes a copy of itself using the passed in reference.
Answer: Don't you just want to have a copy constructor for your Superclass?
public class SuperClass {
    protected int super_class_value;

    public SuperClass (int value) {
        this.super_class_value = value;
    }
    protected SuperClass (SuperClass super_class) {
        this.super_class_value = super_class.supper_class_value;
    }
}

public class Subclass extends SuperClass {
    protected int subclass_value;

    public SubClass(SuperClass super_class, int subclass_value) {
        super(super_class);
        this.subclass_value = subclass_value;
    }
}

See also a question here on SO about writing copy ctors:
Does Java have a default copy constructor (like in C++)?
Comment: @Tester101: Ah, but you aren't! At least, not in SubClass. SubClass just passes super_class along. As for SuperClass itself, if its construction is complicated, you might use [constructor chaining](http://stackoverflow.com/questions/17171012/how-to-avoid-constructor-code-redundancy-in-java).
Comment: Yes, but super_class might be fairly complex, and I don't want to copy over every value manually.
Answer:
However, now I want to be able to pass a SuperClass object into the
  SubClass constructor. How would I do that?

You are perfectly doing the same
public SubClass(SuperClass super_class, int subclass_value) {
    //What do I do here?
    // Do Whatever you want to do here ,
    this.subclass_value = subclas_value;
}

Now i think you might be thinking of how to pass Object to SuperClass from subclass then this can be done by super keyword in Java

super() is used to invoke immediate parent class constructor.

Now for passing the Object to SuperClass , in your Subclass's constructor you very first line must be
super(super_class);

Now In your super class you must have a constructor which takes Object of itself otherwise the above line will throw compile time error
public SuperClass (SuperClass object) {
         // Do whatever you want to do .
          this.anyInstanceVariable=object.thatInstanceVariable;
    }

P.S. : I still don't understand what did you want to achieve with this , but this is the way you'll achieve it whatever you have mentioned

Update
As you said in comments you don't want to copy each single variable then you can use clone method of Object class
Here is an example how you will achieve it in your case
class SuperClass implements Cloneable{ // otherwise clone() method will throw CloneNotSupportedException

    int a;
    SuperClass obj=null; // this will point to the copy of the cloned object

    SuperClass(int a){// just to test that cloning is successfull
        this.a=a;
    }
    SuperClass(SuperClass a){
        try{
        this.obj=(SuperClass)a.clone();
        }
        catch(Exception e){
            e.printStackTrace();
        }
        display();
    }
    public void display(){// to Verify that Cloning has been done successfully
        try{
        System.out.println("Hello from cloned Object "+obj.a);
        }
        catch(Exception e){
            e.printStackTrace();
        }
    }
    @Override
    protected Object clone() throws CloneNotSupportedException  { // Overridden Method
        return super.clone();
    }
}

Check out this nice Article about Object cloning in java
Comment: What would the body of the constructor in SuperClass look like?  Where "*// Do whatever you want to do .*" is, what goes there?
Comment: There you can write any valid java statement , but i think the task you want to perform there is copy constructor's work
Comment: Let's say SuperClass is more complex, and I don't want to copy over each variable. Is there a way to simply "copy" the whole object?
Comment: I think you want to create a clone of object
Comment: @Tester101 , Check out the updated part Hope it will help you and might be this is what you wanted
Answer: You could add getter methods inside of SuperClass and use them in the SubClass constructor.
public class SuperClass {
    protected int super_class_value;

    public SuperClass (int value) {
        this.super_class_value = value;
    }

    public int getSuperClassValue(){ return super_class_value;}
}

public class Subclass extends SuperClass {
    protected int subclass_value;

    public SubClass(SuperClass super_class, int subclass_value) {
        super(super_class.getSuperClassValue());
        this.subclass_value = subclass_value;
    }
}

Comment: You're going to have to set the data somewhere, whether inside of SuperClass by adding an additional constructor to SuperClass or in SubClass by something similar to what I wrote here.
Comment: I want to avoid this, as the super_class might be very complex
Answer: Check out the Decorator Pattern for a well-known example of this.  The page includes a good java example with UML diagram too.
Answer: public class SuperClass {
    protected int super_class_value;

    public SuperClass (int value) {
        this.super_class_value = value;
    }

    Object obj = new Object();
}

public class Subclass extends SuperClass {
    protected int subclass_value;

    private SuperClass superCl = new SuperClass();

    public SubClass(int super_class_value, Object obj2 ,int subclass_value) {
        super(super_class_value);
        obj2 = superCl.obj;
        this.subclass_value = subclass_value;
    }
}


If the curse of dimensionality exists, how does embedding search work?

Question: The curse of dimensionality tells us if the dimension is high, the distance metric will stop working, i.e., everyone will be close to everyone.
However, many machine learning retrieval systems rely on calculating embeddings and retrieve similar data points based on the embeddings. These embedding dimensions can be 512, 1024 or 2048, which is very high.
My question is: If the curse of dimensionality exists, how does embedding search work?
Comment: I think everyone will be far from (not close to) everyone in high dimensions.
Comment: Are you asking what results allow us to use low-dimensional embeddings and compute similarity between these embeddings *instead* of working with high-dimensional data? Or are you asking how searching/computing similarity between low dimensional embeddings works, given that the "low-dimensional" embeddings still have high dimensionality e.g. 512, 1024, 2048?
Comment: Quote: The common theme of these problems is that when the dimensionality increases, the volume of the space increases so fast that the available data become sparse. in high dimensional data, however, all objects appear to be sparse and dissimilar in many ways, which prevents common data organization strategies from being efficient. ~ [Wikepedia](https://en.wikipedia.org/wiki/Curse_of_dimensionality).    What do you mean by everyone will be close to everyone?
Comment: @RichardHardy I think what the OP means originate from this article: [A Few Useful Things to Know About Machine Learning](https://homes.cs.washington.edu/~pedrod/papers/cacm12.pdf#page=5), and I also raised [a question](https://stats.stackexchange.com/q/558567/103153) on this topic.
Answer: The origion of vector space model is as follows:

The idea that the meaning of a word might be modeled as a point in a multi-
dimensional semantic space came from psychologists like Charles E. Osgood, who had been studying how people responded to the meaning of words by assigning val- ues along scales like happy/sad or hard/soft. Osgood et al. (1957) proposed that the meaning of a word in general could be modeled as a point in a multidimensional Euclidean space, and that the similarity of meaning between two words could be modeled as the distance between these points in the space.

For the question

how does embedding search work

There are two methods: 1) you have embedding A and you compute the cosine distances between A and all the embeddings in a corpus and you rank the embeddings by the distances to find the nearest embeddings; or 2) you try the approximate nearest neighbor searching using FAISS or ScaNN.
Why consine? Because it is the normalized dot product since dot product favors long vectors.
Embedding is the result of one of the two vector semantic models: sparse vector models and dense vector models. Embeddings are obtained from dense vector models, and the sparse vector models include word-context and term-term matrix. We can also utilize distances between sparse vectors to measure semantic similarities/associations.
Reference:
Speech and Language Processing: An introduction to natural language processing
Comment: This doesn't seem to anwer the question, which is about how the curse of dimensionality affects embeddings
Comment: @user20160 It reminds me of [this answer](https://ai.stackexchange.com/a/28567/5351), and I will update mine.
Answer: I think this question has not been answered sufficiently despite being a good question.
The curse of dimensionality essentially says that random 3 vectors in sufficiently high dimensional space have roughly the same distance to each other with regards to euclidean distance. This is true, also in the case of dim = 512.
However, in vector search for embeddings are key differences:

The vectors are not random: We are embedding text and questions. Our goal is to measure if they are related, if yes how they are related.
We are not working with euclidean distance and usually normalised vectors, i.e.

$dist_{euchlidean} = d(\mathbf{p}, \mathbf{q}) = \sqrt{\sum_{i=1}^{n}
   (p_i - q_i)^2}$
$dist_{cosine}=d(\mathbf{a}, \mathbf{b}) = 1 - \frac{\mathbf{a} \cdot
   \mathbf{b}}{\|\mathbf{a}\| \|\mathbf{b}\|} = \mathbf{a} \cdot
   \mathbf{b}$
, note that the cosine distance is a number between -1 and 1.

The cosine distance is measures the cosine angle between two vectors. It is a vastly different concept than the euclidean distance which will measure the length of a vector between those two. While the length of vector will increase with an increased dimension it is not the case for the cosine. Therefore the curse of dimensionality finds no application here.
Comment: I agree with your first point:  if the data we have is actually contained in a smaller dimensional submanifold then we have some hope for avoiding the curse.  I disagree with your second point: cosine similarity is basically just projecting all of your data onto a sphere.  A large dimensional sphere has the same curse as a large dimensional Euclidean space.


Percorrer um array bash script

Question: Alguém pode me dar um exemplo de um if e case percorrendo um array em bash script? eu só estou achando exemplo com for que é pra listar os itens..
estou tentando assim porem não da certo
ex:
v1=("sim" "s" "y" "yes" "")
v2=("não" "no" "nao")

read -p "Digite sua opção [S] [n]" RESP

case $RESP in
$V1)
echo "Opção sim"
;;
$V2)
echo "Opção não"
;;
*)
echo "Não conheço"
;;
esca

Answer: Você não precisa de malabarismos com arrays, a sintaxe de case/esac permite que você teste uma lista de valores separados por |, veja só:
#!/bin/bash

read -p "Digite sua opção [S/N]: " RESP

case ${RESP,,} in

    "sim"|"s"|"y"|"yes"|"")
        echo "Opção sim"
    ;;

    "não"|"n"|"nao"|"no")
        echo "Opção não"
    ;;

    *)
        echo "Não conheço"
    ;;

esac

Porém, se o uso das arrays for um pré-requisito obrigatório, existe uma solução usando os condicionais if/elif/else/fi com o operador =~, que verifica se um valor específico está contido dentro de uma array:
#!/bin/bash

v1=("sim" "s" "y" "yes" "")
v2=("não" "no" "nao" "n")

read -p "Digite sua opção [S/N]: " RESP

if [[ "${v1[@]}" =~ "${RESP,,}" ]]; then
    echo "Opção sim"
elif [[ "${v2[@]}" =~ "${RESP,,}" ]]; then
    echo "Opção não"
else
    echo "Não conheço"
fi

Repare que ${RESP,,} faz com que todas as letras contidas na variável $RESP sejam lidas em letras mínúsculas (lowercase), tornando indiferente se o que foi digitato pelo usuário foi em caixa baixa (lowercase) ou em caixa alta (uppercase).
Comment: Cara não poderia ter uma resposta mais completa que a sua, principalmente a dica do ${RESP,,} que eu não sabia haha, muito obrigado!!!

Percorrer um array bash script


Why is the 7th of e.g. GMAJ7 an octave darker than scale degree 3 and 5?

Question: The chord shape for Major 7 is this(photo only meant to show the shape)
Why is the 7th[F#] the second darkest pitch, and not played on the 2nd fret of the 1st string, where it actually would be in a pitch "order" according to the scale?
Comment: [You might be interested in this question and answers](https://music.stackexchange.com/questions/67762/how-can-i-learn-about-reasons-for-choosing-different-ways-to-play-a-chord)
Answer: You've actually shown F#maj7 - G is one fret higher. It can be, and often is - 4/5 3/4 2/3 1/2 (str/fret). And sounds good there, except the root, on 4th string, is quite high.
There is no reason at all for playing the notes in rising order rather than mixed up, although the voicing, particularly on guitar, sound not so good with an extra G right next to the maj7 (F#).
You could experiment with other voicings - as long as the root, third and maj 7th are in there, you don't even need the 5th, although it can go in, if fingers on frets/strings will allow. You'll find some (of several round there) will sound better than others. That seems to be Justin's way of preference - or possibly preference for students.
Scale degree 3>5 is a m3, 1>3 M3, and 5>7 a M3 also. 'Sounding darker' could be because of the mix, although playing just the top 3 note (B D F#) produces a B min chord - supposedly dark in its own right.
Comment: The diagram was meant to show the chord shape, sorry, should have wrote that. So what you are saying is that as long as you follow 1-3-5-7 of the root notes scale, you don't have to care what particular pitch any of them are in? Not even the root?
Comment: Root usually sounds best underneath, but if there's another instrument playing that (piano, or bass) then that's not an issue. Just don't voice with G and F# only one fret (musically) apart. Having answered, I'm not certain what you really mean in the header.
Comment: So a Cmaj7 on the piano(1 is C, 3 is E, 5 is G, and 7 is B) would  C1, E2, G2 and B3 would be acceptable? Notice the number before the note refers to scale degree, and the number after the note the piano pitch notation.
Comment: 'Acceptable' in what way? Please don't go the way so many here do, and think the 'rules' must be followed! You try it, listen, and decide. I quite like it, although that low on a piano sounds quite muddy. Try it up a couple of octaves!
Comment: Good point. I guess I was after a clear answer on wether scale degree, should represent note pitch. I guess you have already answered on that, and so you play notes in the pitch order that sounds best. The chord voicing represented in my post is in that shape, cause it sounds better than if the F# would be higher in pitch than the notes except the root in that scale.
Comment: There's often a problem with guitar chords, in that all it's sometimes impossible/impractical to play all the strings or indeed all the notes in a chord. Especially with more complex chords with 4,5 or 6 notes. Something has to be sacrificed, but it still must sound good.
Comment: I'm not sure this has actually answered the question posed.
Answer: This is easier to explain in notation.   All of these are a Gmaj7 chord, in different inversions and different voicings.   There are lots of other possibilities too, particularly if we include 5 and 6-note versions.
The particular voicing you showed us has the F# low in the chord.   Like the second and third of my examples.  Several other voicings are possible on guitar, though not as many as are available to a keyboard player with his 10 fingers and two hands!  Even more are available to an orchestral composer or sequencer.
So, the notes of a chord don't HAVE to stack up in close order, and very often they don't.   On guitar the mechanics of the instrument restrict your choices somewhat, but there are still several 'shapes' for Gmaj7, up and down the fretboard.
Comment: Are you aware of that  tab - it's for F#maj7. That's why there's F# low in the chord!
Comment: @Tim Chord charts like this are often not mean to be shown in open position but moveable and with a labeling for the fret position (unless the nut is specifically shown as a thicker line). There's no label here, but from the context it's obvious they meant it to be a GMaj7 which would have the F# on the 4th string below the 3rd and 5th degrees as described.
Comment: @laurence shouldn't the F have sharp signs in all the bars?
Comment: @miniHessel - no. One F# is sufficient to show all Fs are sharp.
Comment: @user37496 - I know that! I'm asking if Laurence does!!!
Comment: Isn't that wrong according to notation rules? I mean at a new bar, the accidentals of a previous bar does not count?
Comment: @miniHessel -- that is true of accidentals, but here the F♯ is not an accidental, but part of the key signature.
Comment: Sorry, I must've been having a seizure.... of course.
Answer: Many chords can be played on the guitar with a variety of voicings and fingerings.  In many cases, some voicings and fingerings will work much better than others, either depending upon the surrounding context or the dexterity of the player.
Seventh chords are usually followed by a chord which has a note at the same pitch as the seventh, or a half step down or up (dominant and minor sevenths more often resolve down; major sevenths resolve up).  Resolutions are most satisfying if the note to which the seventh resolves is in the same octave, and so the forms of seventh chord where the seventh is in a middle octave can be good if the following chord has a note in the right place.  Many chord charts, however, simply pick chords based upon what most people would find generally find easiest to finger (without any consideration for surrounding context), and yours may might be intended to fall into that category.
If you would be capable of playing the chord as 2-x-x-3-2-1 or 2-x-3-3-2-1 those would be fine ways of playing it (for F#maj7; shift up or down as needed for other root pitches), but I think many people would have trouble fingering that.  Fingering it as 2-x-4-3-2-1 would be even better, but would probably require reaching the index finger across at a weird angle to fret the outer two strings.
If a performer can't finger a chord cleanly, it's likely to sound bad even if it should contain the ideal combination of notes.  A chord which contains a less-than-ideal combination of notes, fingered cleanly, will generally sound better than a chord with a superior combination of notes, fingered poorly.  For that reason, many tab sheets deliberately use less-than-ideal combinations of notes, and are not intended to discourage players who can do better from doing so.


AWS CDK give permission to resources outside the stack

Question: I am fairly new to AWS CDK and haven't had a lot of experience with AWS. In my CDK stack that I am writing, I have to give permissions to resources that are built with other CDK templates and are already in aws.
Lets say, my stack A contains a lambda, the lambda will be invoked from another service X. The service X needs to have invoke permission of lambda. Can I give the service X permission from the Stack A code or will I need to modify the service X stack?
Answer: In general, the answer is yes, you can add permissions to resources created outside the stack. But, You need to make sure the resource is importable.
Lambda usage:
add a policy to lambda role:
More info here.
const importedLambda = lambda.Function.fromFunctionArn(scope,`${name}-lambda`,${LAMBDA_ARN});

importedLambda.addToRolePolicy(new iam.PolicyStatement({
  effect: iam.Effect.ALLOW,   // ... and so on defining the policy
}));

add permission to lambda:
More info here.
const importedLambda = lambda.Function.fromFunctionArn(scope,`${name}-lambda`,${LAMBDA_ARN});

importedLambda.addPermission('allowInvocation',{
  principal: new ServicePrincipal('events.amazonaws.com'), // ... and so on defining the permission
 sourceArn: ...
});

Answer: You don't have to modify service X Stack.
The examples below assume you are using typescript.
If you want to allow the whole service (not recommended) invoke permission on your lambda you can use following:
For S3
yourfunction.grantInvoke(new ServicePrincipal('s3.amazonaws.com'));

For SNS
yourfunction.grantInvoke(new ServicePrincipal('sns.amazonaws.com'));

But I would recommend specifying the specific resource ARN that you want to allow to invoke your lambda. For example if its another lambda function you can specify its Role ARN like following:
yourfunction.grantInvoke(new ArnPrincipal('arn:aws:iam:region:account-id:role/role-name'));

And as Amit mentioned in his answer you can also use addPermission if you want to specify more granular permissions. You can use addPermission to even allow resources in other AWS accounts to invoke your lambda.
Answer: This issue is such annoying. Finally i got it work. Hopefully it can help someone later.
To add permission to an imported lambda function, you have to use fromFunctionAttributes() and sameEnvironment flag
const imported_lambda = lambda.Function.fromFunctionAttributes(this, 'Function', {
  functionArn: 'xxxxxxxxxxxxxxxxx',
  sameEnvironment: true
})

Comment: Thank you, this helped me a lot! Spent ages trying to figure out why the `add_permissions` CDK call had no effect whatsoever.
Comment: This no longer works
Answer: You can use "cdk bootstrap" to track the aws key permission can meet the cdk requirement.
cdk bootstrap
 ⏳  Bootstrapping environment aws://999999999999/us-west-2...
 ✅  Environment aws://999999999999/us-west-2 bootstrapped (no changes).

Above is fine prinout.
I read the guide from https://cdkworkshop.com/20-typescript/20-create-project/500-deploy.html
Comment: This just does not seem on topic


Is $f(x)=(x_1 x_2, x_1^2+x_2^2) $ well-conditioned?

Question: Is $f(x)=(x_1 x_2, x_1^2+x_2^2) $ well-conditioned $\forall x$ (use $|| \ ||_\infty$ to calculate Condition number) ?
$$f'(x)=\begin{pmatrix} x_2 \ \ x_1 \\ 2x_1 \ \ 2x_2 \end{pmatrix}$$
$$||f'(x) ||_\infty=\max(\lvert x_2 \lvert+ \lvert x_1 \lvert, \lvert 2x_1 \lvert+\lvert 2 x_2 \lvert)= \lvert 2x_1 \lvert+\lvert 2 x_2 \lvert$$

$$|| x ||_\infty=\max(\lvert x_1 \lvert , \lvert x_2 \lvert)$$

$$|| f ||_\infty=\max(\lvert x_1 x_2 \lvert ,  x_1^2+x_2^2 )$$

$$K(f,x)=\frac{2(\lvert x_1 \lvert+\lvert  x_2 \lvert) \max(\lvert x_1 \lvert , \lvert x_2 \lvert)}{\max(\lvert x_1 x_2 \lvert ,  x_1^2+x_2^2 )}$$

I consider: $x_{max}=\max(\lvert x_1 \lvert , \lvert x_2 \lvert)$ and $x_{min}=\min(\lvert x_1 \lvert , \lvert x_2 \lvert)$

$$K(f,x) \le \frac{2(\lvert x_{min} \lvert +\lvert x_{max} \lvert) \lvert x_{max}\lvert}{\lvert x_{max} \lvert^2} = \frac{2(\lvert x_{min} \lvert+\lvert x_{max} \lvert)}{\lvert x_{max} \lvert} $$

$$\lim_{\lvert x_{max} \lvert \rightarrow +\infty} \frac{2(\lvert x_{min} \lvert+\lvert x_{max} \lvert)}{\lvert x_{max} \lvert}=2 $$

$f$ is well-conditioned for $(x_1,x_2) \ne (0,0)$

Is it correct?

Thanks!
Comment: I think for your first step, you need $|x_{min}|^2$ in the denominator
Answer: The function is symmetric with respect to $x_1$ and $x_2$, so wlog assume $|x_1| \geq |x_2| \neq 0$. Then
\begin{align}
K(f,x)
&=
\frac{2(|x_1|+|x_2|)\max(|x_1|,|x_2|)}{\max(|x_1||x_2|,x_1^2+x_2^2)}\\
&=
\frac{2(|x_1|+|x_2|)|x_1|}{x_1^2+x_2^2}\\
&\leq
\frac{4|x_1|^2}{x_1^2}\\
&=
4
\end{align}


How do i create nested tabs in drupal 7 view?

Question: I am trying to create an image gallery from view.
I have a content type called "Photo-Gallery" with fields  title of event,year,month and images
I have created a view with this content type and created page with Unformatted list.I am trying to make a gallery based on the following layout. How can i code custom view template?I want this by Year wise and then Month .
Unfortunately i am stuck on half way. Could you please suggest me a proper way to code the  view to get the exact result.

Awaiting quick replies.
Answer: You could use Quick Tabs Module along with Views Module to achieve this result.
A simple overview to achieve this might be:

Since Quicktabs uses blocks as tabs, If you create a views blocks for each
  single items of a content type and then add them to quick tabs
  manually.

Look through this http://mtt.desk.com/customer/portal/articles/992921-how-to-add-quick-tabs-with-multiple-view-blocks-inside-a-specific-page to get an idea.
Comment: I have created the blocks for each year and added them to the quick tabs.But the issue is, i need to add the quick tabs when in create a block for each year.Now i can add till 2015 and show the tabs.But next year if i add a node with year 2016 and month January , how could i show it automatically?


How to add 'font color' option to Buedit

Question: I have used other text editors but BUEdit is my text editor of choice: lightweight and robust.
However, what I lack in its buttons is a function to enable users to colorize (and hence beautify) their texts. I'd be grateful to know how to do so.
Answer: You can enrich Bueditor by adding buttons to it. You can find some very well written documentation about how to add buttons to the editor in the official bueditor page.
After you have learned how to create buttons, you can use one of the already implemented buttons for text color. You can find a demo and the actual button code here.
The steps that I followed in a clean Drupal 7 installation:

Installed Bueditor
Navigated to Configuration - Content Authoring - Bueditor
Selected a random editor (e.g. Default) and hit "Edit"
Copied the 2 files from the second link in the library folder inside
modules/bueditor
Added the following lines in "Editor specific library files":
%BUEDITOR/library/bue.style.js
%BUEDITOR/library/bue.colorbox.css
I went to the bottom of the page, above the "Save Configuration" button and in the blank button I added a title (i.e. Color), in the "Content" field I added the code from the second link (the code that is marked as: "Button code" (simple copy and paste)
In the place of the icon I just wrote: Color
Now just hit: "Save configuration" and go to the bottom of the page and check in the demo editor how it works.
Comment: Thanks for the hints.I read the docs but still not sure how to implement the codes. I put the bue.style.js in BUEDIT's new button content and the bue.colorbox.css in my themes's style.css. Now the button and its color palette appear in the editor but clicking on colors has not colorizing effect. Any ideas?
Comment: Did you check the demo in the second link that I mentioned? You do not actually see the colorizing effect in the editor, but the corresponding html tag is added (e.g. My text). When you add the color in your editor, does it add the html? Or it does not do anything?
Comment: Sorry, I wasn't clear. I mean, no tags has been added. Clicking on the palette just gets me to top of the page.
Comment: I'm editing my post above with the steps that I followed in order for it to work for me (tested it in a sample installation and work absolutely perfectly).