What type of songs frequently use chords that are a half step apart (like the E and F chords)?

Question: I have heard some songs where chords like "E" and "F" are often used (some times the progression is like, "Am, G, F and E").  The main song relays on these two chords(E and F).
For example, you might have watched the youtube video "worlds best guitar player unbelievable". I know some other songs but not their names... so I cant give any other examples.
I just wanna know the name of the type of the song. So I can Learn more about these type of songs.
Comment: The Am, G, F and E progression is an example of what is called The Andalusian Progression. It is one of the most (over?)used progressions in music and crops up in most genres since pre-baroque times to modern rock and pop music. Wikipedia has a big list of songs that use it - https://en.wikipedia.org/wiki/List_of_popular_music_songs_featuring_Andalusian_cadences
Comment: I'm not sure what you mean by minor second chords
Comment: Oh like "c and c#" , "e and f" (chords with one semi note higher)  (i dont know whether they are minor second chords, but i mean the chords like e and f; f and f# etc)
Comment: Since the iii and IV chords in major keys and the v/V and VII chords in minor keys are all popular, I'd say a large number of songs will have this.
Answer: I think you're referring to Flamenco music. Its characteristic scale is the harmonic minor scale, which in Flamenco is often used starting from the 5th note, i.e. its 5th mode is used. That scale is usually called phrygian dominant.
The notes of the phrygian dominant scale starting on E (i.e., A harmonic minor) are:
E F G# A B C D
Its main characteristics are the b2 (the note F), and the augmented second interval between the 2nd and the third note (from F to G#). The latter is the only difference with the phrygian scale, which has a major second between those two notes (i.e., a G instead of the G#).
The chords you probably refer to are the chords E and F (in E phrygian dominant), or Em and F (in E phrygian), where the tonic chord is the chord with root E.
There are many other relatively common scales with a b2, e.g. dorian b2, etc., but phrygian and phrygian dominant are the most common of those scales, especially in Flamenco.
Comment: OP is asking about chords one semitone apart, although using those scale notes one can formulate the appropriate chords.
Comment: @Tim: If I understood correctly he asks about the "type of songs", that's why I answered "Flamenco". And indeed, you can build a chord on each scale tone, so in phrygian dominant you'd get E and F, whereas in phrygian you get Em and F. I'll add that to my answer.
Answer: Matt is correct, this is characteristic of Flamenco music, assuming E is the root.
This question is pretty vague, but I interpret it as saying the song is in A minor and but stays on E and F for extended periods of time during the instrumental, I would associate it with 80's metal, specifically, Randy Rhoads. He popularized the use of harmonic minor in metal while playing for Ozzy. During live performances the band would stay on the V chord (in your example E), or E and F while he would tear it up in the Harmonic Minor scale and its associated arpeggios (most notably the diminished 7th arpeggio).
For those not familiar with this era of Ozzy I should point out he was not just playing over power chords, as Ozzy had an organ player in the live band. I haven't seen the YouTube video the O.P. talks about, but this would certainly be an area where the  "worlds best guitar player unbelievable" might want to show his stuff as is a signature move of one of the guitar pioneers.
Pick up Randy Rhoads Tribute by Ozzy Ozbourne and start from there.
If you want the CAGED patterns patterns of the Phrygian Dominant Scale starting on E (same as harmonic minor in A) I have them free on my website. I got some flack for posting links to my (btw free with no ads) website, so just type Phrygian Dominant into Google, my chart is in the knowledge box thing on the top of the page with the Wikipedia description.
Answer: I can think of three songs where the chord progresses down a semitone from the root:
Ain't no pleasing you by Chaz and Dave - at the beginning of each verse.
   You won't find another fool like me by The New Seekers - when the song title
   is sung.
   Use it Up Wear it Out by Odyssey - in the introduction of the song.
I think this gives each tune a sad tone at that point without even using a
   minor chord but also very unusual. I can't think of any other examples -
   difficult thing to search on Google!


java restrict switching of window/Jpanel

Question: I have JFrame with 3 JPanel(basically three tabs). one of the panel has a textbox. there is value restriction on textbox. it means, user can enter only 1-1000 number in it. If he enters number >1000, it throws the warning message.
Now I am using focuslistener to save the entered number as soon as it looses the focus. But if the user enters 1200 and click on another tab(panel), it gives me expected warning message but also goes to the another tab. I need to remain in same panel if there is warning box. I don't want to loose the focus from the current panel.
mMaxLabelLength = new JTextField();
mMaxLabelLength.addActionListener(this);

public void focusGained(FocusEvent fe)
{
    // do NOTHING
}

@Override
public void focusLost(FocusEvent fe)
{
    saveActions();
}

public void actionPerformed(ActionEvent e)
{
    //Do something
}

private void saveActions()
{
    // error message
    JOptionPane.showMessageDialog(this,
        "Please enter an integer value between 1 and 1000.",
        "Invalid Entry", JOptionPane.INFORMATION_MESSAGE);
    SwiftApplication APP = SwiftApplication.getInstance();
    int nMaxLabel = APP.getMaxPieLabel();
    mMaxLabelLength.setText(new Integer(nMaxLabel).toString());
    mMaxLabelLength.requestFocus();
}

Comment: Consider using a `JSpinner` with a [`SpinnerNumberModel`](https://docs.oracle.com/javase/8/docs/api/javax/swing/SpinnerNumberModel.html) instead.
Answer: Looks like you are looking for an InputVerifier.

Abstract class that allows input validation via the focus mechanism. When an attempt is made to shift the focus from a component containing an input verifier, the focus is not relinquished until the verifier is satisfied.

As the oracle page describes, it can be used to write own verifiers, which reject invalid inputs and keeps the focus meanwhile on the associated JComponent.
Therefore you just need to do two things:

Write your own InputVerifier, e.g. MyVerifier or take one of the already existing ones and create an instance of it. (See below for a small complete verifiable example)
Register your verifier instance on the target JComponent using calls to the Input Verification API.

This means, to register an...

InputVerifier call the setInputVerifier method of the JComponent class. For example, the InputVerificationDemo has the following code:

private MyVerifier verifier = new MyVerifier();
...
amountField.setInputVerifier(verifier);

Note For some reason I can't find a source for the java8 InputVerifier right now, it seems that the link is broken.
Small Verifiable Complete Example (from here)
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import javax.swing.*;

// This program demonstrates the use of the Swing InputVerifier class.
// It creates two text fields; the first of the text fields expects the
// string "pass" as input, and will allow focus to advance out of it
// only after that string is typed in by the user.

public class VerifierTest extends JFrame {
    public VerifierTest() {
        JTextField tf1 = new JTextField ("Type \"pass\" here");
        getContentPane().add (tf1, BorderLayout.NORTH);
        tf1.setInputVerifier(new PassVerifier());

        JTextField tf2 = new JTextField ("TextField2");
        getContentPane().add (tf2, BorderLayout.SOUTH);

        WindowListener l = new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        };
        addWindowListener(l);
    }

    class PassVerifier extends InputVerifier {
        public boolean verify(JComponent input) {
            JTextField tf = (JTextField) input;
            return "pass".equals(tf.getText());
        }
    }

    public static void main(String[] args) {
        Frame f = new VerifierTest();
        f.pack();
        f.setVisible(true);
    }
}

Comment: Looks like this problem is already known as a bug [here](https://bugs.openjdk.java.net/browse/JDK-4403182) and [here](http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4403182). Furthermore there is a possible explanation concerning portability [here](http://stackoverflow.com/a/10542569/3165552). However, i couldn't find a real solution, but here seems to be [some workaround](http://www.java-forums.org/advanced-java/47355-creating-selective-inputverifier.html) using [this](https://docs.oracle.com/javase/7/docs/api/javax/swing/JComponent.html#setVerifyInputWhenFocusTarget(boolean)) method.
Comment: How would I use the InputVerifier  with addFocusListener. I tried "mMaxLabelLength.addFocusListener(this);
  mMaxLabelLength.setInputVerifier(new PassVerifier());
" but that didn't help
Comment: The combination of both may arise some conflicts, see [this answer](http://stackoverflow.com/a/26433840/3165552) which combines both of them. An important addition is the `shouldYieldFocus` method in the `MyInputVerifier` subclass. However, both instances either use the focus or the verify approach. I'll guess the order of installing the listeners may have an effect as well, but i am not quite sure about this.
Comment: I understand this would allow me to restrict typing or selecting something in same panel, but I have multiple panels in a JFrame as tab. and it wouldn't stop me selecting another tab( even if the value is wrong)
Answer: The code block in the question does not offer too many details, but as far as I understand it, you need to use a VetoableChangeListener to prohibit focus change.
Here an example from Java2s:
import java.awt.Component;
import java.awt.KeyboardFocusManager;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;

public class Main {
  public static void main(String[] argv) {
    KeyboardFocusManager.getCurrentKeyboardFocusManager().addVetoableChangeListener(
        new FocusVetoableChangeListener());
  }
}

class FocusVetoableChangeListener implements VetoableChangeListener {
  public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
    Component oldComp = (Component) evt.getOldValue();
    Component newComp = (Component) evt.getNewValue();

    if ("focusOwner".equals(evt.getPropertyName())) {
      if (oldComp == null) {
        System.out.println(newComp.getName());
      } else {
        System.out.println(oldComp.getName());
      }
    } else if ("focusedWindow".equals(evt.getPropertyName())) {
      if (oldComp == null) {
        System.out.println(newComp.getName());
      } else {
        System.out.println(oldComp.getName());
      }
    }

    boolean vetoFocusChange = false;
    if (vetoFocusChange) {
      throw new PropertyVetoException("message", evt);
    }
  }
}

But, the more I think about it, maybe using InputVerifier and public boolean shouldYieldFocus(JComponent input) is more appropriate. See "Validating Input" in the "How to Use the Focus Subsystem" of the Java Tutorial.
Comment: Well, @isi was faster :-)
Comment: Usually this happens to me.


What does "NC" mean?

Question: On some tabs, I sometimes see a "NC" text on top of the tab.
What does it mean ?
How should it be played or interpreted ?
Answer: NC (or N.C.) is short for "No Chord".
It means that you should only play the indicated notes or melody, and not try to infer or add a chordal accompaniment. This is as opposed to the chord symbols that you probably find everywhere else than where the N.C. notation is.
See for example
http://dictionary.onmusic.org/terms/2344-no_chord
(Although their example doesn't use tabs.)
Comment: I guess that when it's written NC, it means that you can't determine the chord of that section or it's not relevant for that part of the song (for small licks or leads...) as there is no accompaniment.
Comment: Note that in many cases, you can mute the strings and play rhythm similar to how a mandolin player would "chop".
Comment: i.e. you don't play any notes other than the melody, but you still have to play at least one note. So the question becomes: to which chord does this note belong? It seems likely that it would be a note in the preceding chord.

What does "NC" mean?


How to list all services linked to libwrap.a (tcp wrappers)

Question: I know most Linux network services are linked to libwarp.a (tcp-wrappers) and this can be check via the ldd command. But can't seem to find how to list all the network services being linked to libwarp.a.
After some waiting, I created a dump way myself. Run the script below in /usr/sbin
find ./ -type f -exec echo {} \; -exec ldd {} \; | egrep "\\./|libwrap" | less
Found 5 in CentOS7. Is there a correct way to do this?
Answer: There are many ways to do it, but first you will want to search for binaries linking to libwrap.so.
My one liner is (broken into separate lines for readability):
for file in /usr/sbin/*
do
    ldd $file 2>/dev/null | grep -q libwrap.so && echo $file
done

I've selected all the files I want to look at, here in /usr/sbin, but you can look elsewhere if you want.
I suppress error output from ldd because it's noisy.
Using -q causes grep to not output anything (because seeing a bunch of libwrap.so would be pointless). And by using && I only run echo if grep found a match.
So I get:
$ for file in /usr/sbin/*; do ldd $file 2>/dev/null | grep -q libwrap.so && echo $file; done
/usr/sbin/auditd
/usr/sbin/exportfs
/usr/sbin/rpcbind
/usr/sbin/rpcinfo
/usr/sbin/rpc.mountd
/usr/sbin/rpc.statd
/usr/sbin/sshd

Comment: Thanks Michael. I learn -q and && today from this. I was thinking that it's normal for one who started to learn tcp-wrapper would be interested in knowing what are linked to it and hence there would be a common & easy method to list it out, no scripting required.   I installed nfs to see do if I got the same result as you. Now I wonder, are the services "pre-linked" or linked during installation of nfs-utils?


Parsing Data from a file Nodejs

Question: Just trying to experiment with node and lost on this one.
I am trying to read a file using node.js and sum the prices in that file.
So far I can read the data but am having problems adding just the prices.
const fs = require('fs')

fs.readFile('file.txt', 'utf8' , (err, data) => {
  if (err) {
    console.error(err)
    return
  }
  console.log(data)
})

in file.txt I have

"id,item,price
1,Milk,5
2,Soap,10
3,Water,2"

From the file.txt I only need to add the prices and print it out.
For example for above example, I would have "price = 17"
Any guidance in the right direction is appreciated
Answer: Firstly, I assume that the file is a CSV, because of all the commas :).
You can easily parse CSV files with csv-parse.
We just need to additionally specify that the record_delimiter is a space (' '), not the standard new line ('\n')
const csv = require("csv-parse");
const fs = require('fs');
const res = [];

fs.createReadStream('test.txt')
    .pipe(csv({ record_delimiter: ' '})) // pipe input stream to the CSV parser

    .on('data', (data) => res.push(data)) // push data to the result array
    .on('end', () => {
        var price = 0; // create a variable for the price
        for(var s=1; s<res.length; s++) //  iterate over all records
            price += parseInt(res[s][2]);
        console.log(price); // print the price
    })
    .on('error', (err) => {
        console.log("error: " + err);
    });

We can also change it a bit so that we work with objects by setting columns to true (I find the data more sorted that way)
const csv = require("csv-parse");
const fs = require('fs');
const res = [];

fs.createReadStream('test.txt')
    .pipe(csv({ record_delimiter: ' ', columns: true})) // pipe input stream to the CSV parser

    .on('data', (data) => res.push(data)) // push data to the result array
    .on('end', () => {
        var price = 0; // create a variable for the price
        res.forEach(el => price += parseInt(el.price)) // Iterate on each object and get the price field
        console.log(price); // print the price
    })
    .on('error', (err) => {
        console.log("error: " + err);
    });

With this code the data looks like this:
[
  { id: '1', item: 'Milk', price: '5' },
  { id: '2', item: 'Soap', price: '10' },
  { id: '3', item: 'Water', price: '2' }
]

Comment: Yeah, I just noticed that there are `"` at the start and end of the file, if you remove those, it should be fine. Also, it is not a problem that the extension is .txt and not .csv
Comment: Not sure if the solution is correct as I am getting 0 and my file is .txt not .csv

Parsing Data from a file Nodejs


Use drush to put a site in maintenance mode

Question: drush @mysite cget system.maintenance shows:

message: '@mysite is currently under maintenance. We should be back shortly. Thank you for your patience.'
      langcode: en

Drupal 8 uses state values to record transient state, so drush @mysite sget system.maintenance_mode gives me a 1 or a 0.
But, try as I may, I cannot see how to set the boolean. I've tried:
$ drush @mysite sset system.maintenance.mode "TRUE" --format=boolean
$ drush @mysite sget system.maintenance_mode
0
$ drush @mysite sset system.maintenance.mode "TRUE" --format=auto
$ drush @mysite sget system.maintenance_mode
0
$ drush @mysite sset system.maintenance.mode true --format=auto
$ drush @mysite sget system.maintenance_mode
0
$ drush @mysite sset system.maintenance.mode true --format=boolean
$ drush @mysite sget system.maintenance_mode
0

What's the secret?
Answer: system.maintenance_mode is not a boolean, it is an integer:
drush ev "var_dump(\Drupal::state()->get('system.maintenance_mode'));"

Result:
int(0)

The answer to the question, how to use drush to put a site in maintenance mode:
drush sset system.maintenance_mode 1

Comment: It's worth noting here that if the site has never BEEN in maintenance mode before, the `system.maintenance_mode` variable doesn't exist, and the above `drush ev` command actually returns `bool(false)`, which is misleading.
Comment: @DaleAnderson can you update the answer to be "mo betta"?


Converter Html em texto legível usando MVC C#

Question: Tenho um texto no banco de dados desta forma: Exemplo apenas:

 asdsdasdadsdadsa asdsd asdsdasdasdad

                asdas

A informação está com as tags HTML, eu quero poder trazer esse texto e mostra de uma forma legível na página. Aonde desapareça essas tags e mostre apenas o texto.
Eu usei esse código:
 public ActionResult Index(int id)
        {

            QuemSomos model = _repositorio.BuscarPorId(id);
            var quemSomosMapper = Mapper.Map<QuemSomos, QuemSomosViewModel>(model);

            ViewBag.conversao = HttpUtility.HtmlDecode(quemSomosMapper.Texto.ToString());

            return View(ViewBag.conversao);
        }

Más não ta funcionando. Gostaria de uma ajuda se for possível.
Comment: Alysson, você quer remover as tags HTML ou interpretar o HTML na view?
Answer: Tente as opções abaixo:
1
String result = Regex.Replace(htmlDocument, @"<[^>]*>", String.Empty);

2
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(Properties.Resources.HtmlContents);
var text = doc.DocumentNode.SelectNodes("//body//text()").Select(node => node.InnerText);
StringBuilder output = new StringBuilder();
foreach (string line in text)
{
   output.AppendLine(line);
}
string textOnly = HttpUtility.HtmlDecode(output.ToString());

3
string html;
// obtain some arbitrary html....
using (var client = new WebClient()) {
    html = client.DownloadString("https://stackoverflow.com/questions/2038104");
}
// use the html agility pack: http://www.codeplex.com/htmlagilitypack
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(html);
StringBuilder sb = new StringBuilder();
foreach (HtmlTextNode node in doc.DocumentNode.SelectNodes("//text()")) {
    sb.AppendLine(node.Text);
}
string final = sb.ToString();

Obs. a primeira opção tem um gap com CDATA, se não for o caso, pode utilizá-la, caso contrário utilize a segunda.
Fonte: https://stackoverflow.com/questions/787932/using-c-sharp-regular-expressions-to-remove-html-tags


How to remove "Hide these specified drives in My Computer" group policy

Question: I have a Windows Server 2012 R2 Terminal server on a standalone workgroup.
The client asked for the C drive to be hidden so I enabled the "User configuration\Administrative Templates\Windows Components\File Explorer\Hide these specified drives in My Computer" group policy and set it to hide all drives.
After some time the client wished to reshow the drive and I disabled the group policy and rebooted the PC but the drive did not return.
I checked the registry and under HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer the NoDrives dword was still there so I set it to 0, rebooted and the problem still persisted.
The NoDrives dword was also present under group policy objects associated with individual profiles in HKEY_USERS.
Things I have tried:

I set all instances of NoDrives to 0 and rebooted the system
I deleted all instances of NoDrives and rebooted the system
I logged off a user account, renamed their user profile in C:\Users and deleted their key from HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
I reenabled the group policy and set it to only hide A and B drives

All have failed. Is there something I am missing?
Answer: I solved this by doing the following:

Deleting registry.pol from %Systemroot%\System32\GroupPolicy\User
Opening gpedit.msc and enabling User Configuration\Windows Components\File Explorer\Hide These Specified Drives in My Computer
I set the setting to Do Not Restrict Drives.

Simply setting the group policy was not enough, deleting the registry.pol file was required. This will only require you to recreate policies under User Configuration, machine policy is in it's own file.


About Gödel's completeness and incompleteness theorems

Question: I am using ZFC as a tool to demonstrate my problematic logic.
In zfc we construct a proof system for zfc in zfc (a simulation of a proof is what I mean); we will call it inner proof system. We establish that if there is a proof in this inner proof system that concludes A then A holds. Turing machines can be formalized in zfc with the notions of halting and not halting. The whole question relies upon the argument that the zfc can prove that for every halting turing machine on a certain input there exists a proof of this in the inner system (which I am not entirely sure it is provable in zfc without further assumptions).
A turing machine that takes an input (and treats it like an incoding of a turing machine and also as an input) and goes through all possible proofs (in the inner proof system) that conclude that the input halts on itself or does not halt. If such a valid proof was found our machine does the opposite of the proof's conclusion (meaning that if the proof demonstrated halting the machine would enter an infinite loop and if the proof demonstrated not haulting the machine would halt). Under the assumption that zfc is consistent it holds that this turing machine does not halt on itself. This is a construction used to demonstrate the first and second incompleteness theorems in zfc for computer scientists.
Assuming the consistency of zfc, the statement that the aforementioned turing machine does not halt on itself cannot be proven by zfc and thus cannot be proven by the inner proof system. Assuming the consistency of zfc, according to the completeness theorem there exists a model of zfc where the statement: "the aforementioned turing machine does not halt on itself" is true and another with this statement false.
My problem is with the model in which it holds that this statement is false. This means that the relevant turing machine halts. It follows that there is a proof of that in the inner proof system. It follows that the inner proof system is inconsistent.
I know there is something wrong with this logic but I cannot pinpoint it (obiously because I did not formalize this argument sufficiently). Where in this sketch of a proof does the argument fail (for example because a statement is not directly provable from zfc without certain assumptions)?
Note: my backgroung is in computer science
Comment: "My problem is with the model in which it holds that this statement is false. This means that the relevant Turing machine halts. It follows that there is a proof of that in the inner proof system. " But that is the gist of GIT: wrt a suitable theory T we construct a statement G such that neither G nor not-G are provable in T. But in the meta-theory (e.g. ZFC) we "know" that one of them is true (e.g. the T-statement G asserting that G itself is unprovable in T). Thus, on what ground you says: "It follows that there is a proof of that in the inner proof system"?
Comment: "it means that the relevant Turing machine halts. It follows that there is a proof of that in the inner proof system. " Why so? If we conclude form the fact that we know that a "fact" about T machine holds, than there is a proof of that fact in the theory, we are simply assuming the "completeness" (wrt to the "standard model", that of GIT, and not the completeness wrt validity, that of G's Completeness Th) of the theory T, and this is exactly what GIT denies.
Comment: It would be helpful if you could sharpen your question by specifying when you speak of ZFC as the background meta-language, and when - as the object language.
Comment: @MauroALLEGRANZA the statement in question is "the aforementioned turing machine does not halt on itself". If it is false in the model then the turing machine does halt on itself. If the following argument is provable in zfc "for every halting turing machine on a certain input there exists a proof of this in the inner system" then there exists a proof that the relevant turing machine does halt in the inner proof system. if the last argument is not provable in zfc then this answers my question.
Comment: @MikhailKatz everytime I did not mention the inner system I mean zfc
Comment: @MauroALLEGRANZA The inner proof system should be able to prove for every halting turing machine that it halts. The proof itself is by showcasing the entirity of the run configurations of this turing machine on the specific input and also showing that the last state of the machine in this series of configurations is a final state
Comment: See e.g. the post [What is the relationship between Turing Machines and Gödel's Incompleteness Theorem?](https://mathoverflow.net/questions/227310/what-is-the-relationship-between-turing-machines-and-g%c3%b6dels-incompleteness-theo) and [Aronson's related paper](https://scottaaronson.blog/?p=710).
Answer: It's a bit difficult to pin down the issue without sufficient formalization. Here is my attempt.
Given a Turing machine $T$, such that $T$ halts or not is independent of ZFC. This implies that $T$ doesn't halt for otherwise there is a proof in ZFC by simulating its behavior. Assuming ZFC is consistent, then ZFC + " $T$ halts " is still consistent, and by the completeness theorem, there must be a model of it.
How to interpret $T$ halts in terms of set theory? One way is to use the simulation or a proof of halting as the definition of halting. Just like Godel replaced "This is false" by "This cannot be proved", the new system doesn't say "$T$ halts" but "There is a proof that $T$ halts".
So the new axiom is really there exists a number that encodes a proof of "$T$ halts". This is not the same as to say there really is such a proof, because the number in the model might be non-standard!
I learned this from Tim Chow:

suppose someone proves on the basis of ZFC a theorem that states that
the Goldbach conjecture is false, i.e., a theorem of the form "there
exists an integer k that refutes the GC." Again, a priori we still
can't conclude automatically that the GC is indeed false (for the
standard integers) even if we assume that ZFC is consistent.
In other words, consistency doesn't buy you everything that you might
want from a formal system---it tells you that models of the system
exist, but it doesn't tell you that there are any models where the
"integers" are isomorphic to the standard integers, so you can't
necessarily "trust" theorems of the system.


Fouriertransform : Determine the inverse Fourier transform

Question: Determine the inverse Fourier transform to
$$F(ω) = \frac{1}{(ω^2 + 4)(ω^2 + 9)}$$
using
a) Partial fractions, and then using the Fourier Transform table.
b) Convolution.
I don't know to to solve it :( please help.
Comment: I edited the problem to make it $\omega^{2}$ in the denominator (I assume that is what $\omega 2$ meant). Also, you'll have to tell us what you have tried or no one is going to help you. Make an edit to your post that includes this. Also include what your definition of the Fourier Transform is.
Comment: It doesn't work like that. The way to solve has already been given to you in the question, look up partial fractions and fourier transforms, or read other peoples previous questions.
Comment: just tell me the first step and i will do the rest :)
Answer: HINT 1:
For partial fraction expansion, we have
$$\frac{1}{(\omega^2+4)(\omega^2+9)}=\frac15\left(\frac{1}{\omega^2+4}-\frac{1}{\omega^2+9}\right)$$

HINT 2:
For using the convolution theorem, note that
$$\mathscr{F}(f(\omega)g(\omega))=\mathscr{F}(f(\omega))*\mathscr{F}(g(\omega))$$
where here, $f(\omega)=\frac{1}{\omega^2+4}$ and $g(\omega)=\frac{1}{\omega^2+9}$.
Here we define the Fourier Transform as
$$\mathscr{F}(f(\omega))=\int_{-\infty}^{\infty}f(\omega)e^{i2\pi \omega t}\,d\omega$$
Comment: thank you for the hints, they are very usefull for me. so i got ===> (pie^(2abs(-5w)))/10   for f(t)    and for g(t) i got ===> (2pie^(2abs(-5w)))/45  is that correct ?  (i used the table)
Comment: @user2393690 You're welcome! My pleasure.  Pleased to hear the this was useful. I cannot read the answer you provided in the comment.  I suggest pursuing using the partial fraction expansion also.
Comment: i get help by my teacher, thank you anyway.  @Dr. MV
Comment: You're quite welcome.


Swift: Comparing Equatable Class object I get error Binary operator '==' cannot be applied to two 'Any' operands

Question: I have the following class:
import UIKit

class SomeClass: Equatable {
    var Obj: Any

    init(Obj:Any) {
        self.Obj = Obj
    }

    static func == (lhs: SomeClass, rhs: SomeClass) -> Bool {
        return lhs.Obj == rhs.Obj
    }
}

But I'm getting the following error:
Binary operator '==' cannot be applied to two 'Any' operands
On this line:
return lhs.Obj == rhs.Obj
Any of you knows why I'm getting this error? or if there is a way around this?
I'll really appreciate your help.
Comment: `Any` is just about always a bad smell. In any case this appears to be an x–y question. The real question should be about whatever problem this class was intended to tackle.
Comment: The error tells you exactly the problem. `==` cannot be applied to `Any`. You almost certainly don't want Any here, anyway (Any is a very rare type in good Swift, and always a bothersome type). You should likely redesign SomeClass to remove the Any.
Comment: Completely depends on what problem you're solving. What is Obj and SomeClass for? The broad answer is to make SomeClass generic (`class SomeClass: Equatable`), but that introduces various other restrictions, so it depends on the exact situation.
Comment: What if the things are not equatable? For example, two infinite sequences? What about two functions? Are they equal if they return the same values? If they have the same op codes? If they're created from the same source code. Any is a very broad type including all kinds of things that you're probably not thinking of as "objects." "As generic as possible" doesn't mean anything here. You need to work from your actual use cases.
Comment: There is another generic way or type I can use beside `Any`?
Comment: With `class SomeClass: Equatable {` still get the same error. I just want to be able to assign any kind object. I was trying to implement this as generic as posible
Comment: I was not suggesting you just replace the first line of code. I meant redesigning the type to use generics rather than Any. If you want a longer discussion of how to deal with Equatable in a protocol-driven way, see https://www.youtube.com/watch?v=DXwJg0QTlZE (start around 37:30). But Any is almost always the wrong tool. Start with your actual use case; extract generic code from where it duplicates.
Comment: That said, if you mean that Obj must be a *class* (rather than any type), then you can use `AnyObject` and `===` to test for "the same memory location." This is almost always bad Swift, but it is legal.
Comment: @RobNapier I think they should allow `extension Any:Equatable { /* ... */ }` in the next swift version :-)
Answer: check the equality of each property of your custom class in the Equatable protocol function as below
class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
            let objA = someClass(name: "Name1", age: 25)
            let objB = someClass(name: "Name2", age: 25)
            print(objA == objB)
    }
}

class   someClass: Equatable {
    static func == (lhs: someClass, rhs: someClass) -> Bool {
        return lhs.name == rhs.name && lhs.age == rhs.age
    }

    let name: String
    let age: Int

    init(name: String, age: Int){
        self.name = name
        self.age = age
    }
}

Comment: This does not answer the question.


linking symbol to class actionscript

Question: There is a simple method of linking a symbol to a class in flash cs5 in the gui designer. But how can i do the same thing in actionscript alone using code because iam not using flash cs5. Iam using notepad++ and flex compiler.
Comment: I think you need to be clearer about what you're asking.  If you're only using the Flex compiler and Notepad++ where are the symbols coming from?
Comment: in flash a symbol can be a image right. How can i embed a image as a object in actionscript code ?
Answer: Hopefully this link will answer your question: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/MovieClip.html
The essence is this:
[Embed(source="logo.gif")]
[Bindable]
public var imgCls:Class;

and what this does is tell the compiler to add logo.gif as a symbol whose class name will be imgCls.
To then use this in your code, you just have to create an instance of it and work as normal:
var myImg:BitmapAsset = new imgClass() as BitmapAsset;
addChild(myImg);

Comment: how can i display it on the sprite ?
Comment: i added keyboard listner and inside that i have code to move it but it doesnt move. My code is    myImg.x =++x  when user presses up button
Comment: @user44444444 - You probably want something like `myImg.x++`, but this is getting off-topic. Please would you open a new question concerning your movement issues, and mark this as accepted if it answered your original question. Thanks :)
Comment: hey i have one small question. The bitmap looks too large. The bitmap on file is way smaller than the one getting displayed. Is there a way of getting the original onto the sprite ?
Comment: oh ok i figured that out. you can use the myImg.ScaleX and ScaleY property. :) Thanks shanethehat.
Comment: The shouldn't be any scaling applied to the Bitmap, although for the sake of completeness I've updated my anser to make the object a `BitmapAsset`, not a `Bitmap`.  You should check if the container sprite is scaled by setting it's `scaleX` and `scaleY` properties to 1, or check the dimensions of your BitmapAsset by attaching it to an image control as shown in the link in my answer.

linking symbol to class actionscript


connect mysql server installed on t1.micro instance from vpc t2.micro instance

Question: I have mysql database server installed on ubuntu in t1.micro ec2 :
Instance state: running
Public IP: 50.xxx.xxx.xxx
Instance type: m1.medium
Elastic IP: 50.xxx.xxx.xxx
Private DNS: ip-xxx-xxx-xxx-xxx.us-west-1.compute.internal
Availability zone: us-west-1a

I create another instance, this one using t2.micro so it's using vpc
Instance type: t2.micro
Elastic IP: 52.xxx.xxx.xxx
Private DNS: ip-xxx-xxx-xxx-xxx.us-west-1.compute.internal
Availability zone: us-west-1a
Private IPs: 17x.xxx.xxx.xxx
Security groups: default. view rules
Secondary private IPs: Scheduled events
No scheduled events
VPC ID: vpc-25xxxxxx
AMI ID: ubuntu-trusty-14.04-amd64-server-20150325 (ami-xxxxxxxx)
Subnet ID: subnet-9cxxxxxx
Platform

I'm deploying website in t2.micro and want to access mysql server in t1.micro. I've edited my.cnf configuration to comment #bind_address. In the t1.micro security group I've tried to add new inbound rule to access mysqlserver :
type : mysql
protocol : tcp
port : 3306
source : private ip of my t2.micro instance 17x.xxx.xxx.xxx.

My website could not access the server.
Comment: Did t1.micro has private IP?
Comment: @masegaloeh it has public/elastic ip Public IP: 50.xxx.xxx.xxx
Answer: You will need to set up ClassicLink to allow your classic EC2 instance to communicate with your new instance in the VPC.
This has two steps:

Edit the VPC to enable ClassicLink. Click your VPC in the list of VPCs, select Actions, then Enable ClassicLink.
Attach the classic instance to the VPC. Click your old instance in the list of instances, select Actions, ClassicLink, Link to VPC.
Comment: I've follow your step, so, what to do then? how to communicate? tried to ping classic ec2 private ip from t2.micro, but failed.
Comment: the definition of ClassicLink : allows you to link EC2-Classic instances to a VPC, so that you can communicate with resources in the VPC using private IP addresses. so this's just one way, I could'not communicate form vpc to ec2 classic instance?
Comment: ah yes, this is one way? I've tried create new inbound rule in my vpc security group for ec2 classic instance, and ping it, works. but I could not communicate from t2.micro to t1.micro.


Query eureka without registering as a service

Question: I'm building a service X that will use eureka. I use spring boot and spring cloud. I want to check if i configured X correctly (load balancing, service discovery etc). to do it i would like to run X locally and connect/query existing eureka (on company's UAT environment) but without registering X as a new service so no traffic is redirected to my local machine.
is it possible? what configuration is needed to achieve it?
Answer: With this property it works for me:
eureka.client.register-with-eureka=false

But I also found an example in the eureka documentation:
https://github.com/Netflix/eureka/blob/master/eureka-examples/conf/sample-eureka-client.properties

note that for a purely client usage (e.g. only used to get information about other services, there is no need for registration. [...]

eureka.registration.enabled=false


Can't send fax with Fax Server on Windows Server 2008 R2

Question: I have Windows Server 2008 R2 (ip: 192.168.62.1) which installed Fax Server feature on it and connected with Fax device (ip: 192.168.62.20) via LAN.
I haven't success yet to send fax using Windows App: "Windows Fax and Scan". I am wondering what the problem is. Do we really need dedicated modem?
My fax device is:
Kyocera FS-C8520MFP
Thanks in advance
Comment: models please, are you using a multi-function copier??
Comment: yes, kind of. I updated the question @JacobEvans
Comment: did you install the fax driver?
Comment: Yes sir, fax driver only actually. https://www.kyoceradocumentsolutions.eu/index/service/dlc.false.driver.FSC8520MFP._.EN.html
Comment: Did you get any error messages on the Windows Server in the event logs when trying to send a fax? Did you get any error messages in the application sending the fax?
Answer: Fax has morphed many times over the years, for windows to use Fax/Scan it will want to use a driver written to interface with Fax/Scan OR a real fax modem.
You can likely print to a fax queue, which is all handled by the Kyocera itself and give windows indication that it is a fax.  You'll need to load the drive on all endpoints you want to fax.
In my experience, hylafax email gateway is a good option or hosted (check compliance requirements)
Comment: Right, I can do print to fax. In short, I can't use the Windows Fax and Scan application now?
Comment: correct, it's up the the driver writer to configure those hooks
Comment: sadly a cheap Brother MFC supports it.
Comment: I see, how do you know it supports or not? So, I can check another models.
Comment: if one model doesn't support it I doubt any do.
Comment: how about Panasonic KX-series? just ask
Comment: no idea bud, maybe read the manual and see how they tell you to send a fax via PC?


Normal linear maps over $\mathbb C$

Question:
Prove that if $\alpha: V \to V$ is a normal linear map on a finite-dimensional inner product space $V$ over $\mathbb C$ then $\alpha = \alpha_1 + i\alpha_2$ where $\alpha_1$ and $\alpha_2$ are self-adjoint, and $\alpha_1 \alpha_2 = \alpha_2 \alpha_1$.

Since every normal linear map is diagonalisable this is easy to show by diagonalising the matrix representing $\alpha$, but I have a feeling it can be shown directly from the definition of normal: $\alpha \alpha^* = \alpha^* \alpha$. Unfortunately I cannot see how to do it. A hint would be appreciated.
Answer: If we set
$\alpha_1 = \dfrac{\alpha + \alpha^\ast}{2}, \tag 1$
then evidently
$\alpha_1^\ast = \alpha_1, \tag 2$
i.e., $\alpha_1$ is self-adjoint; likewise, setting
$\alpha_2 = \dfrac{\alpha - \alpha^\ast}{2i}, \tag 3$
we see that
$\alpha_2^\ast = \dfrac{\alpha^\ast - \alpha}{-2i} = \dfrac{\alpha- \alpha^\ast}{2i}; \tag 4$
so $\alpha_2$ is also self-adjoint; also,
$\alpha = \alpha_1 + i \alpha_2, \tag 5$
as is easily seen.  Now
$\alpha_1 \alpha_2 = \dfrac{1}{4i}(\alpha + \alpha^\ast)(\alpha - \alpha^\ast) = \dfrac{1}{4i}(\alpha^2 - (\alpha^\ast)^2) = \dfrac{1}{4i}(\alpha - \alpha^\ast)(\alpha + \alpha^\ast) = \alpha_2 \alpha_1, \tag{6}$
where we have used $\alpha \alpha^\ast = \alpha^\ast \alpha$ in performing the algebraic operations of (6).  It follows that $\alpha_1$ and $\alpha_2$
meet the stated requirements.
No diagonalization needed!

Normal linear maps over $\mathbb C$


Finding circles on lattice points with arbitrary origin.

Question: I am trying to find circles on lattice points with exactly $n$ lattice points on its circumference. Schinzel's Theorem only gives one instance for each $n$ and it does not necessarily have the smallest radius. There are two general problem I am trying to solve:

Given $n$, find the circle with smallest radius (arbitrary center).
Given $n$ and $R$, find all circles with radius $r<R$.

The problem can be solved by properties of sum of squares function when the center is on a lattice point (origin). But I found few references when the center is on the axis $(x_0,0)$ or even off the lattice. I also know how to reduce the problem to the same as above, given a center with fraction coordinates.
But I do not know the search space for all the possible centers, and this becomes the bottleneck for both problems.
Any references and hints are appreciated.
Comment: See also https://mathoverflow.net/questions/281382/formula-for-schinzel-circle-with-minimum-radius
Answer: I wrote some Python code to find minimal lattice circles for a puzzle I was solving. See Enigma 136: Twelve-point square, where I give a list of minimal lattice circles with radius less than 1800 (and some other ones that are known to be minimal), along with some other circles which I've found, but are not necessarily minimal.
The smallest unverified circles are for n=29 and n=31 points on the circumference.


Why is that $\int_{-L}^{L} \cos{\left(\frac{m\pi x}{L}\right)}\cos{\left(\frac{n\pi x}{L}\right)}dx=\delta_{mn}L$ does not work for $m=0$?

Question: I have this expression $$\int_{-L}^{L} \cos{\left(\frac{m\pi x}{L}\right)}\cos{\left(\frac{n\pi x}{L}\right)}dx$$ my book says that this is equal to $$\int_{-L}^{L} \cos{\left(\frac{m\pi x}{L}\right)}\cos{\left(\frac{n\pi x}{L}\right)}dx=\delta_{mn}L$$ except when  $m=0$. In this case, it says, we have $$\int_{-L}^{L} \cos{\left(\frac{n\pi x}{L}\right)}dx=2L\delta_{0n}$$

Why is that?

If I put $m=0$ I will have $$\int_{-L}^{L} \cos{\left(\frac{n\pi x}{L}\right)}dx=\left[\frac{L\sin{(\frac{n\pi x}{L})}}{n\pi}\right]_{-L}^L=\frac{L}{n\pi}[\sin{(n\pi)}-\sin{(-n\pi)}]=\frac{2L(-1)^n}{n\pi}$$ how do they obtain that?
Comment: Note that you have to handle the case $n=0$ separately, since the first equality doesn't hold then (because you would be dividing by zero)
Answer: For $n=0$ we have
$$\int_{-L}^L \cos(n\pi x/L)\,dx=\int_{-L}^L (1)\,dx=2L \tag 1$$
And for $n\ne 0$, we have
$$\begin{align}
\int_{-L}^L \cos(n\pi x/L)\,dx&=\left.\left(\frac{\sin(n\pi x/L)}{n\pi /L}\right)\right|_{-L}^L \\\\
&=\frac{\sin(n\pi )-\sin(-n\pi)}{n\pi/L}\\\\
&=0\tag 2
\end{align}$$
since $\sin(n\pi )=0\ne (-1)^n$ for all integer $n$.
Putting $(1)$ and $(2)$ together, we find that
$$\int_{-L}^L \cos(n\pi x/L)\,dx=2L\delta_{n,0}$$
as was to be shown!
Comment: No, when $n=0$ the argument doesn't work. @Euler_Salter
Comment: oh right. Then it should always be zero, and not $2L\delta_{0n}$ right?
Comment: @Euler_Salter : See my comment on the original question above
Comment: @MPW right! I need to divide into two cases again, it makes sense!


Find all the values of $c$, if any, for which $f(f(x))=x$.

Question:
Extracted from The Eleventh W.J. BLUNDON Contest, Consider the function $f(x)=\frac{cx}{2x+3},x\ne-\frac{3}{2}$. Find all the values of $c$, if any, for which $f(f(x))=x$.

My attempt,
$$\frac{c(\frac{cx}{2x+3})}{\frac{2cx}{2x+3}+3}=x$$
$$\frac{c^2x}{2cx+3(2x+3)}=x$$
$$c^2x=2cx^2+3x(2x+3)$$
$$c^2x=2cx^2+6x^2+9x$$
By comparing the coefficients,
$$c^2=9 \space \text{and} \space 2c+6=0$$
So, $$c=-3$$
But the given answer is 3. Why? What's wrong with my solution?
Comment: The "answers at the back of the book" are not always correct.
Comment: The answer seems to be wrong if I didn't misinterpret the problem.
Comment: If you want to make sure -3 is answer but not 3, just Check these two numbers and see result....
Comment: $c=-3$ is the correct answer.
Comment: Is the question for which values of c is f (f (x)) *always* true for all x? Or for what values of c is f (f (x)) sometimes true for some x? If always, you are correct.  If sometimes you must solve for x in terms of c, when c != -3.
Comment: Oh, never mind.  It's clear in context they meant always.  But I think the book made a typo.  That's not uncommon.  The answer should be -3.
Comment: Btw, your solution was impressively methodical, neat and clean.  It was very nice to read.
Comment: @fleablood Thanks a lot. I doubt the my answer as the answer provided if from a popular maths journal. But it seems that, it's a typo.
Answer: Alpha and I agree with you that $c=-3$ works.


How to view the entire Rails console history?

Question: Does anyone know how to view the "history" in the rails console?
Pressing the up arrow lets me iterate through recent commands, but I'd like to see them all together in a list. I'm basically looking for the rails equivalent of the Unix history utility.
Is this possible in rails?  If so, how?
Answer: The best equivalent to the history command would be
puts Readline::HISTORY.to_a

inside the IRB session. This has the advantage that no filesystem logging to any of the$HOME/.*_history files needs to be configured (as is the case in AWS elastic beanstalk instances).
Comment: In newer versions it's Reline instead of Readline

`puts Reline::HISTORY.to_a`
Answer: Look at ~/.irb-history, you will find the history there.
Comment: I found it in `~/.local/share/pry/pry_history` presumably due to a pry-rails gem in dev requirements in the venvs I was using
Comment: hm... for the record, it's actually `~/.irb-history` (with a dash, not an underscore) on my machine. Not sure why. I'm on a Mac and using RVM.  Anyway, thanks!
Comment: Weird, I have both files, but the one with `_` seems to be more up to date than the other. Strange.
Comment: I have both files too, but in my case `-` is more up to date.  Strange indeed!
Comment: It's a hyphen on my Ubuntu laptop & and an underscore on our Ubuntu server.  Odd indeed: they have the same version of ruby but it's hard-installed on the server and rvm-installed on my laptop.  Wonder if it's something to do with rvm?
Comment: I also found it in "~/.local/"... If that's the default for ruby venvs they could have come up with a better naming...
Answer: I've tried the accepted answer, but our server didn't have a ~/.irb-history.
As it turned out, the history was kept in ~/.pry_history. Hope this helps.
Comment: Also here. Maybe when using pry gem, then it'll be stored in `~/.pry_history`, instead of `~/.irb_history`.
Answer: Since we're already in the console,
lines = File.read("#{ENV['HOME']}/.pry_history");

or
lines = File.read("#{ENV['HOME']}/.irb-history");

then,
puts lines

Comment: history = File.read("#{ENV['HOME']}/.pry_history").split('\n')
Answer: Try CTRL+R to open the search in the history
Answer: We can view it by using following command in console
cat ~/.irb-history

Answer: Regarding

The best equivalent to the history command would be

currently (Pry version 0.14.1 on Ruby 3.0.2 for me) there is actually a history command which is an alias for hist.


Node JS installation error: Key not valid for use in specified state

Question: I just want to install nodejs, that's all and it's not like this is the first time. I just un-installed and downloaded the latest version to re-install and I keep getting this error. Is there any fix for this?
I'm doing this on Windows 7 SP1 x64. And yes I've tried both 64 and 32-bit versions still the same issue. See screenshot

Okay I also monitored the installation logs and I noticed this:
MSI (s) (68:6C) [11:32:08:140]: SECREPAIR: SourceHash database file already exists. Deleting it.
...
MSI (s) (68:6C) [11:33:19:147]: SECUREREPAIR: Failed to CreateContentHash of the file: node-v0.10.31-x64.msi: for computing its hash. Error: -2146893813
MSI (s) (68:6C) [11:33:19:147]: SECREPAIR: Failed to create hash for the install source files
MSI (s) (68:6C) [11:33:19:147]: Note: 1: 2262 2: SourceHash 3: -2147287038
MSI (s) (68:6C) [11:33:19:147]: SECUREREPAIR: SecureRepair Failed. Error code: 8009000bECA934B8

Does this have anything to do with it?
Comment: Okay so after some research I found an issue with windows 7 update KB2918614 causing overlapped I/O operation.. did a roll back, installed nodejs and updated again.
Answer: Here are two suggestions from others who have had the same issue:

Rename C:\Users\%USERNAME%\AppData\Roaming\Microsoft\Crypto\RSA to something else like "C:\Users\%USERNAME%\AppData\Roaming\Microsoft\Crypto\RSA.old" and try the installer again.
You may want to check to see if you have the KB2918614 update installed. On Windows 7 you can check by looking through Control Panel -> Programs and Features -> View Installed Updates. Try uninstalling that update and try the installer again.
Comment: I had actually tried the second option before I saw your comment. Thanks anyway.
Comment: The first option works too. I'll actually recommend the first. Renaming the RSA folder. But why didn't Microsoft fix this in their subsequent updates?


Any way to list all user-defined PostgreSQL functions?

Question: PostgreSQL provides the command \dv to list all views.  Is there a similar way to list all user-defined functions or perhaps just those function defined by a particular user?  \sf requires you to know a function's name and it will provide a function's definition.  \df lists all functions (and there are a lot). I'd like a way to just show a list of the functions I've defined.
Answer: The best way to find such a query is to use psql with the --echo-hidden option. Then run the psql meta-command and you will see the query that is used.
For \df this is:
SELECT n.nspname as "Schema",
  p.proname as "Name",
  pg_catalog.pg_get_function_result(p.oid) as "Result data type",
  pg_catalog.pg_get_function_arguments(p.oid) as "Argument data types",
 CASE
  WHEN p.proisagg THEN 'agg'
  WHEN p.proiswindow THEN 'window'
  WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN 'trigger'
  ELSE 'normal'
 END as "Type"
FROM pg_catalog.pg_proc p
     LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
WHERE pg_catalog.pg_function_is_visible(p.oid)
      AND n.nspname <> 'pg_catalog'
      AND n.nspname <> 'information_schema'
ORDER BY 1, 2, 4;

You could adjust that by e.g. changing the where clause to:
AND n.nspname = 'public'

Which is equivalent to \df public.*

If you check the documentation of pg_proc you will notice that there is a proowner column so you could also run:
SELECT n.nspname as "Schema",
       p.proname as "Name",
       pg_catalog.pg_get_function_result(p.oid) as "Result data type",
       pg_catalog.pg_get_function_arguments(p.oid) as "Argument data types"
FROM pg_catalog.pg_proc p
  JOIN pg_catalog.pg_roles u ON u.oid = p.proowner
  LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
WHERE pg_catalog.pg_function_is_visible(p.oid)
  AND n.nspname = 'public'
  AND u.rolname = current_user --<< this limits the functions to those that the current user owns.

Comment: TIL `--echo-hidden`. Mind. blown.
Answer: I'm not sure if this command is entirely accurate but it appears to show me all functions owned by a particular role:
SELECT routine_name, grantee FROM information_schema.routine_privileges WHERE grantee = '<role>';

In any event, it gives me the results I would expect to see.


Fetch feed from a given URL

Question: I have a URL like www.example.com/test/rss.xml, and I want to import this XML automatically in Drupal 6. I created the content type as in rss.xml, but I am not able to import automatically. I tried the Feed module for this, but I am able to upload manually, not automatically, when I need it to update all the feeds from rss.xml automatically.
Does anybody have an idea about this?
Comment: possible duplicate of http://drupal.stackexchange.com/questions/21379/fetch-content-from-another-website-into-new
Comment: Not duplicate  .
Comment: @optimusprime619 I tend to agree it is a duplicate, in someway; the difference is only between fetching content, and fetching a feed content, where the first doesn't exclude the latter. Remember you can flag a question as duplicate using the "flag" link you see after the question, and before the comments. In the dialog box that appears, choose "it doesn't belong here" and then the reason for closing it (duplicate).
Answer: Have you tried the Feeds module?

Import or aggregate data as nodes, users, taxonomy terms or simple database records.

One-off imports and periodic aggregation of content
Import or aggregate RSS/Atom feeds
Import or aggregate CSV files
Import or aggregate OPML files
PubSubHubbub support
Create nodes, users, taxonomy terms or simple database records from import
Extensible to import any other kind of content
Granular mapping of input elements to Drupal content elements
Exportable configurations
Batched import for large files

Fetch feed from a given URL


Nice applications of the Rank–nullity theorem

Question: I'm looking for nice applications of Rank–nullity theorem to show to my students for a 45 minutes class. I'm going to begin this class showing the demonstration of the theorem and I don't know what to do in rest of the time, any suggestions?

Let $V$ and $W$ be finite-dimensional vector spaces and let $T:V\to W$ be a linear transformation from $V$ into $W$. Then:
$$\dim V=\dim \text{Im}(T)+\dim\ker(T)$$

Remark: The only nice applications I remember is the fact the row and column ranks of a matrix are equal and a linear transformation $T:V\to W$ with $\dim V=\dim W$ is injective iff it's surjective.
Comment: You could perhaps show an example calculation or two using actual numbers and matrices. In fact, if you pick the numbers nicely, you could potentially give the argument of the proof only in a special case (say, $V=W=\mathbb{R}^{3}$ and $T$ has some judiciously chosen matrix in the standard basis so that all the gory details appear) and leave the generalization to the students as an exercise.
Comment: @WillR I must prove the theorem in its full generalization. The problem is I don't know what to do afterwards.
Comment: Perhaps try this https://en.wikipedia.org/wiki/Fundamental_theorem_of_linear_algebra ?
Answer: A bit too long for a comment ...
Your memory is faulty.  It's easy to prove that $T$ is injective iff $\ker(T)=\{0\}$.
Now the theorem reveals that if $\dim(V)>\dim(W)$ the map $T$ can't be injective since the dimension of the image of $T$ is at most the dimension of $W$.
OTOH if $\dim(V)<\dim(W)$ then $T$ can't be surjective for the same reason.
Now furthermore if the dimensions are equal your statement is right.
Comment: The theorem demands $f$ to be linear, in your case we must have $f(x)=ax$, which is pretty boring.
Comment: Thank you. You're right, the dimensions must be equal. Do you think I can use this theorem in my calculus classes with functions $f:\mathbb R\to \mathbb R$, since $\mathbb R$ is itself a vector space?
Comment: It's true, you're right!


How to compare the variance from published summary statistics with own data?

Question: I have compiled a very small set of summary data from the literature, and I wish to compare the variances between aspects of the literature-based data, and to some of my own data. The summary data includes the mean, standard deviation and sample size.
In earlier tests, I compared the variances of one continuous dependent variable among 2 age classes and 2 years. I used the Fligner-Killeen test since I have extreme values in the data and I'm not sure it was normal (can't remember now!). I followed up this broad test with pairwise multiple comparisons using F-tests in R var.test(x~age)
What would be a good way to compare the variances of the literature-sourced data? I've searched through the help files in R, and came up with this method, which I believe generates a random set of numbers with the specified sample size, mean and standard deviation, and then I used those datasets to conduct the F-test:
herring_year1<-rnorm(10,mean=10.5,sd=0.51)
herring_year2<-rnorm(15,mean=10.9,sd=0.43)
var.test(herring_year1,herring_year2)

Would this be a good approach? If not, can you suggest what might be?
If so, how can I then compare these variances to my own data set? Should I essentially use the summary data from my own set in the same manner? Or generate the random data for the summary data from the literature and stick it in a file to compare to my raw data?
Also, do I need a broad test initially, or can I go straight to the pairwise comparisons?
Comment: Thanks Chris! Yes, that is interesting, and very helpful.
Comment: You might find this [discussion](http://core.ecu.edu/psyc/wuenschk/stathelp/Pairwise.htm) about broad tests versus pairwise comparisons interesting. I'd be cautious about applying it to this problem since you're lacking the original data and don't have any distribution assumptions to go with, but it is something worth keeping in mind in general.
Answer: I don't think the Fligner-Killeen test (nor the Brown-Forsythe) test is appropriate since you don't know the median in the published data (if you do have it and simply didn't mention it then never mind).
I wouldn't suggest simulation of the data either unless you're sure the samples follow a specific distribution.
Since you don't have the median and the distribution is uncertain Levene's Test would be appropriate. I've never ran the test in R before, but there is a description of it here. If you're having a lot of trouble getting the R code to work though I'd just compute it by hand given the summary statistics from the literature and your own data. As the wikipedia indicates that statistic is F distributed so you'll need a table if you don't have one.
Comment: If you had the published study's data there are tests you could run, if you had the median there are tests you can run. I'm having a hard time thinking of a nonparametric procedure that would work with what you have from the published study. Is it not possible to ask the original researcher for a copy of their data set? If I think of something I'll post it.
Comment: Thanks @Chris! Very helpful response and links. You're right, I don't have the median of the data, nor do I know the distribution. I'm guessing then from your answer, that simple pairwise F-tests on the summary stats (by hand) wouldn't work?
Comment: Thanks again @Chris. I'll check for the original data set...good idea!


Domain network not recognized after replacing switches (Domain Controller or Switch)

Question: I had difficulties with our network speed, we still had 100MBit switches so we made a change and replaced our 3 switches with some nice new ones (1 central 16 port going to 2 switches with 24 ports). I have decided to buy the HP 1920-16G and HP 1920-24G. Right now we plugged the switches in and things worked out of the box. We have 2 servers, one being the Domain Controller (Name: Alpha, IP: 192.168.100.10) and the SQL Server (Name: Delta, IP: 192.168.100.11).
Even though the computers are reached and my Domain Controller gives the users the DHCP lease the network is not recognized as a domain network anymore.
In Network and sharing this used to be displayed (Domain Controller still has it):

Now it is some unidentified network:

The users can log in but they can not automatically log onto network shares. Also authentication in the SQL (Windows authentication) does not work anymore and/or users can not change their user passwords by hitting ctrl+alt+del and select "change password".
This all makes me believe that either something in the mananaged switches is limiting a protocol of the domain controller or that during my reboot of the domain controller (changed things in the patch panel and had to disconnect power of server) some services where not started?
I am quite stranded here having 20 people unable to work properly right now, any Ideas?
Comment: Have you looked if the network connection is stable (using netio.exe **UDP** test between one client and the server) how high is the packet loss? You may need to shutdown firewalls for that test.
Comment: Pinging with 65500 bytes is responding under 1ms, never any packages lost. NetIo -u alpha gives me back that the speed of 1k bytes packets is 86,3 MByte/s and of 32k byte packages 57.8 MByte/s.
Comment: So, 0% packet loss to both alpha and delta. No firewalls shutdown for this.
Comment: can you temporarily got back to the old swithes?
Comment: What are the clients using for DNS? What is the DC using for DNS? Have you checked the AD related services on the DC to see if they're started? Have you checked the Event logs on the DC? Start troubleshooting by checking the basics.
Comment: I am not able to go back to the old switches unfortunately. I did however figure out that only the windows 8 computers are affected. Windows 7, XP and older see no issue whatsoever.
Answer: Where are the DCs connected - one on each switch, or both on one switch?  Where are clients connected?  Wondering about how traffic is getting across those switches - trunk/bridge or routed?
Comment: The Windows 8 clients don't work no matter how they are integrated in the network. I have a central switch with the DC and a SQL server. From there are two other switches that have most of the clients. Why are only win 8 clients affected?


Commutator Subgroup and the Largest Abelian Quotient

Question: Good day. I'm not too sure how I should go about asking my question, so if it is in anyway confusing, feel free to edit it.
In my Group Theory course we defined and showed a few properties of the commutator subgroup $[G,G]$ of a group $G$. And then we stated and proved a lemma in lecture that I'm having some difficulty wrapping my head around. I'll state it here for clarity.
Lemma
a) The commutator subgroup $[G,G]$ of $G$ is a normal subgroup of $G$.
b) The quotient group $G / [G,G]$ is the largest abelian quotient of G in the sense that every homomorphism $\varphi : G \to A$ where $A$ is an an abelian group, induces a unique homomorphism $\bar \varphi : G/[G,G] \to A$ so that $\varphi =\bar \varphi \circ \pi$ where $\pi : G \to G/[G,G]$ is the quotient homomorphism.
Now, it's not the proof of this lemma that I'm having trouble with, it's the italicized text that is messing with me. I completely understand what it is that the italicized text is saying, I'm just not too sure why it is that the property gives us the "largeness" that is claimed. I can see that the above forces $G$ to "pass through" $G/[G,G]$ before it "reaches" $A$ (I apologize for the casual terminology), so I can sort of see why $G/[G,G]$ should be the largest quotient, in a non-rigorous sort of way.
Overall I'm very confused. Perhaps I'm missing something very simple. Any help or nudges in the right direction would be much appreciated.
As a side note I did try a search on Google and here on Stack Exchange and couldn't find anything that answered my question. So if I missed something obvious, then my apologies. Thank you in advance.
Answer: Remember that the larger $N\lhd G$ is $G$ is, the smaller $G/N$ will be. Now suppose $N\lhd G$ and $G/N$ is abelian. This means that $abN=baN$ for any $a,b\in G$. This translates in $a^{-1}b^{-1}abN=N$. This means $N$ contains all commutators, and hence contains $[G,G]$. Thus, whenever $N$ is normal and the quotient $G/N$ is abelian $[G,G]\leq N$. Thus $G/[G,G]$ is as big as $G/N$ gets whenever $N$ is normal and $G/N$ is abelian.
Comment: Thank you. That really helped actually. Correct me if I'm wrong, but essentially the line of reasoning is (supposing N is normal): G/N abelian implies N contains the commutator subgroup, and since the commutator subgroup is normal and has order less than or equal to the order of N, G/[G,G] must have order that is bigger than or equal to G/N, hence we get that G/[G,G] is the largest abelian quotient?
Comment: @CanadianStudent Aha.
Comment: Well thank you very much! I figured there was something simple I was missing.


Windows OS Details with C++

Question: This seems to be a remarkably hard thing to do for what seems a relatively common thing. I want to know precisely the version of Windows (i.e. Windows 7 - Professional) and if it's 32 or 64 bit. I also need it to work with future versions of Windows (i.e. 10). How would I go about doing this with C++?
Comment: possible duplicate of [Check Windows version](http://stackoverflow.com/questions/1963992/check-windows-version)
Answer: You can use GetVersion or GetVersionEx. You can also use the newish version helper functions. Both of these methods mean you will need to write your own logic and supply your own strings based on version numbers. See an implementation of this on this page, you might be able to copy-paste: https://msdn.microsoft.com/en-us/library/ms724429(VS.85).aspx
Even though GetVersion* are considered deprecated, there is no chance of MS actually removing these. Far too many applications rely on them already. My guess is they are discouraging developers from using them, because they have been so misunderstood and misused, they are trying to use a different model for querying OS version information. I would feel totally safe using them though if this is what you need.
To really get a human-readable OS Product description from the OS itself, you can use WMI. Here is an example from MSDN.
Comment: ... be aware that windows often lies about the version for compatibility reasons.
Comment: Thanks but GetVersionEx is deprecated and the VersionHelper functions don't have way to determine if it's 32 or 64 bit, or if it's home, professional, etc. Also, it seems to just have IsWindows7OrGreater() BOOL style functions.

Windows OS Details with C++


How do I solve this normal line problem?

Question: So I got this problem I've been struggling with.

''Determine the points of intersection between the parabola $x^2$ and its normal at the point $(a, a^2)$''.

And here is my try to solve it.enter image description here
As you can see I cant simplify the square root expression so I must have done something wrong.
Comment: Please use the [mathjax basic tutorial](https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference) and enhance your question.
Comment: Better idea: transcribe it into $\LaTeX$. It's the courteous thing to do.
Comment: Would you mind turning the picture anti-clockwise by 90 degrees? That way, it's easier to read. Thanks.
Comment: I'm sorry I'm pretty new to this forum and I didn't know how to do it, thanks for letting me know I sure will.
Comment: I rotated the image, sorry my bad.
Answer: If $a=0$ the normal line is the $y$-axis, hence the unique intersection point is $(0,0)$.
For $a\ne 0$ the equation of the normal line at $(a,a^2)$ is $y=-\frac{1}{2a} x + (a^2+\frac 12)$,  hence the $x$-coordinate of the intersection points of the line with the parabola are the solutions of
$$x^2+\frac{1}{2a} x - (a^2+\frac 12)=0$$
One solution is obviously $x=a$ and using polynomial division we obtain:
$$x^2+\frac{1}{2a} x - (a^2+\frac 12)=(x-a)(x+a +\frac1{2a})$$
The intersection points are then $(a,a^2)$ and $(-(a +\frac1{2a}), (a +\frac1{2a})^2)$.
Comment: Ohhhhh so you came up with the other solution by doing x^2+1/2x-...=(x-a)q(x) where q(x) is the solution and then you just divided the left side with (x-a) and you used polynomial division to get the q(x), correct?
Comment: I just did it, brilliant, why didn't I thought of using polynomial division. One question, why didn't square completion work like I tried to do? Or does it work, because i couldn't simplify the square root expression if you take a look at the image.
Comment: @Muhashka, for some misterious reason I cannot open the link with the picture...
Comment: Strange, it works for me, but what I did is just -1/(2a)x-a^2+1/2=x^2 and solved for x through square completion, or the PQ-formula, same thing. And I got an expression in that square root that I couldn't simplify, but its okay, now when you showed me it will be easier to remember the solutions to these type of questions to just do polynomial division and not square completion. Thanks!
Comment: Maybe you miscomputed, under the squere root in the PQ-formula you get $\frac{1}{4a^2}+4a^2+2= (2a+\frac 1{2a})^2$.
Comment: Shouldnt it be $(x+\frac{1}{4a})^2=\frac{1}{16a^2}+\frac{1}{2}+a^2$? Or am i in the completely wrong here.
Comment: It is correct, and the RHS is $(a+ \frac{1}{4a})^2$.
Comment: Ohhh hahah that's amazing, didn't see that. But why is there no x? That's where I get confused.
Comment: Nvm I see it now, thanks a lot man, I really appreciate it.


Diminuir script ou trocar por um código em PHP, ajuda

Question: Bom dia, se não for incomodar, necessito de ajuda com um script que fiz em java.

Bom, deixa eu explicar um pouco dessa bagunça, é um Script muito simples, ele recebe a Hora atual do computador e pega apenas os segundos, após isso ele gera uma outra variável pega os segundo mais uma vez e adiciona mais 10s e grava em uma Array (Tive que fazer isso, porque sempre que atualizava ele pegava um novo valor em vez de manter o antigo).
Depois ele faz uma subtração do valor da Array com os segundos atuais para que seja gerada uma mensagem quando o tempo chegar ao limite que no caso é de 5s.
Outra função é que se caso o usuário clique em um dos botões do site ele gere uma nova contagem do tempo e adicione mais 5s atualizando o array.
Agora vão me perguntar o porque dessa bagunça, vamos lá, eu preciso de um sistema de TimeOut, para que o usuário tenha um tempo x  para estar no site se caso estiver ocioso e que por causa dessa inatividade ele deslogue, mas se caso ele entrar em atividade dentro do tempo x o site gere os mesmos x tempo para que o usuário não seja deslogado.
Preciso diminuir esse código, simplificar essa bagunça ou troca-lo por um script em PHP, tentei fazer em PHP mas começou a ficar complexo de mais pra mim, não achei certas funcionalidades, foi um fracasso!
Espero que entendam minha dúvida, agradeço desde já, obrigado!
Comment: Bem complicado. Em vez de tentar explicar seu código, acho que seria melhor vc explicar o que quer fazer, com clareza, assim poderíamos propor um código melhor e mais simples. Não entendi o porquê de pegar a hora atual do computador, se, pelo que entendi, basta ver se o cara fica 5s inativo. Pra isso a hora do computador não influi em nada.
Comment: Então seria melhor fazer uma contagem regressiva? Falando dessa forma me sinto meio dislexo, qual seria a melhor maneira de criar um código em que o usuário fique um tempo x ocioso no site e caso ele não clique em nenhum botão seja deslogado?
Comment: Depende o que vc considerar ocioso. Fazer scroll, por exemplo, sem clicar em nada, o cara está ocioso?
Comment: Deixei minha resposta mais equilibrada, não acho que seria ocioso ao estar ativo olhando algo na página, mas não sei como utilizar isso em códigos, poderia me ajudar?
Answer: Use 2 escutadores e chame a função para deslogar desta forma:

deslogado = false;
function desloga(){
   temporiza = setTimeout(function(){
      alert("Deslogado por inatividade");
      deslogado = true;
   }, 5000);
}

document.body.onmousedown = function(){
   clearTimeout(temporiza);
   if(!deslogado){
      desloga();
   }
}

document.body.onscroll = function(){
   clearTimeout(temporiza);
   if(!deslogado){
      desloga();
   }
}

window.onload = desloga;
Clique na página ou faça scroll para não ser deslogado em 5 segundos

Comment: @netoschneider Em php vc não vai conseguir fazer isso, pq o php roda no servidor. O que vc pode fazer é guardar uma SESSION com o horário que o cara logou e depois enviar um ajax pra verificar o tempo de inatividade. Mas isso é outra questão. Não deixe de marcar a resposta com ✔. Se quiser depois eu ajudo com a parte do PHP.
Comment: Muito mais prático e sem muita redundância, muito obrigado pela clareza e paciência em me dar uma aula de lógica, estou começando ADS e ainda estou meio perdido em certos aspectos da programação, sabe me dizer se esse código fica tão seguro em javascript quanto em PHP em relação a compatibilidade?
Comment: @netoschneider Exclui a resposta que vc postou tb porque é contra o regulamento do site postar edições da pergunta ou comentários no campo de resposta. Abs!
Comment: Tudo bem, já apaguei, muito obrigado pelas informações, só por dar essa dica da área de PHP e simplificar meu código com essas dicas importantes já me ajudou de mais até, obrigado pelo apoio e boa noite!


List ocurrences in column - SQL

Question: I have a table column that has integers, for example:
2
2
1
2
3
1
3

How do I get the values that occur in this column? In this case the results should be:
1
2
3

I know there's something is Postgre called width_bucket but I couldn't make that work me and I'm not even sure if that is supposed to solve my problem.
Thank you in advance.
Comment: Um, not sure I'm understanding your question -- `select distinct ... order by...` would achieve your results...
Answer: You can use distinct keyword or group by clause with the order by:
select distinct col from tbl order by col
select col from tbl group by col order by col

Comment: @MarcusAdams: Did know about it in MySQL (however [relying on implicit order seems to be  deprecated since 5.6](http://dev.mysql.com/doc/refman/5.6/en/select.html) ), but what about Postgres?
Answer: Based upon your question, it is a simple select distinct and then an order by
SELECT distinct(Column_Name)
FROM Table_name
ORDER BY Column_Name DESC

Or
SELECT distinct(Column_Name)
FROM Table_name
ORDER BY Column_Name

Depending on the Sort order that you want
Comment: This sorts `Column_Name` in descending order, while OP example has an ascending order.
Comment: Good catch, i have added the other option based upon which order the OP wants
Comment: You can omit `ASC`, it's a default option.
Comment: You are correct, it is the default or can be explicitly included, I removed it for the default option

List ocurrences in column - SQL


Infinite speed of propagation of the heat equation

Question: Consider the heat equation $u_t = \Delta u$ on $\mathbb{R}^n$ with initial data $u(0, x) = f(x)$. Suppose $f$ is smooth and compactly supported. Do we necessarily have that $u$ has non-compact support for all $t > 0$?
What about the same question for the Schrödinger equation $u_t = i\Delta u$ with smooth compactly supported $f$?
Answer: The solution $u(t,x)$ of the heat equation is analytic in $x$ as a function of $x$ for any $t>0$, so it cannot have compact support. This is independent of the smoothies or size of the initial data.
For the Schrödinger equation, the same is true if the initial data decays fast enough at $\infty$, in particular,if it has compact support.


Logistic function - Derivative missing ln(b)

Question: I am a bit stuck in a specific step - I could read numerous posts on it but I can't figure out how to solve the following stage of the derivative process (first part of the logistic cost function):
$$\frac{∂}{∂θj}[log(hθ(xi))]=\frac{1}{hθ(xi)}*\frac{∂}{∂θj}hθ(xi)$$
The same applies for second part : $$\frac{∂}{∂θj}[log(1-hθ(xi))]=\frac{1}{1-hθ(xi)}*\frac{∂}{∂θj}1-hθ(xi)$$
If I am not  wrong, the rule for differentiating $$log_{(b)}(u)$$ (with u = sigmoid(z) which is a function) should be $$\frac{1}{u*ln(b)} * \frac{du}{dx}$$
Why do we have here only $$\frac{1}{u}\frac{du}{dx}$$ as if we were using $$ln(u)$$ instead of $$Log_{10}(u)$$
Why ln(b) is missing if we respect the rule above ?
thank you very much for your help !
Answer: In your "logistic cost function", the logarithm $\log$ means the natural logarithm. In other words, $\log(x)=\ln(x)$ in your context.
So for instance, by the chain rule, you have
$$
\frac{d}{dx}\log(f(x))=\frac{f'(x)}{f(x)}\;.
$$
Comment: Thank you very much. Why not using ln then.... It is logical to me now :)


How to update binding source for checkbox from template?

Question: I have a template (TextBlock + CheckBox) for items in LonglistSelector but I wasn't able to figure out how to refresh binding. The CheckBox is bound to a boolean property. Only way that worked so far was to navigate to same XAML page with different parameter however this "solution" is unusable.
I've found some examples how to use UpdateSource() with TextBox but none with CheckBox from template.
Here is my CheckBox from teplate. Many things are probably useless, I tried everything I found. Binding is working but it does not refresh so I have to navigate to another page for example and then it is refreshed.
<CheckBox BorderThickness="2"
                          VerticalAlignment="Center"
                          x:Name="TemplateCheckBox"
                          IsChecked="{Binding IsDone, UpdateSourceTrigger=Explicit, Mode=TwoWay}"
                          Checked="TemplateCheckBox_Checked"
                          Unchecked="TemplateCheckBox_Checked"
                          />

EDIT: I found easy way how to update items in LonglistSelector. Just create another empty List set it as a ItemsSource and just afterwards set original list as ItemsSource.
Answer: <CheckBox BorderThickness="2" **Loaded="OnLoaded"**
                          VerticalAlignment="Center"
                          x:Name="TemplateCheckBox"
                          IsChecked="{Binding IsDone, UpdateSourceTrigger=Explicit, Mode=TwoWay}"
                          Checked="TemplateCheckBox_Checked"
                          Unchecked="TemplateCheckBox_Checked"
                          />

private List<CheckBox> chkList=new List<CheckBox>();

private void OnLoaded(object sender,EventArgs e)
{
   if(!chkList.Contians(sender as CheckBox))
   {
     chkList.Add(sender as CheckBox);
   }
}

private void UpdateSource()
{
   foreach(CheckBox chk in chkList)
   {
     chk.GetBindingExpression(CheckBox.IsChekcedProperty).UpdateSource();
   }
}

Comment: Thanks, I was hoping that my problem would be finally solved but it does not work. It add all CheckBoxes to the list and go through them but it does not see that they were changed. "Refreshing" via my navigation solution still works so there shouldn't be problem somewhere else in code.


Qual a forma correta de utilizar um pacote instalado pelo npm?

Question: Para explicar minha pergunta vou utilizar como exemplo o jquery.
Instalei o jquery a partir do npm (npm install jquery). Então o npm criou a pasta node_modules\jquery\dist onde está o arquivo do jquery que preciso (jquery.js).
Para utilizar este arquivo devo apontar para esta pasta do node_modules?
Ou seja se a pasta do meu projeto está no mesmo nível da pasta node_modules devo fazer isso para utiliza meu js?:

Comment: Se ele estiver dentro da pasta `public` criada no `express`, por exemplo, não vai funcionar não.
Comment: Minha duvida não é se funciona ou não,mas sim se esta é a forma correta de usar um pacote vindo do npm


Dynamically change page content between divs?

Question: I am looking for a way to change a single pages content instead of redirecting a user to a new page using jQuery or anything similar. I am quite new to scripting, so help would be greatly appreciated.
I've gone ahead and created a quick mock up in jsFiddle that demonstrates the basic layout of the site and the content that I'd like to change when a user requests a different page:
http://jsfiddle.net/Syrne/8pMnR/
CODE:
HTML:

Home

Link 1

Link 2

   Drop

   Menu

Option 1

Option 2

Option 3

MAIN CONTENT

This content should change dynamically when a user follows a page link.

© 2013

CSS:
@import url('http://twitter.github.com/bootstrap/assets/css/bootstrap.css');
 .dropdown-submenu {
    position:relative;
}
.dropdown-submenu>.dropdown-menu {
    top:0;
    left:100%;
    margin-top:-6px;
    margin-left:-1px;
    -webkit-border-radius:0 6px 6px 6px;
    -moz-border-radius:0 6px 6px 6px;
    border-radius:0 6px 6px 6px;
}
.dropdown-submenu:hover>.dropdown-menu {
    display:block;
}
.dropdown-submenu>a:after {
    display:block;
    content:" ";
    float:right;
    width:0;
    height:0;
    border-color:transparent;
    border-style:solid;
    border-width:5px 0 5px 5px;
    border-left-color:#cccccc;
    margin-top:5px;
    margin-right:-10px;
}
.dropdown-submenu:hover>a:after {
    border-left-color:#ffffff;
}
.dropdown-submenu.pull-left {
    float:none;
}
.dropdown-submenu.pull-left>.dropdown-menu {
    left:-100%;
    margin-left:10px;
    -webkit-border-radius:6px 0 6px 6px;
    -moz-border-radius:6px 0 6px 6px;
    border-radius:6px 0 6px 6px;
}
#main_page {
    text-align: center;
}

.footer {
    text-align: center;
}

.navbar .nav,
.navbar .nav > li {
  float:none;
  display:inline-block;

  vertical-align: top;
}

#navWrap {
    text-align: center;
}
}

As you can see, the middle area of the site is where the action should be happening. the rest (nav bar and footer) should stay fixed.
For reference, I've pulled up this guide that utilizes jQuery, "Modernizr" and HTML5's history API in order to preserve unique URL's for each change of content; this is exactly what I want to do, but I cannot seem to wrap my head around how to make it work for my current design. Any help is greatly appreciated, even a light hint to help me on my way. I am very new to web design/development and have a LOT to learn.
Answer: All you need is AJAX. The basic procedure may be:

Attach a click event on navigation links.
When user clicks the link, prevent default action and get what is in href.
Use AJAX to get contents from that link.
Update your main content div with new content.

EG:
$('nav li').on('click', 'a', function(e){ //step 1
  e.preventDefault(); //prevent default action, step2
  var url = $(this).attr('href'); //get the url, step 2

  $.ajax({ //step 3
    url: url,
    //your other options
    success: function(response){ //on success
      $('YOUR MAIN DIV').html(response); //update your div, step 4
    }
  });
});

Edit Based on Comment
There is a problem with your implementation. You are targeting $('#link1') which doesn't exists. Change the links of your navigations like this:

Home

Link 1

Link 2
   ...

Then use the following code.
$(document).ready(function(){
    $("ul.nav li a").click(function(e){
        e.preventDefault();
        var url = $(this).attr('href'); //get the link you want to load data from
        $.ajax({
         type: 'GET',
         url: url,
         success: function(data) {
            $("#main_page").html(data);
        }
       });
     });
  });

Or, if you want your current implementation to work provide id to your anchor tag like this

Also be sure to wrap your script inside $(document).ready(function(){})
Comment: Thank you for the response, as of right now I am trying this: `$("#link1").click(function(e) {
    e.preventDefault();
 $.ajax({
   type: 'GET',
   url: 'external.html',
   success: function(data) {
  $("#main_page").html(data);
  }
 });
});`

But it does not seem to work, no content is filled. Any ideas? Where exactly should my externally referenced html file be so it can be linked? Sorry for the nooby-ness. Still learning!
Comment: Thank you for the update, I understand the process now. However, I am still having trouble and after some frustration I have found the problem to be my AJAX 'get' call. For example, let's say I have another html file ("other.html") that I want to load the content of. I would use this: `$.ajax({ url: "other.html", type: "get", success: function(data) { $(#main_page).html(data); } });` In theory, this should work, but no data is loaded. The AJAX call never reaches "success". I made sure `$(document).ready(function(){})` is being used. I am not sure what is causing the issue here.
Comment: My apologies! The external html file wasn't being referenced because I wasn't running my code on a web server, so it could never be located.
Answer: I believe you should check jQuery Mobile,it will handle AJAX loaded pages and preserving the URL
http://jquerymobile.com/demos/1.2.0/docs/pages/page-navmodel.html


combinatorics: sum of product of integer compositions

Question: I am trying to solve a problem from Stanley's book, it says:
Fix $k,n \in \mathbb{P}$. Show that:
\begin{align}
\sum a_1 a_2 \cdots a_k = \binom{n+k-1}{2k-1}
\end{align}
where the sum ranges over all compositions $(a_1 , a_2 , \ldots , a_k)$ of $n$ into $k$ parts.
I am trying to reason like this:
we need to find the coefficient $c_n = \sum a_1 a_2 \cdots a_k$ from this generating function --
\begin{align}
\sum_n c_n x^n &= \sum_n \sum a_1 a_2 \cdots a_k x^n \\
&= \sum_n \sum a_1 a_2 \cdots a_k x^{a_1 + a_2 + \cdots + a_k}\\
&= \sum_n \sum a_1x^{a_1} a_2x^{a_2} \cdots a_kx^{a_k}
\end{align}
after that, I have no clue, how do I solve this ?
moreover, what is the range in the inner sum ?

If we consider Mark Riedel's answer, and assume $n=4$, $k=2$; then the sum will be
\begin{align}
\sum (z + 2z^2)^2 = z^2 + 4z^3 + 4z^4
\end{align}
On the other hand the compositions will be $(1,3), (2,2), (3,1)$, therefore the above sum will be counted as:
\begin{align}
(1.3)z^{1+3} + (2.2)z^{2+2} + (3.1)z^{3+1} &= 1z^1.3z^3 + 2z^2.2z^2 + 3z^3.1z^1\\
&= 3z^4 + 4z^4 + 3z^4 = 10z^4
\end{align}
what's going on? what am I missing?
Answer: Compositions of $n$ into $k$ parts can be represented as a string of $n$ stars and $k-1$ bars. The $k-1$ bars break the stars into $k$ groups, and the number of stars in the $i^{th}$ group represents $a_i$.
For each of these compositions, we are adding $a_1a_2\dots a_k$. This represents the number of ways to choose one star from each of the $k$ blocks, and color it red. For example, with $n=6, k=3$, and the composition $\star\star|\star\star\star|\star$, the number of ways to color one star in each group red like $\star\color{red}\star|\star\color{red}\star\star|\color{red}\star$ would be $2\cdot 3\cdot 1$.
However, there is a more direct way to count these arrangements of black  stars, red stars, and bars. If you ignore the black stars, then what remains is an alternating pattern of red stars and bars; in the example, this is $\color{red}\star|\color{red}\star|\color{red}\star$. There are $k+(k-1)=2k-1$ symbols which are red stars or bars, and $n+k-1$ symbols total. Therefore, there are $\binom{n+k-1}{2k-1}$ arrangements, since an arrangement is specified by choosing which of the $2k-1$ symbols are red stars or bars, and then assigning these in an alternating fashion.
Answer: We have using generating functions the closed form
$$[z^n](z+2z^2+3z^3+\cdots)^k
= [z^n] \frac{z^k}{(1-z)^{2k}}
\\ = [z^{n-k}] \frac{1}{(1-z)^{2k}}.$$
Using the Newton binomial this becomes
$${n-k+2k-1\choose 2k-1} = {n+k-1\choose 2k-1}.$$
Comment: I do not understand at all, how does $(z + 2z^2 + \cdots)^k$ equate to $\sum a_1x^{a_1} a_2x^{a_2} \cdots$? could you please explain a little bit more ?
Comment: If you write down these $k$ sums say making a list then the product consists of choosing one term from the first sum one from the second and so on up to the $k$th term ... in doing so the exponent accumulates the sum and the coefficient the product of the parts. At the end extract the contributions where the parts sum to $n.$
Comment: I see, let's try a concrete example, let's say $n = 4$ and $k=2$, then we will have these compositions $(1,3), (2,2), (3,1)$. So, in this case the sum will be $1z^1.3z^3 + 2z^2.2z^2 + 3z^3.1z^1$, but if I take $(z + 2z^2)(z + 2z^2)$, it is not equal to $1z^1.3z^3 + 2z^2.2z^2 + 3z^3.1z^1$, why ? by equal, I mean a similar polynomial form.
Comment: The generating function includes many more terms than what sums to $n.$ That's why we extract the coefficient on $[z^n]$ with the coefficient extraction operator.
Comment: so does it mean that $\sum_n z^2 + 4z^3 + 4z^4$ must be equal to $10z^4$ for some combination of $n$ such $z^2 + 4z^3 + 4z^4$ terms? Don't you think it's a bit far fetched? then how does $z^3$ term vanish? because all these terms supposed to be positive.
Answer: This is  a supplement to @MarkoRiedel's answer which should clarify OPs question. At first we look at the compositions of $n=4$ which consists of two terms ($k=2$) and look at the corresponding terms of the generating function.

\begin{array}{crl}
1+3\qquad&\qquad  x^1\cdot3x^3=&3x^4\\
2+2\qquad&\qquad2 x^2\cdot 2 x^2=&4x^4\\
1+3\qquad&\qquad3 x^3\cdot x^1=&3x^4\\
\end{array}

When looking at the three compositions above, we see the first summand is either $1$ or $2$ while the second summand is either $3$ or $2$. In general the first summand is a positive integer encoded as generating function
\begin{align*}
(x^1+2x^2+3x^3+\cdots)=\sum_{n=1}^\infty  n x^n=x\frac{d}{dx}\left(\frac{1}{1-x}\right)=\frac{x}{(1-x)^2}
\end{align*}
The same holds for all the other summands of a composition. Since we want to multiply the summands and $k=2$  we have to consider
\begin{align*}
(x^1+2x^2+3x^3+\cdots)^2=\frac{x^2}{(1-x)^4}\tag{1}
\end{align*}
We use the coefficient of operator $[x^n]$ to denote the coefficient of $x^n$.

The number of  compositions of $n=4$ is according to (1)
  \begin{align*}
[x^4](x^1+2x^2+3x^3+\cdots)^2&=[x^4](x^1+2x^2+3x^3)^2\tag{2}\\
&=([x^3]+2[x^2]+3[x^1])(x^1+2x^2+3x^3)\tag{3}\\
&=3+2\cdot 2+3\\
&=\color{blue}{10}
\end{align*}
Comment:

In (2) we see it is sufficient to consider terms with exponents up to $3$, since higher exponents do not contribute to $x^4$.
In (3) we use the linearity of the coefficient of operator and apply the rule $$[x^p]x^qA(x)=[x^{p-q}]A(x)$$

On the other hand we obtain with $n=4$ and $k=2$
  \begin{align*}
\binom{n+k-1}{2k-1}=\binom{5}{3}=\color{blue}{10}
\end{align*}
Comment: Thanks for helping to explain this to the OP. (+1). The problem at this [MSE link](http://math.stackexchange.com/questions/389099/) required the use of complex residues. I wonder if it can be done  using formal power series methods only (coefficient extraction operator).
Comment: @MarkoRiedel: While looking (admittedly somewhat later than proposed) at your referred MSE link I detected I've already answered it at *[this MSE link](http://math.stackexchange.com/questions/1874816/how-to-show-sum-k-0n-binomnkk-frac12k-2n/1875016#1875016)* :-)


Docker sdk, proof if lable name exists

Question: I've got the current situation:
import docker
import platform

java-base = False
client = docker.from_env()

images = client.images.list(filters={"label":"architecture"
+platform.machine()})

for image in images:
    if "java-base" in image:
        java-base = True
if java-base == False:
    #build this image

The problem is now, that it seems I can not access the data object in this fashion. I've tried some ways but can not get to the bottom of this.
Somebody an Idea how to access this object:

<Image: 'Tag1:Version', 'Tag2:Version'>

Thanks in advance
Answer: If you use dir(image) you will get the structure of that object like next:
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'attrs', 'client', 'collection', 'history', 'id', 'id_attribute', 'labels', 'reload', 'save', 'short_id', 'tag', 'tags']

Here, tags is what you needed like next:
test.py:
import docker

client = docker.from_env()
images = client.images.list()

for image in images:
    print("===")
    print(dir(image))
    print(image)  # this is what you get
    print(image.tags) # use this instead
    print(type(image.tags))
    for tag in image.tags:
        print(tag)
    print("===")

execution:
===
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'attrs', 'client', 'collection', 'history', 'id', 'id_attribute', 'labels', 'reload', 'save', 'short_id', 'tag', 'tags']
<Image: 'docker.elastic.co/elasticsearch/elasticsearch-platinum:6.1.4'>
['docker.elastic.co/elasticsearch/elasticsearch-platinum:6.1.4']
<class 'list'>
docker.elastic.co/elasticsearch/elasticsearch-platinum:6.1.4
===
===
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'attrs', 'client', 'collection', 'history', 'id', 'id_attribute', 'labels', 'reload', 'save', 'short_id', 'tag', 'tags']
<Image: 'ubuntu:17.04', 'ubuntu:zesty'>
['ubuntu:17.04', 'ubuntu:zesty']
<class 'list'>
ubuntu:17.04
ubuntu:zesty
===

You could see the tags will get a python list of image name, so you could directly access that list.

Docker sdk, proof if lable name exists


Tensorflow detection API SsdFeatureExtractor' object has no attribute 'override_base_feature_extractor_hyperparams'

Question: When I use ssd_mobilenet_v1_coco_11_06_2017 model to train myself data set,
I use google TensorFlow detection API to train that
There are some problems will arise.
my os: ubuntu 16.04

./train.sh
  Traceback (most recent call last):   File "../../train.py", line 167, in
      tf.app.run()   File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py",
  line 126, in run
      _sys.exit(main(argv))   File "../../train.py", line 163, in main
      worker_job_name, is_chief, FLAGS.train_dir)   File "/home/feng/project/models/research/object_detection/trainer.py", line
  240, in train
      detection_model = create_model_fn()   File "/home/feng/project/models/research/object_detection/builders/model_builder.py",
  line 98, in build
      add_background_class)   File "/home/feng/project/models/research/object_detection/builders/model_builder.py",
  line 166, in _build_ssd_model
      is_training=is_training)   File "/home/feng/project/models/research/object_detection/builders/model_builder.py",
  line 129, in _build_ssd_feature_extractor
  feature_extractor_config.override_base_feature_extractor_hyperparams)
