Linux Server Virtual Ethernet interface stops responding to arp requests

Question: I'm hoping someone has had this issue before as it is driving me nuts.  I have 2500 linux embedded Linux servers.  We use these servers partly to act as gateways to other devices sat on a private network.  The configuration contains a series of virtual interfaces (not vlans) with DNAT and SNAT rules to pass requests on to said devices.
For years this has worked fine.  Last week we added about 25 virtual interfaces and about 50 plus iptables rules.  At this point we ran into an issue that we did not expect.  Our embedded Linux servers randomly stopped answering requests for IP virtual IP addresses configured against the main Ethernet interface eth0.  ARP requests go unanswered eg:
tcpdump -vvvnn arp  -- *x.x.x.23 is the virtual IP address and x.x.x.16 is the router the request came from*
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 68 bytes
16:15:10.404513 arp who-has x.x.x.23 tell x.x.x.16
16:15:12.403592 arp who-has x.x.x.23 tell x.x.x.16
16:15:14.407617 arp who-has x.x.x.23 tell x.x.x.16

The device that x.x.x.23 is natted to is pingable from the Linux Server and the IPtables entry looks correct but never gets evaluated.
Does anyone know if there is some sort of buffer/cache in Linux that could limit the number of interfaces defined against a single Ethernet interface?  We have about 50 per Linux Server now.
Our firewall configuration is getting larger but I would expect an operating system error if that was causing a problem.
I can't see an operating system errors in dmesg or /var/log/messages.
We have a mixture of different ethernet hardware RLT8139 and RDC6040.  2 different flavours of Linux, Debian 6 and Puppy Linux 3(older sites).  Both have exhibited the same problem.
It is almost like the server does not know that it has the interface.  Flushing the firewall rules doesn't seem to do anything.  The server should reply to the ping when the nat rule is disabled but it doesn't.
I'm banging my head now.  This is what our interfaces look like.  The IPs have been masked to protect the innocent.......
eth0      Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.1  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1036673 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4606675 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:164871619 (157.2 MiB)  TX bytes:354806888 (338.3 MiB)
          Interrupt:10 Base address:0xde00

eth0:1    Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.3  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:10   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.13  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:14   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.14  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:15   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.15  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:16   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.16  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:17   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.17  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:18   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.18  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:19   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.19  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:2    Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.11  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:20   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.20  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:21   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.21  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:22   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.22  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:23   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.23  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:24   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.24  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:25   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.25  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:26   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.26  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:27   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.27  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:3    Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.12  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:33   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.33  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:34   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.34  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:39   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.39  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:4    Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.4  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:40   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.40  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:41   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.41  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:42   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.42  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:43   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.43  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:44   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.44  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:45   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.45  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:46   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.46  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:47   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.47  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:48   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.48  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:49   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.49  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:5    Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.5  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:50   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.50  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:51   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.51  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:52   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.52  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:53   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.53  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:54   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.54  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:55   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.55  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:56   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.56  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:57   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.57  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:58   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.58  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:59   Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.59  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:6    Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.6  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:7    Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.7  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:8    Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.8  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

eth0:9    Link encap:Ethernet  HWaddr 00:1B:EB:43:24:05
          inet addr:x.x.x.9  Bcast:x.x.x.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xde00

Answer: According to what you report: x.x.x.16 is both eth0:16 and the router.
Have you masked too many things ?
Anyway, I would look at /proc/sys/net/ipv4/conf/ [all|default|eth0] / arp_ignore and arp_announce .
Regards,


Swift CoreData: error: Failed to call designated initializer on NSManagedObject class 'NSManagedObject'

Question: I'm using core data to save a category in vc1 and want to add list properties to a list in vc2. My data model is one category to many list properties.
I'm adding the category like this in vc1:
func createNewCategory() {
    var category: NSManagedObject! = NSEntityDescription.insertNewObjectForEntityForName("Category", inManagedObjectContext: self.context) as NSManagedObject
    category.setValue(self.categoryTextField.text, forKey: "name")

    var error: NSError? = nil
    self.context.save(&error)
}

Setting up the data in vc2:
func setupCoreData() {
    var appDelegate: AppDelegate = (UIApplication.sharedApplication()).delegate as AppDelegate
    self.context = appDelegate.managedObjectContext!

    var request: NSFetchRequest = NSFetchRequest(entityName: "Category")
    if (self.context.executeFetchRequest(request, error: nil)) {
        var error: NSError? = nil
        self.listData = self.context.executeFetchRequest(request, error: &error)
        self.managedObject = self.listData.objectAtIndex(0) as NSManagedObject
    }
}

It crashes on the last row: self.managedObject = ... saying:
CoreData: error: Failed to call designated initializer on NSManagedObject class 'NSManagedObject'

The managed object is in the array if I put a break point and print the array. What's wrong?
Comment: You are executing the fetch request twice. Why?
Comment: I was checking if it existed, but it seemed to work without it...
Comment: The test just checks if the fetch returns an array, even an empty one.
Comment: Ok, good to know. I'm a novice as you can tell :) Thanks for your help.
Answer: The dedicated initializer is
class func insertNewObjectForEntityForName(_ entityName: String!,
   inManagedObjectContext context: NSManagedObjectContext!) -> AnyObject!

Clearly, you are not inserting a new object, so you really want an optional value. Maybe you declared your class variable managedObject as NSManagedObject!? Try setting it to NSManagedObject? and also change the operator to as?.
Comment: Setting ut up like this:
var managedObject: NSManagedObject? = NSManagedObject?()
self.managedObject = self.listData.objectAtIndex(0) as? NSManagedObject
seemed to work. Thanks!
Answer: An entity in CoreData is equivalent to a class. Did you add the entity to your managed object model, and subclass the entity? (Check out the programming guide for a fuller background.)


cannot update in panel when i choose a file path

Question: once a user selects the button "CLICK HERE TO UPLOAD", the3 file path is stored into a file, and these paths are read into an arraylist, which is shown on the JPanel. the problem is that once a file is selected, it is never updated automatically on the JPanel, unless the application is re runed, before the up to date number of information is displayed. How can this problem be rectified, because i have no clue where i have gone wrong. By the way the arraylists gets updated on runtime but the JPanel never gets updated.
public class Media2 extends JPanel {

private JPanel video_pnl, control_pnl;
private JButton play_btn;
private JLabel loc_lbl;
private int increment;
ArrayList<String> file_location;
ArrayList<JButton> button_lists;
private FileWriter file_writer;
private BufferedWriter buffered_writer;
private JFileChooser filechooser;
private File file;
private JButton btn_upload;
private BufferedReader br;
private FileReader fr;

public Media2(ArrayList<String> file_location) throws IOException {

    btn_upload = new JButton("Click here to Upload Video");
    String file_path = "C:\\Users\\goldAnthony\\Documents\\NetBeansProjects\\VDMS\\src\\VideoInfos.txt";
    file = new File(file_path);
    if (!file.exists()) {
        file.createNewFile();
        file_writer = new FileWriter(file.getAbsolutePath());
    } else {
        file_writer = new FileWriter(file.getAbsolutePath(), true);
    }
    add(btn_upload);

    Handlers handler = new Handlers();
    btn_upload.addActionListener(handler);

    this.file_location = file_location;
    readFile(file_location, file_path);
}

private void readFile(ArrayList<String> file_location, String file_path) throws FileNotFoundException, IOException {
    fr = new FileReader(file_path);
    br = new BufferedReader(fr);

    String text = "";
    String line2;
    line2 = br.readLine();
    while (line2 != null) {
        int i = 0;
        file_location.add(i, line2);
        line2 = br.readLine();
        i++;
    }
    configurePanel(file_location);
    //System.out.print(file_location.size() + "in the read file 1");
}

private void configurePanel(ArrayList<String> file_location) {
    increment = 0;
    while (increment < file_location.size()) {

        video_pnl = new JPanel();
        video_pnl.setLayout(new BoxLayout(video_pnl, BoxLayout.Y_AXIS));
        loc_lbl = new JLabel();
        loc_lbl.setText(file_location.get(increment));
        control_pnl = new JPanel();
        control_pnl.setLayout(new FlowLayout(FlowLayout.CENTER));
        video_pnl.add(loc_lbl);
        control_pnl.add(createButton(increment));

        video_pnl.add(control_pnl, BorderLayout.SOUTH);
        video_pnl.revalidate();
        add(video_pnl);
        increment++;
    }
}

private JButton createButton(final int i) {
    play_btn = new JButton("Play");
    play_btn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
//                System.out.println(file_location.get(i));
            play(i);
        }
    });
    return play_btn;
}

public void play(int i) {
    System.out.println(file_location.get(i));
}

private class Handlers implements ActionListener {

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == btn_upload) {
            try {   //display the image in jlabel
                file = new File("C:\\Users\\goldAnthony\\Documents\\NetBeansProjects\\VDMS\\src\\VideoInfos.txt");
                if (!file.exists()) {
                    file.createNewFile();
                    file_writer = new FileWriter(file.getAbsolutePath());
                } else {
                    file_writer = new FileWriter(file.getAbsolutePath(), true);
                }
                buffered_writer = new BufferedWriter(file_writer);
                //creating a file chooser
                filechooser = new JFileChooser();
                filechooser.setDialogTitle("Choose Your Video");
//            //below codes for select  the file
                int returnval = filechooser.showOpenDialog(null);
                if (returnval == JFileChooser.APPROVE_OPTION) {
                    file = filechooser.getSelectedFile();
                    String filename = file.getAbsolutePath();
                    buffered_writer.write(filename);
                    buffered_writer.newLine();
                    buffered_writer.close();
                }
            } catch (IOException | HeadlessException ex) {
                System.out.println(ex.getMessage());
            }
        }
    }
}

public static void main(String[] args) throws IOException {
    //Declare and initialize local variables
    ArrayList<String> file_location = new ArrayList<>();

    //creates instances of the VlcPlayer object, pass the mediaPath and invokes the method "run"
    Media2 mediaplayer = new Media2(file_location);
    JFrame ourframe = new JFrame();
    ourframe.setContentPane(mediaplayer);
    ourframe.setLayout(new GridLayout(5, 1));
    ourframe.setSize(300, 560);
    ourframe.setVisible(true);
    ourframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

}
Comment: I think it would help, if you added more context info instead of just posting the whole application code. Now everyone has to figure out the context of the problem!
Comment: Changes to the GUI are preferably done on the [Event Dispatch Thread](http://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html), which I don't see where you update... your problem is unclear.
Answer: When you add components to a visible GUI the basic code is:
panel.add(...);
panel.revalidate();
panel.repaint();

You are revalidating the wrong panel:
video_pnl.revalidate(); // wrong panel
add(video_pnl);

You should be doing:
//video_pnl.revalidate();
add(video_pnl);
revalidate();
repaint();

Comment: @MastaOpec, Then I guess I don't understand your question. Post a [MCTRE](http://stackoverflow.com/help/mcve) that demonstrates the problem.
Comment: From the Handler class  which updates the source file, never does anything to actually update the UI. Take a look and see what I mean, when you update your answer let me know so I can up vote it
Answer: Your code needs some changes, try:
private void configurePanel(ArrayList<String> file_location) {

    increment = 0;
    while (increment < file_location.size()) {
        addEntry(file_location.get(increment));//--------->New line
        increment++;
    }
}

private void addEntry(String location) {//--------->New constructor
    video_pnl = new JPanel();
    video_pnl.setLayout(new BoxLayout(video_pnl, BoxLayout.Y_AXIS));
    loc_lbl = new JLabel();
    loc_lbl.setText(location);
    control_pnl = new JPanel();
    control_pnl.setLayout(new FlowLayout(FlowLayout.CENTER));
    video_pnl.add(loc_lbl);
    control_pnl.add(createButton(increment));

    video_pnl.add(control_pnl, BorderLayout.SOUTH);
    video_pnl.revalidate();
    add(video_pnl);
}

and:
 private class Handlers implements ActionListener {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (e.getSource() == btn_upload) {
                try {   //display the image in jlabel
                    file = new File("C:\\VideoInfos.txt");
                    if (!file.exists()) {
                        file.createNewFile();
                        file_writer = new FileWriter(file.getAbsolutePath());
                    } else {
                        file_writer = new FileWriter(file.getAbsolutePath(), true);
                    }
                    buffered_writer = new BufferedWriter(file_writer);
                    //creating a file chooser
                    filechooser = new JFileChooser();
                    filechooser.setDialogTitle("Choose Your Video");
//            //below codes for select  the file
                    int returnval = filechooser.showOpenDialog(null);
                    if (returnval == JFileChooser.APPROVE_OPTION) {
                        file = filechooser.getSelectedFile();
                        String filename = file.getAbsolutePath();
                        buffered_writer.newLine();
                        buffered_writer.write(filename);
                        buffered_writer.newLine();
                        buffered_writer.close();
                        addEntry(filename);//---------------->New Line
                        validate();//------------>New Line
                    }

                } catch (IOException | HeadlessException ex) {
                    System.out.println(ex.getMessage());
                }
            }
        }
    }

Now it's working. You have to make further changes, of course :)
Comment: There is not need to invoke the update(Graphics) method directly. Swing will do this when a component needs to be repainted.
Comment: Please, never suggest using update or getGraphics, you don't control the paint process, this is the responsibility of the repaint manager
Comment: If you reuse the component - and if you want to change the graphics while component is invisible - `update(getGraphics())` is very useful (I mean before setting component to visible). `repaint()` only works while componet is visible..
Comment: @MastaOpec - your goal is to add all JPanels to some JPanel vertically? If so - try to revalidate parent JPanel. You can try `pack()` also.
Comment: You can use `BoxLayout` also in parent `JPanel`.
Comment: But how to repaint component if it's invisible? Let's say I have static `JWindow` as a dialog, and after making it invisible, I make some changes to it, and then I set it to visible. Without `update(getGraphics())` - component repaints AFTER I set it to visible - so for a few milliseconds an old content is visible..
Comment: -1 for the horrible update(getGraphics) ... please read the painting article referenced in the swing tag wiki
Comment: @kleopatra - then please tell me how to repaint component when it is not visible?
Comment: _repaint_ and _!visible_ is a contradiction in itself ... what do you **really** want?
Comment: Please read my comments more closely - if you reusing the same component - if you want to make changes when it is invisible - and later will become visible.


unable to install opencv in mac for python.. below is the error. else suggest a better way to install opencv

Question:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/usr/local/lib/python3.7/site-packages/cv2.cpython-37m-darwin.so, 2): Library not loaded: /usr/local/opt/glog/lib/libglog.0.3.5.dylib
  Referenced from: /usr/local/Cellar/opencv/3.4.3_1/lib/libopencv_sfm.3.4.dylib
  Reason: image not found

above is the error - how to fix ?
Comment: Show us the command that had this error.
Comment: Your error seems to be referenced in this GitHub issue: https://github.com/opencv/opencv/issues/8652. I would recommend reinstalling opencv from either brew or pip3.
Comment: thsnk you John :)
Answer: I searched for this problem and also got to github.com/opencv/opencv/issues/8652 where they recommended installing the missing library.
However, our error message references a different library -- glog: brew install glog worked for me!


How to access the order amount without tax in Rules?

Question: I have a rule which adds a percentage of the order amount to the shipping costs.
I use "commerce-line-item:order:commerce-order-total:amount" as the base price.
But unfortunately this amount has the tax (21%) in it.
How do I get the total amount in my rule without the tax in it?
Answer: I solved it using the commerce_price_components module. Some details about it (from its project page):

Extension to Drupal commerce that provides a price formatter to enable/disable price components such as discounts or taxes when displaying prices. This gives the admin absolute control over which components should be displayed and which shouldn't.
It also provides two Views handlers to display/hide price components in cart totals and order totals.
Additionally it has basic rules support that gives to the commerce administrators the ability to do conditions using price components such as discounts or taxes and react accordingly.

It gave me a new data selector, i.e site:current-cart-order:commerce-order-total:base-price:amount, which was exactly what I needed.


C-SPARQL query - match exact string literal

Question: I am working with C-SPARQL and I want to query triples received from a stream. However I encountered an issue when using a query in which I want to match an exact string literal. I usually get a result with my queries (data is coming from the string) but when I add a exact match for a string value for a literal, I always don't get any results. As if there is no match found. However if I look at all triples received from my stream there are entries that would match my string literal.
Here is an example of my query:
REGISTER QUERY LogStream AS
PREFIX person: <http://vocab/Person#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?s
FROM STREAM <ws://localhost:8124/tw/stream> [RANGE 5s STEP 1s]
WHERE {
?s person:name "Huber" .
}

I also tried working with filters and regex which are the following 2 examples:
REGISTER QUERY LogStream AS
PREFIX person: <http://vocab/Person#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?s ?o
FROM STREAM <ws://localhost:8124/tw/stream> [RANGE 5s STEP 1s]
WHERE {
 ?s person:name ?o FILTER ( ?o = "Huber" ) .
}

REGISTER QUERY LogStream AS
PREFIX person: <http://vocab/Person#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?s ?o
FROM STREAM <ws://localhost:8124/tw/stream> [RANGE 5s STEP 1s]
WHERE {
 ?s person:name ?o FILTER (regex(?o, '^Huber$')) .
}

None of the queries give my any results as if there are no matches.
If I just execute the following query, I get a lot of results with name = Huber:
REGISTER QUERY LogStream AS
PREFIX person: <http://vocab/Person#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?s ?o
FROM STREAM <ws://localhost:8124/tw/stream> [RANGE 5s STEP 1s]
WHERE {
 ?s person:name ?o .
}

I am not sure if C-SPARQL supports all features of SPARQL. I read in a different post that round() is not supported in C-SPARQL. Since the match of an exact String is a basic feature, at least in my opinion, I am not sure if I might do something wrong or if I miss some details.
I tried the queries in SPARQL, querying a triplestore, and there all queries work just fine.
So, I am a bit confused why the string match is not working here in C-SPARQL.
Does anyone has some hints or suggestions?

EDIT (further information about how my data looks like):
The data I am trying to query using C-SPARQL are JSON-LD entries coming from  a Web stream. The stream is created and published via Triplewave.
Here would be a small example of a JSON-LD:
[
  {
    "@id": "http://Stream/d7e4e816-0931-42ce-a21a-cbfaa552855d",
    "http://www.w3.org/ns/prov#generatedAtTime": [
      {
        "@value": "2018-11-14T07:08:45.182Z"
      }
    ],
    "@graph": [
      {
        "@id": "http://schema.org/Person#1234",
        "http://schema.org/name": [
          {
            "@value": "Huber"
          }
        ]
      },
      {
        "@id": "http://schema.org/Job#1234",
        "http://schema.org/title"": [
          {
            "@value": "Professor"
          }
        ]
      }
    ]
  }
]

There is no type information or any language tag.
In order to query my web stream using C-SPARQL I implemented a RdfStream which receives the JSON-LD data via a websocket and created RdfQuadruple of all entries in my graph and puts it into the RdfStream.
An example of a RdfQuadruple is this:
http://schema.org/Person#1234 http://schema.org/name Huber .

Comment: Are you sure these literals are not `rdf:langString`s, e.g. `"Huber@de"`?
Comment: did you try `FILTER ( str(?o) = "Huber" )` ?
Comment: Or just with a possible language tag, i.e. `?s person:name "Huber"@en` ? I don't know your data
Answer: The STR( value ) function solved my issue.
I have to convert the value to a string beforehand
So the following query worked:
REGISTER QUERY LogStream AS
PREFIX person: <http://vocab/Person#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?s ?o
FROM STREAM <ws://localhost:8124/tw/stream> [RANGE 5s STEP 1s]
WHERE {
 ?s person:name ?o FILTER ( str(?o) = "Huber" ) .
}

Thank you for your suggestions.
Comment: I added some further explanation about by data in my initial post after "EDIT". I hope this clarifies your questions.
Comment: So what was the problem? Were these objects `xsd:string`s (and then it should be a bug)? Or were they strings with language tags (like `Huber`@en)? Or possibly URIs (like ``)?!
Comment: @StanislavKralin Good question. That's why I also suggested two options, namely `FILTER(str(?o) = "Huber") ` and `?s person:name "Huber"@en` given that I don't know the data