AttributeError: 'SsdFeatureExtractor' object has no attribute 'override_base_feature_extractor_hyperparams'

What kind of question is that?
Answer: I reccomend you check out the below issue reported on the TensorFlow Object Detection API Git:
https://github.com/tensorflow/models/issues/4121
Answer: I ran into this recently after upgrading my TensorFlow Object Detection API and fixed it by refreshing the protobuf bindings.
This kind of error message can happen why you have the wrong protobuf bindings installed, since the new bindings may be incompatible with the old version bindings that are still being referenced. You can fix this by downloading the newest version of protobuf and compiling the new bindings.
To do this follow the instructions for "Manual protobuf-compiler installation and usage" found here: Section Link, but to future proof this against a future broken link, I will note that they currently instruct you to:

Make tensorflow/models/research the current directory
Download and install the latest version of protoc (aka protobuf)

wget -O protobuf.ziP
https://github.com/google/protobuf/releases/download/v3.0.0/protoc-3.0.0-linux-x86_64.zip
unzip protobuf.zip

Run the compilation process with the downloaded version (the old version may still be in your path and you might need it elsewhere).

./bin/protoc object_detection/protos/*.proto --python_out=.

Add libraies to PYTHONPATH

export PYTHONPATH=$PYTHONPATH: `pwd` : `pwd` /slim

Test the installation

python object_detection/builders/model_builder_test.py