When should one use multiple regression with dummy coding vs. ANCOVA?

Question: I recently analyzed an experiment that manipulated 2 categorical variables and one continuous variable using ANCOVA.  However, a reviewer suggested that multiple regression with the categorical variable coded as dummy variables is a more appropriate test for experiments with both categorical and continuous variables.
When is it appropriate to use ANCOVA vs. multiple regression with dummy variables and what factors should I consider in selecting between the two tests?
Thank you.
Comment: Which of your variables is a predictor and which a correlate?
Comment: @John, in the experiment that I mention all of the variables were predictors and were manipulated but I left the description vague because I am hoping for a general answer of what I should consider when choosing between the two types of analysis.
Comment: That really changes everything in your question.  So you don't really want to select between ANCOVA and regression but ANOVA and regression.
Comment: @John thanks for your comments. I may not be using the terms correctly.  I have an experiment where 2 categorical factors (light/no-light and ambient/elevated CO_2) and one continuous variable ([DOC]) were manipulated.  To evaluate the effect of these factors on the response, I used ANCOVA, since there was a mix of categorical and continuous factors. However multiple regression with dummy variable coding can also be used to test the effect of a mixture of cont. and cat. factors on a response.  I am hoping to learn more about when it is appropriate to select one or the other.
Comment: This is a question about John's answer (as I do not have enough reputation points to write a real comment). The sources I read so far (e.g. if I google for `ANOVA ANCOVA` or `Multiple regression ANCOVA`) tell me that `ANOVA involves only categorical predictors` and `ANCOVA involves categorical and continuous predictors`, and that both, ANOVA and ANCOVA designs, can be described using a multiple regression model. Does this conflict with John's answer, which sais `"ANCOVA and ANOVA are the same, as ttnphns pointed out"`?
Answer: These two are the same thing. For example, in SPSS the procedure where I specify ANCOVA is called GLM (general linear model); it askes to input "factors" (categorical predictors) and "covariates" (continuous predictors). If I recode the "factors" into dummy variables (omitting one redundant category from each factor) and input all those together with the covariates as "independent variables" in REGRESSION procedure (linear regression), I will obtain the same results as with GLM (taken that the dependent variable is the same, of course).
P.S. The results will be identical if the models are identical. If regression contains only main effects then ANCOVA should be specified without factor by factor interactions, of course.
Answer: ttnphns is correct.
However, given your additional comments I would suggest that the reviewer wanted the change merely for interpretation.  If you want to stick with ANOVA style results just call it ANOVA.  ANCOVA and ANOVA are the same, as ttnphns pointed out.  The difference is that with ANCOVA you don't treat the covariates as predictors and you definitely appear to want to do just that.
What the reviewer was getting at was that, while you can perform an ANOVA on continuous predictors, it's typical that one perform a regression.  One feature of this is that you get estimates of the effects of the continuous variable and you can even look at interactions between it and the categorical (which aren't included in an ANCOVA but could be in an ANOVA).
You may need some help with interpretation of regression results because funny things happen on the way to interactions if you're going to use the beta values to determine the significance of your effects.
Answer: As long as you can write the null hypothesis clearly, the problem will be solved head-on...
For a regression analysis with a dummy variable (categorical variable consisting of several groups), your attention is on the reference group and comparing other groups with it by t-test.
For ANCOVA, your attention is on the entire factor (categorical variable), and check if this factor is significant by F-test (or LRT). After passing the test, people usually investigate further by a pairwise t-test with some correction, like Bonferroni correction.
The difference between ANCOVA and ANOVA is just whether doing an adjustment of other covariates.
As they said, if you do ANCOVA and regression on SPSS, you will get the same model. The only difference is how you do the inference (test) next. If people can realize that a t-test is also essentially a regression analysis (with some assumptions), then will easily distinguish modeling and inference...
Answer: ANCOVA is a form of regression but not identical to other multiple regression techniques. SPSS is not robust enough software to trust in anything outside of some psychology research. Within econometrics, biology, chemistry, physics, and finance SPSS is not accurate or useful in general. Even within psychology, SPSS preset regression corrections are often problematic.
Within education research here are examples of misuses of multiple regression and ANCOVA; they are similar but it is 100% wrong to say they are the same or almost identical.
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5701329/
Comment: Please use a reference that supports your argument that ANCOVA and multiple regression are not fundamentally the same thing given the constraints @ttnphns specified.
Answer: Multiple linear regression appears to me more appropriate than ANCOVA in this situation, as the journal reviewer recommends.
Try running both a multiple regression and an ANCOVA, and comparing the results.  They probably will not be identical.
ANCOVA and multiple linear regression are similar, but regression is more appropriate when the emphasis is on the dependent outcome variable, while ANCOVA is more appropriate when the emphasis is on comparing the groups from one of the independent variables.  In the experiment described above, the emphasis seems clearly to be on the outcome variable.
Finally, unless you are really certain that you way of doing things is better than the Reviewer's, and can explain why, then you should probably just concede to the Reviewer's expertise, so you can get your paper published.
Comment: -1, this is incorrect. Did you read the answers by @John or @ttnphns? Both correctly point out that ANCOVA **is** a multiple regression model. The traditional ANCOVA did not allow for interactions b/t covariates & factors (the so-called 'parallel slopes assumption'), but the term 'ANCOVA' is used sloppily & many people use it to include cases w/ interactions. Moreover, I gather SPSS will run an 'ANCOVA' w/ such. Is that what you had meant here? If so, please clarify. If not I must let the downvote stand.


How to mark a file dirty from an extension

Question: We have implemented a custom FileSystemProvider in our extension and has a scenario where we need to mark a file provided by our FileSystemProvider as dirty (has unsaved changes) even when user has not modified the file.
Is there a way to explicitly mark a file as dirty from the extension?
Comment: with an edit builder add a space at the end and when that is processed remove the space
Comment: Do you still need to see an example of this?
Comment: Yes, please could you share an example?
Answer: Here are two ways to do it.  Basically you do have to make a change to the file and then remove it.

// Method 1

await editor.edit((editBuilder)=> {
    editBuilder.insert(new vscode.Position(0,0), " ");
}, {undoStopBefore:false, undoStopAfter:false });

await editor.edit((editBuilder)=> {
    editBuilder.delete(new vscode.Range(new vscode.Position(0,0), new vscode.Position(0,1)));
}, {undoStopBefore:false, undoStopAfter:false });

// Method 2

let edits = new vscode.WorkspaceEdit();
edits.insert(vscode.window.activeTextEditor.document.uri, new vscode.Position(0,0), " ");
await vscode.workspace.applyEdit(edits);

let edits2 = new vscode.WorkspaceEdit();
edits2.delete(vscode.window.activeTextEditor.document.uri, new vscode.Range(new vscode.Position(0,0), new vscode.Position(0,1)));
await vscode.workspace.applyEdit(edits2);

I inserted a space at the first character and then removed it.  Obviously, you could insert any character anywhere in the document that you want (like an end of a line) and then remove it.  I don't think there is a better way to do this - you actually have to make a change to the file to get vscode to mark it dirty.  Fortunately for you, undoing that change leaves it as dirty.
This also works (but not for text files which don't have comment characters):
await vscode.commands.executeCommand('editor.action.commentLine');
await vscode.commands.executeCommand('editor.action.commentLine');

but the toggling is more jarring than adding and removing a space.
I was hoping that simply replacing a character by itself would be the least noticeable but still render the file dirty, but the file is not made dirty - so this does NOT work:
let edits = new vscode.WorkspaceEdit();

const replaceRange = new vscode.Range(new vscode.Position(0,0), new vscode.Position(0,1));
const textToReplace = vscode.window.activeTextEditor.document.getText(replaceRange);

edits.replace(vscode.window.activeTextEditor.document.uri, replaceRange, textToReplace);
await vscode.workspace.applyEdit(edits);


How to have a separate image style for an image field for the 1st views row?

Question: First I tried with views_conditional (which was already installed on the site) to check for 1st row and output the specific image but it does not seem to work as per this issue
Ideally I want to do it without installing an extra module.
I tried with THEMENAME_preprocess_views_view_field but the image was already rendered at this stage.  Have used the somewhat hackish str_replace but it does not actually work.
function THEMENAME_preprocess_views_view_field(&$vars) {
  if($vars['view']->element['#name'] == "free_write"
      && $vars['field']->field == "field_main_image"
      && $vars['row']->index == 1
      ){
    $html = str_replace("teaser_media_small","teaser_media_medium",$vars["output"]->__toString());
    $vars["output"] = Drupal\Core\Render\Markup::create($html);
  }
}

what is the proper way to do this in a preprocess function or perhaps in a twig template ?
Comment: I think the solution from @Adrian Cid Almaguer is the best for your field based view. You might consider for better performance and theming a view displaying content and then switch view modes in a row style plugin, see this module https://www.drupal.org/project/views_parity_row
Answer: A solution can be Add an Attachment Display to the View, in the Attachment you can select to show only one element with a different style and you can give as position Before.

In the Page then you select to skip 1 element.

This will output something like this:
Answer: Another option, is to simply add your image field again and give it the other image style and only print this field in the first row via preprocess function.
If you want to use twig, you can add "count" as a field and use that to know which row you're on in your conditional.


Host verification fails for https://www.apis.google.com/ in spring social

Question: I'm using Spring Social for login with gmail account into my webapp. It was all ok when I have implemented the feature but today I'm getting
javax.net.ssl.SSLPeerUnverifiedException: Host name 'www.googleapis.com' does not match the certificate subject provided by the peer (CN=*.storage.googleapis.com, O=Google Inc, L=Mountain View, ST=California, C=US)
This is the stack trace:
Caused by: javax.net.ssl.SSLPeerUnverifiedException: Host name 'www.googleapis.com' does not match the certificate subject provided by the peer (CN=*.storage.googleapis.com, O=Google Inc, L=Mountain View, ST=California, C=US)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.verifyHostname(SSLConnectionSocketFactory.java:465)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:395)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:353)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
    at org.springframework.http.client.HttpComponentsClientHttpRequest.executeInternal(HttpComponentsClientHttpRequest.java:84)
    at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:46)
    at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:52)
    at org.springframework.http.client.InterceptingClientHttpRequest$RequestExecution.execute(InterceptingClientHttpRequest.java:94)
    at org.springframework.social.oauth2.OAuth2RequestInterceptor.intercept(OAuth2RequestInterceptor.java:45)
    at org.springframework.http.client.InterceptingClientHttpRequest$RequestExecution.execute(InterceptingClientHttpRequest.java:84)
    at org.springframework.http.client.InterceptingClientHttpRequest.executeInternal(InterceptingClientHttpRequest.java:69)
    at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:46)
    at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:52)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:541)
    ... 44 more

If I browse with firefox to the url : https://www.apis.google.com/
I'm getting the warning that the certificate is not valid for this domain.
Is there something wrong with the call of spring social?
How to temporary disable the host verification for gmail spring social?
Answer: I am encountering the same issue. My best guess. There is mismatch between HTTPs call and Certificate. This looks like more of a Google issue then Spring Social Google API issue.
Not sure how long this issue has been going on. I started working on this code yesterday.
Will open bug with Google and Spring Google Social
Filed bug with Google, and for social on Github
59:27:345 ERROR org.springframework.social.connect.web.ProviderSignInController.oauth2Callback Message=Exception while completing OAuth 2 connection:
org.springframework.web.client.ResourceAccessException: I/O error on GET request for "https://www.googleapis.com/plus/v1/people/me":Host name 'www.googleapis.com' does not match the certificate subject provided by the peer (CN=*.storage.googleapis.com, O=Google Inc, L=Mountain View, ST=California, C=US); nested exception is javax.net.ssl.SSLPeerUnverifiedException: Host name 'www.googleapis.com' does not match the certificate subject provided by the peer (CN=*.storage.googleapis.com, O=Google Inc, L=Mountain View, ST=California, C=US)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:580)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:530)
    at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:237)
    at org.springframework.social.google.api.impl.AbstractGoogleApiOperations.getEntity(AbstractGoogleApiOperations.java:50)
    at org.springframework.social.google.api.plus.impl.PlusTemplate.getPerson(PlusTemplate.java:105)
    at org.springframework.social.google.api.plus.impl.PlusTemplate.getGoogleProfile(PlusTemplate.java:110)
    at org.springframework.social.google.connect.GoogleAdapter.fetchUserProfile(GoogleAdapter.java:51)
    at org.springframework.social.google.connect.GoogleAdapter.fetchUserProfile(GoogleAdapter.java:31)
    at org.springframework.social.google.connect.GoogleConnectionFactory.extractProviderUserId(GoogleConnectionFactory.java:37)
    at org.springframework.social.connect.support.OAuth2ConnectionFactory.createConnection(OAuth2ConnectionFactory.java:91)
    at org.springframework.social.connect.web.ConnectSupport.completeConnection(ConnectSupport.java:161)
    at org.springframework.social.connect.web.ProviderSignInController.oauth2Callback(ProviderSignInController.java:216)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)

Finally found solution to this problem.
Downgrade HttpClient to 4.3.x. There is a bug filed and resolved marked for 4.5.x https://issues.apache.org/jira/browse/HTTPCLIENT-1613
For reference -
https://github.com/GabiAxel/spring-social-google/issues/67#issuecomment-97154525
Answer:
If I browse with firefox to the url : https://www.apis.google.com/ I'm getting the warning that the certificate is not valid for this domain.

The hostname must be apis.google.com, i.e. without the www. Then the certificate validation should succeed.

Is there something wrong with the call of spring social?

Here you use a different name, i.e. www.googleapis.com. The certificate for this name is correct.

Host name 'www.googleapis.com' does not match the certificate subject provided by the peer (CN=*.storage.googleapis.com, O=Google Inc, L=Mountain View, ST=California, C=US)

While the CN is indeed *.storage.googleapis.com there is a subject alternative name for *.googleapis.com which matches www.googleapis.com. Which means that the hostname check used by your code is wrong. I don't know where this bad check originates but it might be an old version of Java or the libraries you use.

How to temporary disable the host verification for gmail spring social?

This would be a bad idea, because this would undermine the reason why https is used at all.
Answer: Check if you using HttpClient. Then change to HttpClient 4.3.x library, not 4.4.x.

<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.3.1</version>
</dependency>


Insert new or update version - sqlite (android)

Question: I need to insert new record if it doesn't exist OR update a column (version no) by incrementing the current value it if exists already.
create table t(id int, version int);

I'm trying to get this done using a single SQL statement but I can't seem to find a suitable control flow statement. Would appreciate any help on it. Thanks.
Answer: well seems to me that you need a few lines.
Take input from user check if it exists, iF the returned cursor(for android, there must be some return value for other) is null put an insert statement if cursor is not null then update the returned cursor position with the new value
Like first perform select * from tablename where title = ""
Now if the returned value is null
insert into ....

If not
update table tablename ----

Comment: Thanks for your response. Actually, I'm already using similar approach & I'm looking for a way to get around having to make multiple DB queries.
Comment: afaik: There's no practical way to implement 'createOrUpdate' without using two SQL statements.


Find the density function of a random variable that depends on two other random variables with a given joint distribution.

Question: For example,

The joint density of $X$ and $Y$ is given by
  $$f(x, y) = \begin{cases}e^{-x-y}&\text{ if } 0<x<\infty, 0<y<\infty\\ 0 &\text{ otherwise}\end{cases}.$$
  Find the density function of the random variable $Z = X/Y$.

How would I do or even approach a problem like this?
Source http://dept.stat.lsa.umich.edu/~ionides/425/notes/joint_rvs.pdf
Comment: Don't forget to mention the support of $Z$ in your final answer. Similar questions have been asked before. See [this](https://math.stackexchange.com/questions/33778/cdf-of-a-ratio-of-exponential-variables) and its linked posts.
Answer: There are a couple ways. First, it's usually easiest to attack these things through the CDF. We have $$ F_Z(z) = P(Z\le z) = P(X/Y\le z) = P(X\le zY).$$ Then we can express the final probability as an integral. We want to integrate the joint PDF of $X$ and $Y$ over the region $x\le zy.$ This can be set up as $$ \int_0^\infty \int_0^{zy}e^{-(x+y)}dx\; dy = \int_0^\infty e^{-y}\int_0^{zy}e^{-x}dx\; dy \\= \int_0^\infty e^{-y}(1-e^{-zy})dy \\= \int_0^\infty (e^{-y}-e^{-(z+1)y})dy \\= 1-\frac{1}{z+1}.$$
Now, the PDF is the derivative of the CDF, $$ f_Z(z) = \frac{d}{dz}\left(1-\frac{1}{z+1}\right) = \frac{1}{(z+1)^2}.$$
Another way is, if you're familiar with variable transformations. We can set $Z=X/Y$ and $W = XY$ and then do a transformation of the PDF to get $f_{Z,W}(z,w)$ and then integrate over $w$ to get the marginal PDF of $Z.$
Finally, there is a general formula for the quotient of two continuous random variables (that can be derived from either of these two methods: $$ f_Z(z) = \int uf_{X,Y}(u,zu) du$$
Answer: $P\{\frac X Y \leq t\}=P\{X\leq tY\}=EP\{X\leq tY|Y\}$
$=E\int_o^{tY} e^{-x} \, dx=E(1-e^{-tY})=\int_0^{\infty} (1-e^{-ty}) \, e^{-y}dy=1-\frac 1 {1+t}=\frac t {1+t}$.  Differentiating we get the density as $\frac 1 {(1+t)^{2}}$
Answer: I believe the procedure is to first rewrite the inequality, sketch the area that the inequality represents in $\mathbb R^2$ and then integrate the joint pdf over this area.

Rewrite the inequality:

Your first instinct might be to cross-multiply:
$$P(Z := \frac X Y \le z) = P(X \le Yz)$$
But wait, can we cross-multiply inequalities? Yes if $Y > 0$ surely. What if $Y > 0$ only almost surely, i.e. $P(Y > 0) = 1$ but technically we don't have surely that $Y > 0$ (Precisely there are $\omega$'s s.t. $Y(\omega)<0$, but they are too small to count)?
Well then, we'll use total probability:
$$P(\frac X Y \le z) = P(\frac X Y \le z \cap Y > 0) + P(\frac X Y \le z \cap Y < 0)$$
$$ = P(X \le Yz \cap Y > 0) + P(X \ge Yz \cap Y < 0)$$
Now consider the latter term, $P(X \ge Yz \cap Y < 0)$. Observe that $\{X \ge Yz \cap Y < 0 \} \subseteq \{Y<0 \}$. By monotonicity of probability, since $P(Y<0)=0$, (*) we have that $P(X \ge Yz \cap Y < 0) = 0$.
Hence,
$$P(\frac X Y \le z) = P(X\le Yz)$$

Sketch the area.

You may have noticed in the beginning that the expression $'\frac X Y \le z'$ looks something like an area below or above a line. That's because it is. But which area? Le't take cases.
Case 1: $z<0$
Since $P(X<0)=0$ for the same symmetric reasoning as $P(Y<0)=0$ (*), we have that $P(X \le zY)=P(0<X \le zY < 0) = P(\emptyset) = 0$ because $\{0<X \le zY < 0\}=\{0<0\}=\emptyset$. Nothing to sketch here.
Case 2: $z=0$
Again, since $P(X<0)=0$, we have that $P(X \le zY)=P(X \le 0)=P(X<0)=0$. Nothing to sketch here.
Case 3: $z>0$
Finally, we have something to sketch, namely the set $\{X \le zY\}$. Observe that $X = zY$ is a line, if we plot $Y$ vertically and $X$ horizontally. Imagine $z=5$. Consider any point in $\mathbb R^2$, say $(0,1)$. Is that in the set? Yes. Let's check: $0 = X \le z(1) = z = 5$ is true, and this extends to any $z > 0$. Thus, $\{X \le zY\}$ is all the points above the line $X \le zY$ as seen in $(0,1)$, which is above $X \le zY$. We have shown that $Y>0$, $X>0$ almost surely, hence, by total probability,
$$P(X \le zY) = P(0 < X \le zY)$$

Integrate

Case 1: 0
Case 2: 0
Case 3:
Let $y_0 < 0, y_1 > 0, x_0 < 0, x_1 > 0$. Try to sketch a rectangle with these 4 lines as boundaries and then draw $x=zy$ as a diagonal of the rectangle. Then,
$$P(X \le zY) = \lim_{(y_0,y_1,x_0) \to (-\infty,\infty,-\infty)} \int_{y_0}^{y_1}\int_{x_0}^{zy} f(x,y) dx dy$$
$$\implies P(X \le zY) = P(0 < X \le zY) = \lim_{(y_0,y_1) \to (-\infty,\infty)} \int_{y_0}^{y_1}\int_{0}^{zy} f(x,y) dx dy$$
Because $Y>0$ almost surely, we have $$P(X \le zY) = \lim_{y_1 \to \infty} \int_{0}^{y_1}\int_{0}^{zy} f(x,y) dx dy$$
For reversed order of integration, we have:
$$P(X \le zY) = \lim_{(x_1,y_1,x_0) \to (\infty,\infty,-\infty)} \int_{x_0}^{x_1}\int_{\frac x z}^{y_1} f(x,y) dy dx$$
$$\implies P(X \le zY) = P(0 < X \le zY) = \lim_{(x_1,y_1) \to (\infty,\infty)} \int_{0}^{x_1}\int_{\frac x z}^{y_1} f(x,y) dy dx$$
I'll do the one without the fraction in the bound for integration:
$$P(X \le zY) = \lim_{y_1 \to \infty} \int_{0}^{y_1}\int_{0}^{zy} f(x,y) dx dy$$
$$ = \lim_{y_1 \to \infty} \int_{0}^{y_1}\int_{0}^{zy} e^{-x}e^{-y}1_{x>0}1_{y>0} dx dy$$
$$ = \lim_{y_1 \to \infty} \int_{0}^{y_1}\int_{0}^{zy} e^{-x}e^{-y} dx dy$$
$$ = \lim_{y_1 \to \infty} \int_{0}^{y_1}e^{-y}\int_{0}^{zy} e^{-x} dx dy$$
$$ = \lim_{y_1 \to \infty} \int_{0}^{y_1}e^{-y} [- e^{-zy} + e^{0}] dx dy$$
$$ = \lim_{y_1 \to \infty} \int_{0}^{y_1}e^{-y} [- e^{-zy} + 1] dx dy$$

(*) Pf that $P(Y<0)=0$, i.e. $P(Y > 0)=1$, i.e. $Y>0$ almost surely.
$$P(Y<0) = \int_{y<0} f_Y(y) dy = \int_{y<0} \int_{\mathbb R} f_{X,Y}(x,y) dx dy = \int_{y<0} \int_{\mathbb R} e^{-x}e^{-y}1_{x>0,y>0} dx dy$$
$$ = \int_{y<0} \int_{\mathbb R} e^{-x}e^{-y}1_{x>0}1_{y>0} dx dy = \int_{y<0} e^{-y} 1_{y>0} \int_{\mathbb R} e^{-x}1_{x>0} dx dy = \int_{y<0} e^{-y} 1_{y>0} \int_{x>0} e^{-x} dx dy$$
$$ = \int_{y<0} e^{-y} 1_{y>0} (1) dy = \int_{y<0} e^{-y} 1_{y>0} dy = \int_{\mathbb R} e^{-y} 1_{y>0} 1_{y<0} dy = \int_{\mathbb R} e^{-y} (0) dy = \int_{\mathbb R} 0 dy = 0$$
QED


Using L-BFGS-B optimization

Question: This is a general question about how the L-BFGS-B optimization algorithm works.
I have encountered some strange likelihoods in a model I was running (which uses optim from R, and the L-BFGS-B algorithm). The function optimizes over a parameter, which is constrained to 0-1 and maximizes the likelihood (Minimizes the negative log-likelihood I believe is what it technically does)
As I said earlier, I found some odd results and since the model does not take long to run, I ran all possible values of the parameter and plotted the Likelihood for each value, the results looks like so:

The red line indicates the value that optim suggested, and the blue line is the max value I found by doing all possible values.
My question is then why is this happening?
Does the L-BFGS-B employ some kind of Newton-Raphson search algorithm, ie. it only finds local maxima / minima?
Or does the systematic process it goes through just not fit in a situation where the likelihood probability is as seen in the graph?
Thanks,
Sam
Comment: ML depends only on one parameter? You say that it is constrained to interval [0,1], yet in the graph we see values from 0 to 50. If you do minimisation, then the minimum should be achieved at point (30,-210), are you sure you did not confuse minimisation with maximisation? From what I see, you either confused minimisation with maximisation, or your optimal solution lives on a boundary. In the latter case gradient based methods are not guaranteed to work.
Answer: I will assume that the x-axis in your plot refers to indices of a vector of possible parameter values rather than the parameter values themselves (in which case as @mpiktas says there may be an issue with not respecting the constraint in your exhaustive search).
If this assumption is correct then the problem is that the optimal solution is on the boundary of the parameter space - i.e. from your exhaustive search the best value of the parameter is $1$. I suspect this may be compounded by your choice of starting value (is it $0$?).
I find it helpful in diagnosing issues with optim to include a print statement in the score function so I can follow which parameter values are being used at each function call. This may give you an intuition as to why it is not exploring certain regions of the parameter space.
Comment: Thank-you. Yes that is correct it is the indices of the parameter, rather than the value itself.  The starting value is 0.5 currently. I didn't write this function so I'm not sure if there is solid reasoning for that or if it is just a good place to start. Could you explain what you mean by the score function?
Comment: The score function is the function to be minimized, in your case the negative log-likelihood function. Judging from the points in your plot it looks like if you start at $0.5$ then the gradient will cause it to head straight towards $0$. I would assume if you changed the starting value to, say, $0.75$ you would end up with the solution at $1$. One final point of clarification, is this really a one-dimensional optimization? In which case the `optimize` function may be more appropriate - but still wouldn't solve the issue with the solution lying on the boundary.
Comment: It is not a 1D optimization. But I have tried to simplify the issue as much as I can, as the actually question is quite complex. The answer I wanted to get was what you have given, around optimization and boundry solutions. So thank-you. I think I will re-write the function to by-pass the optim and just run an exhaustive search of parameters. I know this isn't the most elegant way to find the result, but it will give the answer I want and will shed some light on a different area of the problem that I think will be interesting.
Comment: One final suggestion - you could try transforming the parameter to avoid using constrained optimization and move the optimal solution away from the boundary. You optimize between $-\infty$ and $\infty$ and apply a transformation such as `sin` before evaluating the negative log-likelihood. Specifically you'd do `(sin(x)+1)/2` to have it lie in `[0,1]`.

Using L-BFGS-B optimization


Updating a sql table with a sumifs equivalent query

Question: Hope you can help.  I'm fairly new to sql, and this is the query that I have.
I want to update an existing table with a new field that sums the orders for each unique number on each date.  So for example, in the following table, SumOfOrders is the column I want.
UniqueID    Date    Orders  SumOfOrders
A       01/03/2012      2       9
A       01/03/2012      3       9
A       01/03/2012      4       9
A       01/07/2012      1       1
B       02/07/2012      3       3
B       30/10/2012      2       4
B       30/10/2012      2       4
C       01/03/2012      5       5
D       NULL            NULL    n/a

There are over a million unique IDs, so this is just a simplified example.
From what I googled, I felt that it should use some variant on sum over partition by (using update table  and set, but the following code gives the wrong number of records:
select [UniqueID], [Date], [Orders],
  sum([Orders]) over (partition by [UniqueID], [Date] order by [UniqueID], [Date])as SumOfOrders
            from test
            group by [UniqueID], [Date], [Orders]
            order by [UniqueID], [Date], [Orders]

Any pointers would be very appreciated!
Answer: Perhaps you just want :
select [UniqueID], [Date], [Orders],
        sum([Orders]) over (partition by [UniqueID], [Date]) as SumOfOrders
from test
order by [UniqueID], [Date], [Orders];

The same simplified version would be :
select t.[UniqueID], t.[Date], t.[Orders], t1.SumOfOrders
from test t cross apply
     (select sum(t1.Orders) as SumOfOrders
      from test t1
      where t1.[UniqueID] = t.[UniqueID] and t1.[Date] = t.[Date]
     ) t1
order by t.[UniqueID], t.[Date], t.[Orders];


Where is the code of a new view i've created?

Question: i'm using drupal 7 with starter theme of zen. i've created a view on a block, now i need to customize some parts of html / css in order to add just media query (css part) and add a  tag with display:none for desktop version and display:block for mobile. SO i need to modify html AND css of this view. I'm searching for the php file of this view and i didn't find it.
Any help please ?
Comment: It's dynamic, the rendered content isn't actually saved anywhere except a transient cache if you have that enabled. For the customisations you've outlined, you don't need to make any HTML changes, just CSS, so just use your theme's CSS file
Comment: You can find the appropriate file name for the template in the right part of your view's interface: click on *Theme* and you'll see the activated templates.
Answer: If you click on the Theming link in the Advanced tab, you will get a list of possible template files that you can use. See here:

Next, you can click on "Display Output" to get a copy of the PHP that is powering the view. See here:

Copy that PHP into a file and save it using the naming pattern of your choice from the list beside "Display Output".
Click on "Rescan template files" to make your theme aware of the new template.
Now, any changes you make to that template - add CSS classes, etc - will automatically be picked up.
If you wish to edit HTML for the style or row, just click on the relevant "Style Output" or "Row Style Output" link instead of "Display Output".
I hope this helps you.


What is the classifying space G/Top?

Question: I simply can't find the definition(except in one book on surgery where a definition was not actually given but instead they alluded to what the definition is) and I have spent an hour and half looking.  My professor used the notation when talking me today.  I would be grateful for a reference.  My background is evident from my stackexchange posts.
Answer: A reference available online is Rudyak's survey Piecewise Linear Structures on Topological Manifolds. Beware that what you are calling $G$ he calls $F$ (I think both notations are common --and awful).
$G/TOP$ can be defined as the homotopy fiber of the canonical map $BTOP \to BG$, where $BTOP$ is the classifying space for stable topological bundles and $BG$ is the classifying space for stable spherical fibrations.
$BTOP$ can be defined as follows: let $TOP_n$ denote the topological group of self homeomorphisms of $\mathbb{R}^n$ fixing the origin, and let $BTOP_n$ be its classifying space. Each $TOP_n$ can be included in the next by sending $h : \mathbb{R}^n \to \mathbb{R}^n$ to $h \times \mathrm{id} : \mathbb{R}^{n+1} \to \mathbb{R}^{n+1}$. You get induced maps $BTOP_n \to BTOP_{n+1}$ and define $BTOP$ to be the colimit of all the $BTOP_n$.
$BG$ can be defined as follows: let $G_n$ be the topological monoid of pointed homotopy self equivalences of $S^n$ and $BG_n$ its classifying space (note that homotopy equivalences don't strictly speaking have an inverse udner composition, so $G_n$ is not a group, just a monoid). Suspension gives a map $G_n \to G_{n+1}$ and you set $BG$ to the colimit of the corresponding sequence of maps $BG_n \to BG_{n+1}$.
The map $BTOP \to BG$ is induced from the operation of one-point compactification: if $h : \mathbb{R}^n \to \mathbb{R}^n$, the one-point compactification $h^\bullet : S^n \to S^n$ is a homotopy self equivalence of $S^n$.
Comment: Thank you so much for telling me about Rudyak's survey.  It has been super helpful over the past month.

What is the classifying space G/Top?


Concatenating with Case Statement

Question: I'm trying to concatenate Column C and Column H into Column F where it meets certain conditions.  I want to concatenate Column C where it equals "FS_Tier_1" with Column H where it equals "FS_CAP_1_001" into Column F (below the first line "FS_Tier_1"), until Column H reaches "FS_CAP_1_002".
This is what my data looks like:

I've searched a lot of vba code but cannot find something that quite fits what I'm trying to accomplish.  I mainly work in SQL Server, so I'm new to vba.  I've tried to use the WHERE clause but haven't been able to make it work.
Sub Concat_ParentCode_Cap1()

With Worksheets("PD Code Structure")

Dim ParentCode As Range
Dim TierCode As String
Dim CapCode As String

TierCode = "FS_Tier_1"
CapCode = "FS_CAP_1_001"
ParentCode = Range("F2:F24")

    Select Case CapCode
        Case "FS_CAP_1_001"
            ParentCode = TierCode & " . " & CapCode

    End Select
End With
End Sub

I keep getting the error message: "Object variable or with block variable not set."
I'd like my data to look like the following:
Comment: Which line gives the error?
Answer: You have to Set the range:
Set ParentCode = Range("F2:F24").
Comment: Thank you so much!  I can't believe it was that simple!!  :)
Comment: I'm trying to add another criteria to the case statement; however, I keep getting the error "Type Mistmatch."   My code is: `Sub Concat_ParentCode_Cap1_001()

With Worksheets("PD Code Structure")

Dim ParentCode As Range
Dim TierCode As String
Dim CapCode As String

CapCode = "FS_CAP_1_001"
TierCode = "FS_Tier_1"
Set ParentCode = Range("F3:F24")

    Select Case CapCode
        Case CapCode = "FS_CAP_1_001" And Range("E2:E1006").Value = 2
            ParentCode = TierCode & "." & CapCode

    End Select
End With
End Sub`
Comment: You compare an entire range with one number in `Range("E2:E1006").value = 2`. This is not possible.

Concatenating with Case Statement


How do I calculate the optimal titleView width?

Question: I am using navigation with a custom UIView subclass that becomes my titleView. I want to ensure this is the full available width.
Logically from my UIViewController's viewWillAppear:, this should be:
CGFloat width = self.width - self.navigationItem.leftBarButtonItem.width - someConstant;

(I don't have a right item here.)
This would adapt, then, for different possible widths of the leftBarButtonItem. The catch is that leftBarButtonItem is nil, so leftBarButtonItem.width is always 0 (well, in the simulator anyway).
backBarButtonItem is also nil.
What should I be doing instead?
Comment: I have this exact issue as well :(
Answer: I hacked this by doing the following:
    int vcStackSize = [[self.navigationController viewControllers] count];
    WEViewController* previousController = [[self.navigationController viewControllers] objectAtIndex:vcStackSize - 2];

    NSString* previousTitle = [previousController title];

    UIFont* font = [UIFont boldSystemFontOfSize:12];

    lw = [previousTitle sizeWithFont:font].width + 26;

Nasty but it works


COMPASS CREATE Permissions denied

Question: I have gem installed both SASS and COMPASS using
gem install compass

I am trying to use the command
compass create .

to generate a compass project but when i do I get the following error.
Errno::EACCES on line ["897"] of C: Permission denied

This appears as it is trying to create the config.rb file
I am at a bit of a loss as it seems to be able to create both the stylesheets and sass directories
PS C:\Projects\tutorials\sass> compass create --trace
create config.rb
Errno::EACCES on line ["897"] of C: Permission denied - (C:/Projects/tutorials/sass/config.rb20140323-9028-1j0o9n1, C:/P
rojects/tutorials/sass/config.rb)
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.18/lib/sass/util.rb:897:in `atomic_create_and_write_file'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.4/lib/compass/actions.rb:58:in `write_file'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.4/lib/compass/app_integration/stand_alone/installer.rb:20:in `write_c
onfiguration_files'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.4/lib/compass/app_integration/stand_alone/installer.rb:35:in `prepare
'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.4/lib/compass/installers/base.rb:32:in    `run'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/compass-.12.4/lib/c ompass/commands/stamp_pattern.rb:75:in `perform'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.4/lib/compass/commands/base.rb:18:in `execute'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.4/lib/compass/commands/project_base.rb:19:in `execute'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.4/lib/compass/exec/sub_command_ui.rb:43:in `perform!'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.4/lib/compass/exec/sub_command_ui.rb:15:in `run!'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.4/bin/compass:30:in `block in <top   (required)>'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.4/bin/compass:44:in `call'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.4/bin/compass:44:in `<top (required)>'
C:/Ruby193/bin/compass:23:in `load'
C:/Ruby193/bin/compass:23:in `'

any help anyone could give me to resolve this would be most appreciated
Comment: I'm having very similar issues after updating yesterday, what versions of software and OS are you on?
Comment: I have another machine and I performed the same install with success on that machine very confused
Comment: I am on a windows 8.1 machine
Comment: Try uninstalling compass and sass and the re-installed with the --pre option, as detailed by the answer here: https://stackoverflow.com/questions/22596760/yeoman-error-errnoeacces-on-line-897-of-c-permission-denied/22597296#22597296 I was having the same problem and this fixed the issue for me.
Answer: I've solved this issue by downgrading the compass version. then i've tryed to understand what was the error.
So the problem was version conflicts between sass 3.2.14 and 3.3.4 . compass 0.12.3 depends on 3.2.14 sass verison.
Have a look at this link Can't get sass + compass + susy installed due to version conflict
If you want to make things work with the latest compass version. you can uninstall all sass  and compass version that you have. then look for the appropriate version between them.
This will things work perfectly.
And as a better solution you can work with this : http://bundler.io/ .
Kind regards.
Comment: Thank you uninstalling everything and installing with the --pre command has solved my issue
Answer: you're right. and here you can find details about this issue: https://github.com/chriseppstein/compass/issues/1618#issuecomment-38397775
They are working to solve it.
Answer: I think I have found the issue in the util.rb file specified in the error, an attempt is made to change the permissions of the files I think this link may hold the answer.
stackoverflow answer
Answer: you can do this way :
  gem install compass -v 0.12.3 --no-rdoc --no-ri

and install :
  compass install blueprint

it work for me

COMPASS CREATE Permissions denied


How to prevent a node from being deleted while performing a delete operation?

Question: I want to prevent a node from being deleted while a delete operation is performed on it. For example in administration panel if user clicks "Delete" on the node, the node shouldn't be deleted if he is not an administrator. Permissions and user roles are not a problem for me, the problem is "stopping" delete operation.
I found hook_entity_predelete(), which is perfect, it runs exactly just before deleting the node, but I don't know how to stop delete operation. I want to do some things inside that hook and prevent deleting the node.
I saw also this issue: How do I prevent a Node from being deleted? with hook_node_access(), but it  is not working as I need.
hook_entity_delete() is also not ok, because This hook runs once the entity has been deleted from the storage. I need to prevent it.
Thanks for your help.
Comment: The simplest answer is to remove the permission from their given role of "Delete any" or "Delete own" per content type. This should remove the button in the user interface. Hooks won't help in this case, because they are meant for running before the operation, not stopping it - it will proceed anyway. This is contained in EntityBase::delete, mainly. Otherwise, Clive and Berdirs answers in the linked question should be sufficient.
Comment: Thank you for your comment, I found another solution (I added it below as an answer).
Answer: I found a solution that satisfies me: I use hook_form_alter(). When you always try to delete a node there is a confirmation form, with "Delete" and "Cancel" buttons. I'm altering that form - in some cases (which depend of users permissions) I am unsetting "Delete" button (with unset($form['actions']['submit'], so delete is not possible) and adding my own button instead of it, with a callback function. I am also altering title of that form and description.
Comment: Would probably be helpful for future readers to see a bit of the code


form rendering through tpl file

Question: I want to render drupal 6 form through tpl file.
for that
1. I have written mytheme_theme in template.php file and there I have define my template forms arguments and path for tpl file.

I have written tpl file
in form function at the end I have called theme by '#theme' => 'my_template'

doing all these thing my from is rendering through tpl but now its not going into submit_hander() and validation.
can any one help me these? I am not getting what's wrong in these.
see in my template.php contain:
function cs_theme(&$existing, $type, $theme, $path) {
  $hooks = zen_theme($existing, $type, $theme, $path);
  // Add your theme hooks like this:
  /*
  $hooks['hook_name_here'] = array( // Details go here );
  */

  // @TODO: Needs detailed comments. Patches welcome!

  $hooks['my_theme_example'] = array(
                  'arguments' => array(
                  'order' => null,
                  ),
                  'render element' => 'form',
                 'template' => 'mymodule_template',
                 'path' => drupal_get_path('theme', 'theme_name') . '/templates',
              );

  return $hooks;
}

In these way I have printed all the form fields
in my .tpl file is:
   <?php print drupal_render($variables['order']['logo']);?>

Comment: Change theme hook definition for the form in hook_registry_alter().
Comment: can u plez explain in more detail?
Comment: Zz.. So hard to help you) Do you have ' in your template?
Comment: Can we attach files here so that you can view my code and then you can help me
Answer: You need rewrite 'form' like this:
/**
 * Implements hook_theme_registry_alter().
 */
function mymodule_theme_registry_alter(&$theme_registry) {
  $form_registry = &$theme_registry['form'];
  $form_registry['function'] = 'mymodule_form_theme';
}
function mymodule_form_theme($element) {
  // I'm not sure that $element has 'from_id' but you could pass it if you need.
  if ($element['form_id'] == 'yours_form_id') {
    return theme_form($element);
  }
  // Else return what you need I guess that better to use hook_theme()
  // and then call theme() function.
}

Look at theme_form() to understand what variables need to pass in form tag.
I don't understand why do you need this. What is the reason to use template file?
Comment: thanks for reply.
i have written hook_theme() in .module file. but thn also its going into submit hander.
is anything miss by me?
Comment: Describe what you need at the end. Do you need simple form without Drupal Form API? Or you need change submit handler? Or what else?
Comment: I have created custom form and for that I have written submit_handler() and validation, the form was working fine without writing anything in tpl, template file. but there is requirement that form should be render through template file, so I have done all thing which mention above but now its not going into submit_handler(). I want the form should go into submit_handler() and the form should render through template.
Comment: Show your template file in your question. Also, do you get form content throw drupal_get_form() function?
Comment: I am getting form content through tpl file but only prob is that it is not going in submit_handler()
Comment: Show the template file, content of file with tpl! I think the problem is that you don't add in html required form params.
Comment: hi. see my tpl file sample. like wise i m printing all the form fields
Comment: -1 This is not the standard way of [overriding themable output](https://www.drupal.org/node/341628).
Comment: This is not standard way but there is no standard way to override theme_hook with 'function' param not for all theme('key').

form rendering through tpl file


Does the nonexistence of $\in$-cycles imply the nonexistence of an infinite descending $\in$-sequence?

Question: We are working over the theory of (ZFC - {Foundation}). I know that, in (ZFC - {Foundation}), the nonexistence of an infinite descending $\in$-sequence implies Foundation. However, I am considering the theory $T$ that consists of (ZFC - {Foundation}), along with an infinite set of axioms that collectively say there are no $\in$-cycles. So for example, one axiom would be $\neg \exists x (x \in x)$, another would be $\neg \exists x \exists y (x \in y \in x)$, another would be $\neg \exists x \exists y \exists z(x \in y \in z \in x)$, and so on. Does the theory $T$ prove that there is no infinite descending $\in$-sequence? Or, is there a model of $T$ where there is an infinite descending $\in$-sequence?
Answer: No, the nonexistence of cycles does not imply the nonexistence of descending chains.
We can build a model of $\mathsf{ZF-Foundation+NoCycles}$ in which there is a descending $\in$-sequence as follows. This is a bit tedious, but here is a sketch:
We define our model in ordinal-indexed stages. $A_0$ consists of infinitely many elements, $a_i$ ($i\in\mathbb{Z}$), with the relation $\varepsilon$ (to distinguish it from true set elementhood) defined as $a_i\varepsilon a_j$ iff $i<j$. Having defined $A_\alpha$ for an ordinal $\alpha$, we build $A_{\alpha+1}$ as follows:

Let $$New_\alpha=\{X\subseteq A_\alpha: \forall x\in A_\alpha(X\not=\{y\in A_\alpha: y\varepsilon x\})\}$$ be the set of subsets of $A_\alpha$ not yet "named" by an element of $A_\alpha$. For example, we'll always have $A_\alpha\in New_\alpha$.

We set $A_{\alpha+1}=A_\alpha\sqcup New_\alpha$, with the $\varepsilon$ relation extended in the obvious way. (The reason we only add in "new" sets is to preserve extensionality.)

Finally, for limit $\lambda$ we let $A_\lambda$ be the direct limit of the $A_\alpha$s for $\alpha<\lambda$ (basically, "take unions").

By continuing through the ordinals, we get a model of $\mathsf{ZF-Foundation+NoCycles}$ in which there is an infinite descending $\in$-chain.


Criando um arquivo executável de um programa python em windows 10

Question: Sou usuário do BackBox Linux mas preciso gerar um executável para um programa escrito em Python. Instalei o Windows 10 Pro em VMWare com Python 2.7 e Python 3.4. Utilizo a IDE Pycharm e IDLE. Instalei o pyinstaller através do pip, mas quando tento:
<code>pyinstaller -F --clean script.py
</code>
Recebo o seguinte erro:"failed to create process" Alguma ideia? Como resolver?
Alguma outra maneira de criar um executável?
Comment: Olhando no SO em inglês, parece que é um problema com a instalação do pyinstaller. O que acontece se vc rodar `pyinstaller --version`? Seu sistema de arquivos tem [diretórios com espaços no nome](http://stackoverflow.com/questions/30620172/pyinstaller-version-failed-to-create-a-process)?
Comment: @hugomg, meu SO está em inglês. Vou fazer o teste e te informo!
Comment: Eu estava falando do StackOverflow.com em inglês, não do sistema operacional hahaha :)
Comment: >pip install pyinstall
Requirement already satisfied (use --upgrade to upgrade): pyinstall in c:\program files\python36-32\lib\site-packages
Comment: @hugomg, hahahah. Foi engraçado! Obrigado
Comment: pyinstaller --version
'pyinstaller' is not recognized as an internal or external command,
operable program or batch file.
Comment: A segunda mensagem de erro é pq o executável do pyinstaller nao está no seu PATH.
Comment: pyinstaller --version
3.2                                        agora deve funcionar!
Comment: Eu já não gosto muito do Windows... Há alguma maneira de gerar o EXE no Linux?
Comment: Deve dar mas gerar executável de window no Linux sempre é mais chatinho.
Comment: Gerou o EXE mas não rodou no próprio Windows: "the program cant start because msvcr100.dll is missing...
Comment: Uma vez precisei fazer isso para um projeto da faculdade e segui o tutorial desse video: https://www.youtube.com/watch?v=GSoOwSqTSrs Ele explica certinho como fazer pra não ter conflito com as bibliotecas que vc utilizar e tudo mais.
Answer: O erro "the program cant start because msvcr100.dll is missing:" pode ser resolvido instalando o Microsoft Visual C++.


How can i populate data from a reference node into another content type?

Question: I have two content types. hospitals and referral form. I would like to pull data from the hospital form automatically, example hospital name, address, contact etc when the user fills in the name of the hospital in the referral form.
I have used entity reference but i cant get it to work. It only gets the URL of the node but not the other fields. And also i have used autofill but it only works for a single content type.
If any one has done this before or if anyone has an idea, please do help. looking forward to your responses.
Answer: Take a look at entityreference_autofill

The Entity reference autofill module gives Entity reference fields an option to populate other form fields with data from selected referenced entities.
Comment: Thanks Andre. I have looked at the module but it only works for the content type that is referenced. Or may be i'am missing something. Have you used it before for such a case?
Comment: "If you plan to load the referenced values from another entity type or bundle, you will need to add another instance of the same field to the referenced entity (source).
"
Comment: Thanks. I managed to do it using field collections and Autofill. Thanx again


How do I get computed column using db_select?

Question: I require sum(points)? Any help on what to add in the sample code given below?
$query = db_select('digitaliq_question_points','n')
  ->fields('n',array('points'))
  ->condition("node_id", $node->nid, '=')
  ->condition('n.fld_group', $fields, 'IN');

$points = $query->execute()->fetchAll();

Answer: You can make use of the addExpression() method:
$query = db_select('digitaliq_question_points','n')
  ->fields('n',array('points'))
  ->condition("node_id", $node->nid, '=')
  ->condition('n.fld_group', $fields, 'IN');

$alias = $query->addExpression('SUM(points)', 'sum_of_points');

$points = $query->execute()->fetchAll();

Obviously that might need to change slightly based on your return value/grouping requirements but that's the method you're looking for.


Dynamic object method invocation using reflection in scala

Question: I'm looking to create a way to dynamically call logic depending on template id within scala. So template id 1 calls logic a, template id 2 call logic b, etc. The logic will be diverse but will have the same inputs/outputs. Also the number of different template ids will get into the thousands and will not be known ahead of time, so a loose coupling feels the way to go.
I've started looking at reflection to do this using scala 2.11.1 and can statically use reflection when I know the logic to be used ahead of time but have not found the correct way to dynamically use reflection, so for example passing in template id 2 will call logic b.
Below is a cut down example showing how the static version works and the skeleton I have so far for the dynamic version.
package thePackage

import scala.reflect.runtime.{universe => ru}

trait theTrait { def theMethod(x: String): Unit }

// the different logic held in different objects
object object1 extends theTrait {
  def theMethod(x: String) = { println("a " + x ) }
}

object object2 extends theTrait {
  def theMethod(x: String) = { println("b " + x ) }
}

object object3 extends theTrait {
  def theMethod(x: String) = { println("c " + x ) }
}

// run static/dynamic reflection methods
object ReflectionTest {

  // "static" invocation calling object1.theMethod
  def staticInvocation() = {
    val m = ru.runtimeMirror(getClass.getClassLoader)
    val im = m.reflect(thePackage.object1)
    val method = ru.typeOf[thePackage.object1.type]
                   .decl(ru.TermName("theMethod")).asMethod
    val methodRun = im.reflectMethod(method)
    methodRun("test")
  }

  staticInvocation

  // "dynamic" invocation using integer to call different methods
  def dynamicInvocation( y: Integer) = {
    val m = ru.runtimeMirror(getClass.getClassLoader)
    val module = m.staticModule("thePackage.object" + y)
    val im = m.reflectModule(module)

    //  stuck... static approach does not work here

  }

  dynamicInvocation(1)
  dynamicInvocation(2)
  dynamicInvocation(3)

}

What needs to be added/changed to the dynamicInvocation method to make this work, or should I be using a different approach?
Answer: You need to get an instance mirror for your module, on which you can reflect the method.
def dynamicInvocation( y: Integer) = {
  val m = ru.runtimeMirror(getClass.getClassLoader)
  val module = m.staticModule("thePackage.object" + y)
  val im = m.reflectModule(module)
  val method = im.symbol.info.decl(ru.TermName("theMethod")).asMethod

  val objMirror = m.reflect(im.instance)
  objMirror.reflectMethod(method)("test")
}

Answer: It seems that TermName method in above solution has been replaced by newTermName and also the info.decl seems to not work. Below line worked for me
val method = im.symbol.typeSignature.member(ru.newTermName("testMethod")).asMethod


Solving Differential Equations faster

Question: I'm currently taking a differential equations course and we've had a few quizzes and exams where I'm solving a High Order Differential Equation (non-homogeneous) and I have to stop mid-problem because what I'm currently doing will not work. (I'm talking about, for example, if the equations is
$$
y''''+2y'''+2y''=3x^2
$$
then I will get the complement solution, no biggie, but when I try to get the particular solution, I do $(Ax^2 + Bx + C)$ , and after attempting to solve it, we know it won't work. So then I try $(Ax^3 + Bx^2 + C)$, and after doing the work again, STILL IT DOESN'T WORK! Not until I do $(Ax^4 + Bx^3 + Cx^2 + Dx + E)$ Does it work, BUT AFTER ALL THAT TIME I'VE LOST LIKE 7 MINUTES OR MORE AND MY EXAM/QUIZZES SCORES ARE AFFECTED.
Is there a way of knowing ahead of time to start with $Ax^4....$ rather than $Ax^2$ ?
Comment: I'd start with the exponent corresponding to the highest order differential. If you get zeros, you find out quickly anyway.
Comment: The equation is linear. If you have computed the left hand side for $Ax^2+Bx+C$ then the left hand side for $Dx^3 + Ax^2 + Bx + C$ is found by simply computing it for $Dx^3$ and adding it to the result, you don't have to recompute all the terms. Also to see why $x^4$: look at the equation and note that the smallest derivative on the left hand side is $y''$ and if this is supposed to give $x^2$ then $y$ has to contain at least $x^4$ as a derivative on a power reduces the exponent by $1$.
Answer: The lowest order derivative in $y'''' + 2y''' + 2y''$ is second-order. That means any $n$th degree polynomial for $y$ will result in an at most $n-2$th degree polynomial. Since your inhomogeneous term is degree 2, you need at least a fourth degree polynomial for your trial function.
In general, if your differential operator has constant coefficients and lowest order $n$, and your inhomogeneous term is a polynomial of degree $m$, your trial function will need to be a polynomial of degree $n+m$.

Solving Differential Equations faster


Solve $\left(1+{y'}^2 \right) y''' - 3{y''}^2 y' = 0$ with Legendre Transformation

Question: I have got a question concerning the use of Legendre Transformation for solving ordinary differential equations.
We did this stuff in an ordinary differential equations class. The professor stated the definition. Unfortunately I could not find any examples of this on the web.
Now, I am going to repeat the class in order to specify the topic.
To begin with, let's clarify the notation: Derivatives with respect to $t$ are denoted by dots above letters. Derivatives with respect to $k$ are denoted by an apostrophe.
    Let $y(t)$ be the solution of an ODE. Equation 1 is the definition of the Legendre Transformation.
    \begin{align}
 y(t)&=kt-n(k)\\
 \therefore \dot{y}&=k\\
 \therefore \dot{y}&=k+t \dot{k} - \dot{n}\\
 \therefore \frac{dn}{dt}&=x \frac{dk}{dt}\\
 \therefore \frac{dn}{dk}&=t\\
 \end{align}
    So,
    \begin{equation}
  \frac{d^2 y}{dt^2}=\frac{dk}{dt}=\frac{1}{\frac{dt}{dk}}=\frac{1}{\frac{d(\frac{dn}{dk})}{dk}}=\frac{1}{\frac{d^2 n}{dk^2}}=\frac{1}{n''}
 \end{equation}
    Up to here, I think I understand pretty much everything. $k$ is the slope of $y$ and $-n$ is the distance from the origin to the point of intersection of the tangent of $y$ with the $y$ axis.
Now comes my real question:
How to solve this ODE via Legendre Transformation?
    $$\left(1+{y'}^2 \right) y''' - 3{y''}^2 y' = 0$$
I have no idea how to do this and would be glad for any help.
    Furthermore, why can't I find any example of a solution of an ODE via a Legendre Transform?
Comment: The most obvious question would seem to be what that ODE looks like upon making the above substitution. (Though, the above ODE is actually a function of $y'$ alone. So it may be the case that, say, $y'(t)$ is what should be Legendre-transformed. Can't tell for sure.)
Answer: $$(1+y'^2)y'''-3y''^2y'=0$$
Transformation : $\quad y'(t)=z \quad\to\quad (1+z^2)z''-3z'^2z=0$
$$\frac{z''}{z'}=3\frac{z'z}{1+z^2}$$
$\frac{3}{2}\ln|1+z^2|=\ln|z'|+$constant.
$$(1+z^2)^{3/2}=c_1z'=c_1\frac{dz}{dt} \quad\to\quad dt=c_1\frac{dz}{(1+z^2)^{3/2}}$$
$$t=c_1\int \frac{dz}{(1+z^2)^{3/2}} =-c_1\frac{z}{\sqrt{1+z^2}}+c_2$$
$(t-c_2)^2(1+z^2)=c_1^2z^2 \quad\to\quad z^2=\frac{(t-c_2)^2}{c_1^2-(t-c_2)^2}$
$$z=\pm\frac{t-c_2}{\sqrt{c_1^2-(t-c_2)^2}}$$
$$y=\pm\int \frac{(t-c_2)dt}{\sqrt{c_1^2-(t-c_2)^2}} = \pm\sqrt{c_1^2-(t-c_2)^2}+c_3$$


How to open pop up window in javascript in drupal 6?

Question: I have made a custom module in Drupal 6 and want to implement the following: When I click on my link it should open in a pop up window in javascript. But I don't know it how to implement pop up window in Drupal.
Please help me.
This is my link code.
l('open pop up','admin/state_user/stateadmin/state/user/disable/'
  . $result -> uid, array('attributes' => array('title' => t('open pop up'))),TRUE);

Comment: You can achieve popup using CTools API. Check examples of CTools contributed modules. You will find a code to open modal popup by clicking on link.
Comment: I just wnat to use pop up window in java script only....
Answer: Use the Colorbox module.

Colorbox is a light-weight customizable lightbox plugin for jQuery. This module allows for integration of Colorbox into Drupal.
Images, iframed or inline content etc. can be displayed in a overlay
  above the current page.

You need to activate the iframe method and add the custom iframe class to your link.
Answer: Though window.open is not considered as good practice but still if you want to open window in D6 using this then you can do like this.
Create a link
<?php echo l('product', 'product', array('attributes' => array('id' => 'product-link'))); ?>

Add JavaScript file & add it to theme.info or call it in some custom module.
Write javascript code as
$(document).ready(
function() {
  $("#product-link").click(
    function(e) {
      openWindow();
      e.preventDefault();
    }
  );
}
);


What does this 'Led' or 'Σed' indication mean?

Question: In Mark Levine's The Jazz Theory Book, there is this example to be played on the piano:
The Jazz Theory Book, figure 3-149

I've never had any piano training/lessons, so I don't really know the indications.
What does 'Led' (or is it 'Σed') mean?
Comment: `Ped.` for [pedale](http://en.wikipedia.org/wiki/Glossary_of_musical_terminology#P).
Comment: Does this answer your question? [Why does the pedal sign look like "Leo"?](https://music.stackexchange.com/questions/111755/why-does-the-pedal-sign-look-like-leo)
Comment: Interesting that the notes written Eb are accompanied by a G7#5 chord. Should they be a D#?
Comment: @Tim Seeing as the E♭ resolves down to D, I'd say that E♭ is correctly spelt, and that the chord symbol is wrong. I'd analyse it as G ♭13. The G root resolves to C, so it may fairly be taken as a dominant chord. F is there, so, dominant 7th. The E♭ is above the 7th and may thus be analysed as the 13th.
Answer: It's actually Ped, and just instructs the pianist to use the sustain pedal, in this   section.
Answer: It means to use hold down the damper pedal until the end of the dash. The effect is that every note you play while the pedal is held down is sustained.
There are actually a few variations of this notation with another popular form of it shown here. The idea behind the other common form is to show where you press the pedal (the PED) and where you release the pedal (the *).
Answer: This is a pedale marking, and there is even a Unicode encoding for it, U+1D1AE, see here:
Or copied in (unfortunately very small):
Comment: FYI: the copied, quoted character does not display properly (on macOS Monterey).
Answer: It actually means "Ped" for pedale. The pedale symbol directs you to step on the pedal. If you see an asterisk beside it, it indicates that you should release the pedal.
 So you should stop using the pedal after the asterisk. I hope this helps.
Comment: See https://music.stackexchange.com/questions/111755/why-does-the-pedal-sign-look-like-leo


Showing that this function on $\mathbb{R}^{2}$ is continuous

Question: Let, $f(x,y) = \frac{y^{2}-x^{2}y}{\lvert y-x^{2}\rvert}$ when $y \neq x^{2}$ and $0$ otherwise.
I was thinking about using the squeeze theorem and then taking the limit as $y \rightarrow x^{2}$ but I couldn't establish any meaningful inequalities. Any hints?
Answer: Hint : $y^2 - x^2y = y(y-x^2)$