text:
Q: File Copier keeps failing(caught the error, no error code) I've been making an installer for a few of my friends for adding mods to Minecraft.
I created a method(inside the class FileHandling) called fileChooserCheck. What it does is it gets the directory for installation defined by the user by a JFileChooser and sets that to modDir, or, if the user doesn't specify, it sets the installation directory to the default directory, which is the File 'defaultDir'. Whenever I run the method fileChooserCheck, it doesn't change the Path modDir, when I try to call it(modDir) it returns null.
How can I make it so that fileChooserCheck actually changes the Path modDir?
Also, why is my installation failing?( I just removed modDir altogether and set the Path manually and it still failed)
If you see anything in my code that you is sloppy and/or could/needs to be improved please tell me, I've only been programming with Swing for a few days, and Java for almost a week[I only know one other programming language[which is pretty basic)]
Main Class
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.nio.file.Path;

import javax.swing.*;

public class MainInstaller extends JFrame {
    private final long serialVersionUID = 1L;

    String moddir;
    Path modDir;
    URI bioForums = URI.create("http://bio-mc.com/forum");
    URI thread = URI.create("http://google.com");
    String username = System.getProperty("user.name");
    String mcDir = "C://Users//" + username + "//AppData//Roaming//.minecraft";
    File defaultDir = new File("C://Users//" + username +          "//AppData//Roaming//.minecraft");
    Font consoleFont = new Font("", Font.PLAIN, 13 + 1/2);
    Font checkFont = new Font("", Font.PLAIN, 14 + 1/2);
    String[] minimapsArray = { "REI's Minimap", "Zan's Minimap" }; //An array of optifine versions, get manually later
    Object minimap;
    int yInterval = 22;
    boolean enabled = false;
    boolean optifine, invtweaks, armorhud, statuseffecthud, tabbychat, spc, chatbubbles, map = true;
    boolean fcLaunched = false;

    JPanel installPanel, modsPanel, consolePanel;
    Box box, box1;
    JLabel title;
    JLabel modsel;
    JLabel author;
    JTabbedPane tabbedpane = new JTabbedPane();
    JComboBox<?> minimaps; //The drop down menus to select the versions of optifine and invtweaks
    JButton installButton;
    JButton fileButton, forumButton, threadButton;
    JTextArea console;
    JTextField mcdir;
    JFileChooser fc;

    public MainInstaller() { //MainInstaller Constructor
        super("BlackCrew ModPack Installer"); //Sets the title of the frame

        //Defines the title a bit more and adds it to the box
        box = Box.createVerticalBox();
        title = new JLabel("BlackCrew Modpack");
        title.setFont(new Font("Impact", Font.PLAIN, 38 + 1/2));
        title.setAlignmentX(CENTER_ALIGNMENT);
        box.add(title);

        //The First Tab(Installer)
        installPanel = new JPanel();
        installPanel.setLayout(null);
        Insets insets = installPanel.getInsets();
        installButton = new JButton("Install!");
        installButton.setFont(new Font("", Font.PLAIN, 20));
        Dimension size = installButton.getPreferredSize();

        mcdir = new JTextField();
        mcdir.setText("C:/Users/" + username + "/AppData/Roaming/.minecraft");
        mcdir.setFont(new Font("", Font.PLAIN, 13));
        size = mcdir.getPreferredSize();
        mcdir.setBounds(139 + insets.left, 80 + insets.top, size.width + 5,    size.height);
        mcdir.setEditable(false);

        fileButton = new JButton("...");
        size = fileButton.getPreferredSize();
        fileButton.setBounds(mcdir.getX() + 280, mcdir.getY() - 1 + insets.top, size.width, size.height + 3);
        fileButton.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e) {
                fcLaunched = true;
                //Create the FileChooser and define it a bit
                if (fc == null) {
                        fc = new JFileChooser("C://Users//" + username + "//AppData//Roaming//.minecraft");
                            fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                    }

                //Show the file Chooser
                int returnVal = fc.showOpenDialog(fileButton);

                fc.setSelectedFile(defaultDir);

                //modDir = moddir.toPath();

                //Process the results
                if(returnVal == JFileChooser.APPROVE_OPTION) {
                    mcdir.setText(fc.getSelectedFile().getPath());
                }
            }
        });

        forumButton = new JButton("BioCraft Forums");
        forumButton.setFont(new Font("", Font.PLAIN, 13));
        size = forumButton.getPreferredSize();
        forumButton.setBounds(1 - 1/2 + insets.left, 10 + insets.top, size.width, size.height);
        forumButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    Desktop.getDesktop().browse(bioForums);
                } catch (IOException e1) {
                    e1.printStackTrace();
                    System.out.println("Failed to Launch the BioCraft Forums");
                }
            }
        });

        threadButton = new JButton("Installer Thread");
        threadButton.setFont(new Font("", Font.PLAIN, 13));
        size = threadButton.getPreferredSize();
        threadButton.setBounds(459 + insets.left, forumButton.getY() + insets.top, size.width, size.height);
        threadButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                try {
                    Desktop.getDesktop().browse(thread);
                } catch (IOException e) {
                    e.printStackTrace();
                    System.out.println("Failed to Launch the Installer Thread");
                }
            }
        });

        author = new JLabel("Developed by n1ghtk1n9");
        author.setFont(new Font("", Font.PLAIN, 13));
        author.setForeground(Color.RED);
        author.setBounds(235 + insets.left, 1 + insets.top, size.width + 20, size.height);

        installButton.setBounds(139 + insets.left, mcdir.getY() + 50 + insets.top, mcdir.getWidth() + fileButton.getWidth(), size.height + 40);

        installPanel.add(author);
        installPanel.add(forumButton);
        installPanel.add(threadButton);
        installPanel.add(installButton);
        installPanel.add(mcdir);
        installPanel.add(fileButton);

        //The Second Tab(Mod Selection)
        modsPanel = new JPanel();
        modsPanel.setLayout(null);
        insets = modsPanel.getInsets();
        JLabel modsel = new JLabel("Select the mods you installed");
        modsel.setFont(new Font("", Font.BOLD, 15));
        size = modsel.getPreferredSize();
        modsel.setBounds(5 + insets.left, 2 + insets.top, size.width + 15, size.height);

        //Adds all the mod checkboxes
        JCheckBox optiBox = new JCheckBox("Optifine");
        optiBox.setFont(checkFont);
        size = optiBox.getPreferredSize();
        optiBox.setBounds(2 + 1/2 + insets.left, 2 + yInterval + insets.top, size.width, size.height); //Y = 23
        optiBox.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                optifine = !optifine;
            }
        });

        JCheckBox invBox = new JCheckBox("InvTweaks");
        invBox.setFont(checkFont);
        size = invBox.getPreferredSize();
        invBox.setBounds(2 + 1/2 + insets.left, 2 + (yInterval*2) + 1/2 + insets.top, size.width, size.height); //Y = 44
        invBox.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                invtweaks = !invtweaks;
            }
        });

        JCheckBox armorhudBox = new JCheckBox("Armor HUD"); //Also automatically installs bspkrs-core
        armorhudBox.setFont(checkFont);
        size = armorhudBox.getPreferredSize();
        armorhudBox.setBounds(2 + 1/2 + insets.left, 2 + (yInterval*3) + insets.top, size.width, size.height); //Y = 65
        armorhudBox.setToolTipText("Also installs 'bskprs core'");
        armorhudBox.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                armorhud = !armorhud;
            }
        });

        JCheckBox statusBox = new JCheckBox("Status Effect HUD"); //Also automatically installs bspkrs-core
        statusBox.setFont(checkFont);
        size = statusBox.getPreferredSize();
        statusBox.setBounds(2 + 1/2 + insets.left, 2 + (yInterval*4) + insets.top, size.width, size.height); //Y = 86
        statusBox.setToolTipText("Also installs 'bskprs core'");
        statusBox.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                statuseffecthud = !statuseffecthud;
            }
        });

        JCheckBox tabbyBox = new JCheckBox("TabbyChat");
        tabbyBox.setFont(checkFont);
        size = tabbyBox.getPreferredSize();
        tabbyBox.setBounds(2 + 1/2 + insets.left, 2 + (yInterval*5) + insets.top, size.width, size.height); //Y = 108
        tabbyBox.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                tabbychat = !tabbychat;

            }
        });

        JCheckBox spcBox = new JCheckBox("SinglePlayerCommands");
        spcBox.setFont(checkFont);
        size = spcBox.getPreferredSize();
        spcBox.setBounds(2 + 1/2 + insets.left, 2 + (yInterval*6) + insets.top, size.width, size.height);
        spcBox.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                spc = !spc;

            }
        });

        JCheckBox mapBox = new JCheckBox("MiniMap");
        mapBox.setFont(checkFont);
        size = mapBox.getPreferredSize();
        mapBox.setBounds(2 + 1/2 + insets.left, 2 + (yInterval*7) + insets.top, size.width, size.height);
        //map = mapBox.isSelected();
        mapBox.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                enabled = !enabled;
                minimaps.setEnabled(enabled);
                map = !map;

            }
        });

        JCheckBox bubbleBox = new JCheckBox("Chat Bubbles");
        bubbleBox.setFont(checkFont);
        size = bubbleBox.getPreferredSize();
        bubbleBox.setBounds(2 + 1/2 + insets.left, 2 + (yInterval*8) + insets.top, size.width, size.height);
        bubbleBox.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                chatbubbles = !chatbubbles;

            }
        });

        minimaps = new JComboBox<Object>(minimapsArray);
        minimaps.setFont(checkFont);
        size = minimaps.getPreferredSize();
        minimaps.setBounds(83 + insets.left, 7 - 31/32 - 1/32 + (yInterval*7) + insets.top, size.width, size.height - 6 - 1/2);
        minimaps.setEnabled(false);
        minimap = minimaps.getSelectedItem();

        //The Third Tab(Console)
        consolePanel = new JPanel();
        consolePanel.setLayout(null);
        console = new JTextArea("Launched the BlackCrew ModPack Installer!", 600, 400);
        console.setFont(new Font("", Font.PLAIN, 13 + 1/2));
        console.setBounds(0, 0, 600, 400);
        console.setEditable(false);
        console.setWrapStyleWord(true);
        console.setLineWrap(true);

        consolePanel.add(console);
        console.setCaretPosition(console.getDocument().getLength());

        modsPanel.add(modsel);
        modsPanel.add(optiBox);
        modsPanel.add(invBox);
        modsPanel.add(armorhudBox);
        modsPanel.add(statusBox);
        modsPanel.add(tabbyBox);
        modsPanel.add(mapBox);
        modsPanel.add(spcBox);
        modsPanel.add(bubbleBox);
        modsPanel.add(minimaps);

        tabbedpane.addTab("Installer", installPanel);
        tabbedpane.addTab("Mod Selection", modsPanel);
        tabbedpane.addTab("Console", consolePanel);

        //Add everything to the frame
        add(box, BorderLayout.NORTH);
        add(tabbedpane);
    }

    public static void main(String[] args) throws IOException { //Main Method
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        } catch(UnsupportedLookAndFeelException e) {
            e.printStackTrace();

        } catch (ClassNotFoundException e) {
            e.printStackTrace();

        } catch (InstantiationException e) {
            e.printStackTrace();

        } catch (IllegalAccessException e) {
            e.printStackTrace();

        }

        final MainInstaller frame = new MainInstaller();
        Insets insets = frame.getInsets();
        frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
        frame.setSize(600, 400);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        frame.setResizable(false);

        final FileHandling file = new FileHandling();
        file.createBaseFolder();

        frame.installButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if(frame.optifine == false && frame.invtweaks == false && frame.armorhud == false && frame.chatbubbles == false && frame.spc == false && frame.statuseffecthud == false) {
                    JOptionPane.showMessageDialog(frame, "No mods are enabled");
                } else {
                    // (?) Install mods here?
                    try {
                        file.copyMods();
                        System.out.println("Installing Mods");
                        System.out.println("Source: " + file.invSource);
                        System.out.println("Target:" + file.invTarget);

                    } catch (IOException e1) {
                        e1.printStackTrace();
                        System.out.println("Error!" + e);

                    }
                }
            }});
    }
}

FileHandling Class
import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.nio.file.*;
import java.nio.file.StandardCopyOption.*;

public class FileHandling {
    MainInstaller mi = new MainInstaller();

    Path modDir = mi.modDir;
    Path source = Paths.get("C://Users//Gannon//Desktop//Java//workspace//ModPack Installer//test.txt");
    Path target = Paths.get("C://Users");

    Path invSource = Paths.get("mods//invtweaks.jar");
    Path invTarget = Paths.get(mi.modDir + "//InventoryTweaks-MC1.6.2-1.55-b56.jar");

    public void createBaseFolder() {
        try {
            System.out.println(mi.moddir);

        } catch(Exception e) {
            System.out.println("Folder Creation Failed!"); // (?)Remove and   replace with in-program error

        }
    }

    public void fileChooserCheck() {
        if(mi.fcLaunched == false) {
            mi.modDir = mi.defaultDir.toPath();
            System.out.println("Unchanged: " + mi.modDir);
        } else if(mi.fcLaunched == true) {
            mi.modDir = mi.fc.getSelectedFile().toPath();
            System.out.println("Changed: " + mi.modDir);
        }
    }

    public void copyMods() throws IOException {
        fileChooserCheck();
        try {
            if(mi.invtweaks == true) {
                Files.copy(invSource, invTarget);
                System.out.println("Trying to copy!");
            }

        } catch (IOException e) {
            System.out.println("The Copying Failed!" + e);
        }
    }
}

A: You have used two forward slashes in the path (//):
("C://Users//Gannon//Desktop//Java//workspace//ModPack Installer//test.txt");

Use a single forward slash or use two backward slashes because you need to escape those (\\).
I hope this helps.


text:
Q: Do I risk breaking documents by updating my TeX distribution? I ran into a feature missing because its package was out to date and started the MikTeX update utility for the first time after installing MikTeX in February. The updater found dozens of packages that can be updated. Among these packages were several that I have used extensively over the last few months.
Do I risk breaking my existing documents by updating my packages? Or do updates typically support backwards compatibility?

A: Unfortunately, yes.
Breaks can come from several sources:

*

*Sometimes, packages you have used are retired (and no longer in the default distribution) or withdrawn altogether.

*Packages may have incompatible changes (hopefully documented, but it will take some time to adapt your document to the new conventions)

Linux distribution often tend to have a fine-grained packaging of TeX, LaTeX, and friends, and an update of the Linux distro can become a real adventure because the packaging has changed; including a search of the needed style files in the package manager. SuSe has dropped the TeX distribution altogether, so you need a CTAN DVD in addition to your SuSe installation media.
Minor issues are:

*

*Internal commands have changed and the new version of the package cannot work with the temporary files of the old version. Deleting all auxilliary files and compiling your document anew helps here.

A: Generally speaking, there's always a risk that something will break and the usual caveats thus apply: never update on a deadline, check that the output of your document is satisfactory, etc.
That said, backward compatibility is, as David says in the comment, a primary concern of package developers. TeX and its associated programs have always been presented as very good at compatibility (sometimes a little bit too much, maybe), and it's one of the system's great strength.  If your first installation dates from February this year it's very recent with respect to the overall age of TeX and LaTeX, and you should be absolutely fine updating all the packages.
Obviously, we'll need to know which packages you mean in order to give more details.  The package authors may very well have documented the changes too.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Start/access emulator from ssh or with built images For a school project i have to modify AOSP to create our own custom android (7.1.2 version).
We setup a server (ubuntu server 17) who can build it, and it works.
The problem is when we want the emulator to test the builted android.
We can't start it from the server, cause it doesn't have a display.
We tried to start it with my computer (with ubuntu 18 os), to do this i downloaded Android Studio and setup an AVD with Android 7.1.1, and when i start the emulator i specify -system and -ramdisk, as i see here: custom android emulator
It starts sometime (sometime i have just blackscreens) but i didn't see my edits in the settings app (i add a "rom name" value)
I read something about "emulator networking" but it didn't seems to solve my problem, i want to see the android built running in a window.
Can anyone help me ?
Thank you in advance.


text:
Q: laravel-5 How can i specify tags which not be escaped by blade? I am using Laravel and imperavi redactor on my website.
How can i specify list of the tags which will be not escaped by Blade?
For example redactor using tag p and if i just escape all data it will be unformatted, without paragraphs. But i need some tags for formatting and still want to be safe from XSS injections. Is laravel have an ability to do this or i need to use some other stuff?
Of course i can {!! $data !!} data but if i do this all data will be unescaped and it's scary.

A: Blade either will escape all or nothing. Only choice is to use your own or 3rd party parser that will escape needed tags for you.
One package that might help you is https://packagist.org/packages/mews/purifier


text:
Q: Vaadin 14 Flow and SEO, PWA I'm going to start working on the brand-new web application with Vaadin 14 Flow (pure Java). Right now, I'm unable to find the clear information about - will my Vaadin 14 Flow (pure Java) web application be SEO(Search Engine Optimization) friendly out of the box or no? And if no - what additional steps should I implement in order to achieve this? Also, is it worth to add PWA support to the application and how complex is it in case of Vaadin 14 Flow (pure Java)?

A: This question is on the fringe of StackOverflow policy, as it is potentially quite wide, so I am just answering briefly on top level. This question is seldomly asked in context of Vaadin applications, as they tend to be mostly implemented for company internal use, and thus SEO is not a requirement. Vaadin stance regarding SEO is neutral. So this is mostly application implementation level question. What you need to know is, that Vaadin's component implementations are web components, thus their internals are protected by shadow DOM. This means, if you have say ComboBox and you have set label to it, the label is not necessarily exposed to search index crawlers. In most cases it is not even necessary. Vaadin's layout components place components in light DOM, so if you use native html components representations like Span, Div, H1, H2, ...  for the texts that you want to be exposed to SEO, you will be ok. Your text content will be exposed to the indexing crawlers. The rest is just about proper SEO copywriting, and that is naturally out of scope of Vaadin. You may be also interested in GoogleAnalyticsTracker.

A: A web app with Vaadin 14 is the perfect choice for companies requiring quick, agile, low memory solutions.
Where will your code be running? On a central server with Java enterprise architecture! What are the benefits to this setup? There are many benefits in one, it provides scalability to meet most customers needs without having any additional cost beyond storage and bandwidth usage.
Benefits of a scalable solution include the ability to add resources when needed because only  one instance of the app is necessary if there's enough RAM and CPU capacity on the system or hardware that can be added. Another benefit includes portability- which means an organization can take their application data and settings wherever they want without proprietary reliance on software licenses or third party services.


text:
Q: How to recursively delete all folders of a folder tree unless they contain a file with certain file extension? How to go though a directory tree and delete all directories unless they contain a file with a particular file extension?
I tried Robocopy thinking the folders were empty. But all the folders have hidden files. So I need something that will take every folder in a directory that does not have a .pdf for example in it and delete it.

A: The task is to delete all directories/folders not containing a PDF file and also not containing a subdirectory/subfolder containing a PDF file. Let us look on an example to better understand the directory/folder deletion task.
The directory C:\Temp contains following subfolders and files:

*

*Folder 1

*

*Subfolder A

*

*File 1A.txt

*Subfolder B

*

*File 1B.txt

*Subfolder C

*

*File 1C.pdf

*File 1.cmd

*Folder 2

*

*Subfolder A

*Subfolder B

*

*File 2B.pdf

*Subfolder C

*

*File 2C.pdf

*File 2.jpg

*Folder 3

*

*Subfolder A

*

*File 3A.log

*Subfolder B

*File 3.doc

*Last Folder & End

*

*Subfolder A

*

*Last File A.xls

*Subfolder B

*Subfolder C

*

*Last File C.pdf

A folder is formatted bold. A hidden folder is formatted bold and italic. A hidden file is formatted italic.
The wanted folders and files after running the batch file should be:

*

*Folder 1

*

*Subfolder C

*

*File 1C.pdf

*File 1.cmd

*Folder 2

*

*Subfolder B

*

*File 2B.pdf

*Subfolder C

*

*File 2C.pdf

*File 2.jpg

*Last Folder & End

*

*Subfolder C

*

*Last File C.pdf

This result can be achieved by executing following batch file:
@echo off
goto MainCode

:ProcessFolder
for /F "delims=" %%I in ('dir "%~1" /AD /B 2^>nul') do call :ProcessFolder "%~1\%%I"
if exist "%~1\*.pdf" goto :EOF
for /F "delims=" %%I in ('dir "%~1" /AD /B 2^>nul') do goto :EOF
if /I "%~1\" == "%BatchFilePath%" goto :EOF
rd /Q /S "%~1"
goto :EOF

:MainCode
setlocal EnableExtensions DisableDelayedExpansion
set "BatchFilePath=%~dp0"
if exist "C:\Temp\" cd /D "C:\Temp" & call :ProcessFolder "C:\Temp"
endlocal

Doing something recursively on a directory tree requires having a subroutine/function/procedure which calls itself recursively. In the batch file above this is ProcessFolder.
Please read the answer on Where does GOTO :EOF return to? The command goto :EOF is used here to exit the subroutine ProcessFolder and works only as wanted with enabled command extensions. FOR and CALL as used here require also enabled command extensions.
The main code of the batch file first enables explicitly the command extensions required for this batch file and disables delayed environment variable expansion to process correct also folders with an exclamation mark in name. This is the default environment on Windows, but it is better here to explicitly set this environment because the batch file contains the command RD with the options /Q /S which can be really very harmful on execution from within wrong environment or directory.
The subroutine ProcessFolder is not at end of the batch file as usual with a goto :EOF above to avoid an unwanted fall through to the command lines of the subroutine after finishing the entire task. For safety reasons the subroutine is in the middle of the batch file. So if a user tries to execute the batch file on Windows 95/98 with no support for command extensions nothing bad happens because first goto MainCode is executed successfully as expected, but SETLOCAL command line, calling the subroutine and last also ENDLOCAL fail and so no directory was deleted by this batch file designed for Windows with cmd.exe as Windows command processor instead of command.com.
The main code sets also current directory to the directory to process. So C:\Temp itself is never deleted by this code because of Windows prevents the deletion of a directory which is the current directory of any running process or contains a file opened by a running process with file access permission set to prevent other processes to delete the file while being opened by the process.
Next is called subroutine ProcessFolder with argument C:\Temp to process this folder recursively.
Last the initial environment is restored which includes also initial current directory on starting the batch file if this directory still exists.
The command for /D is usually used to do something on all subdirectories of a directory. But this is not possible here because FOR always ignores directories and files with hidden attribute set. For that reason it is necessary to use command DIR to get a list of all subdirectories in current directory including directories with hidden attribute set.
The command line dir "%~1" /AD /B 2>nul is executed by FOR in a separate command process started with cmd.exe /C in background. This is one reason why this batch file is quite slow. The other reason is calling the subroutine again and again which cause internally in cmd.exe to save and restore environment again and again.
Please read the Microsoft article about Using Command Redirection Operators for an explanation of 2>nul. The redirection operator > must be escaped with caret character ^ on FOR command line to be interpreted as literal character when Windows command interpreter processes this command line before executing command FOR which executes the embedded dir command line with using a separate command process started in background.
For each subdirectory in a directory the subroutine ProcessFolder calls itself. The first FOR loop in the subroutine is left if a directory does not contain one more subdirectory.
Then the subroutine checks in current directory if there is at least one *.pdf file. The IF condition used here is true even if the directory contains only a hidden PDF file. In this case the subroutine is exited without doing anything as this directory contains definitely a PDF file and therefore must be kept according to the requirements of the folder deletion task.
Next is checked if the current directory still contains at least one subdirectory as in this case the current directory must be also kept as one of its subdirectories contains at least one PDF file.
Last the subroutine checks if the current directory contains by chance the batch file as this directory must be also kept to finish the processing of the batch file.
Otherwise the current directory is deleted with all files on not containing a PDF file and no subdirectories and also not the currently running batch file as long as Windows does not prevent the deletion of the directory because of missing permissions or a sharing access violation.
Please note that the batch file does not delete other files in a directory which is not deleted as it can be seen also on the example.
For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.

*

*call /?

*cd /?

*dir /?

*echo /?

*endlocal /?

*for /?

*goto /?

*if /?

*rd /?

*setlocal /?


text:
Q: Returning to wrong activity after application got killed by OS Some of the customers of my application claims that when they return to my application after it has been in background for a while they get to the activity they haven't left from. The view (activity) they leave is a form for which I provide all the staff with serializing data in onSavedInstanceState and recovering it on return. And what they say is that sometimes they return to 1 activity before the form (1 below in activity stack). How is this possible ?
So tested the whole thing. I put my app in background and killed it with DDMS. Also I just turned screen off, killed it with DDMS. Everything is fine. I stay in the form view and all form's data are recovered.
There is a situation that when I kill my app when it's in foreground (active). Then I indeed get pushed 1 activity back. But it's happening for all places in application, not only for the form. However it's really unlikely that OS will kill foreground application. Or am I wrong ?
Is there any other scenario this behavior may occur ?


text:
Q: Mysql query script weird first im sorry my english is not too good,
i just wondering about something i dont know and its weird for me
so, example : i have 2 tables in my mysql database
let say 1st table called "one" second one is "two"
if i want to CRUD from table "one" using PHP script, i dont need to use backtick --> ` <-- mark, i dont know how to call it in english, i just using, eg:
mysql_query("SELECT * FROM one WHERE id='1'");

but i dont know why, if i want to do the same for table "Two" i must use --> ` <-- mark, and it doesnt work if i not using that, its working if i use this :
mysql_query("SELECT * FROM `two` WHERE `id`='1'");

maybe some one know about this, so i will not think if its weird anymore :D
thank you, i hope you guys understand my language
regards
Yongki Agustinus

A: Your two table most likely named after some of mysql reserved word (or the name contains some non-alphanumeric symbol) and thus require additional formatting


text:
Q: open explorer and close sidebar with the same key I would like to use the View: Show Explorer command when the Sidebar is closed. And close the sidebar with the same key when the Sidebar is open.
So basically I want to let my Sidebar open with the Explorer by default (and also change the focus to the explorer by default), but also close the sidebar with the same key. This can be done with the when function in the vscode keyboard shortcuts, but I dont find the function which represents when the sidebar is open.
Already tried out: workbench.SideBar.visible: true 'sideBar.isOpen || sidebarIsOpen'
where are all these when functions listed in the documentation of VSCode?
just to be clear: it is one key which is used for two different shortcut actions - one is open+focus explorer and the other is toggle sidebar (but only when its open) - so it could also be named "close sidebar".

A: Try these keybindings in your keybindings.json:
  {
    "key": "ctrl+shift+e",             // when Explorer not open
    // "command": "workbench.view.explorer",   // either of these commands works
    "command": "workbench.files.action.focusFilesExplorer",
    "when": "!explorerViewletVisible"
  },
  {
    "key": "ctrl+shift+e",              // when Explorer open
    "command": "workbench.action.toggleSidebarVisibility",
    "when": "explorerViewletVisible"
  }

How did I find those context keys?  See Inspect Context Keys Utility.

*

*Open View/Help/Toggle Developer Tools

*Go to and clear (right-click) the Console in the Developer Tools

*Trigger the command: Developer: Inspect Context Keys from the Command Palette and click anywhere in the vscode window

*In the Console, a large object will be created and output.  Expand this object open so you can search in it.

*With focus in the Console, Ctrl/Cmd+F to open a find input.  For me, this appears at the very bottom and is tricky to see.

*Type what you want to find, like "explorer"

*I found 21 hits and looked at them all to see which were promising - you can Enter through them if focus is in the find input.

explorerViewletVisible looked most promising.  Then I looked through the KeyBoard Shortcuts for "view explorer" and then "sidebar" to find commands I thought would work.


text:
Q: How to enable electric-pair-mode in emacs 24 I have enabled electric pair mode according to instructions on this page: http://ergoemacs.org/emacs/emacs_insert_brackets_by_pair.html , i.e. adding these lines to ~/.emacs:
;; autocomplete paired brackets
(electric-pair-mode 1)

But this doesn't take any effect, I still have to M-x electric-pair-mode to activate it. Why is this happening?
Emacs version is 24.3, on Mac OSX.
Here is my entire ~/.emacs
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; set up package-archives
(require 'package)
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(package-archives (quote (("gnu" . "http://elpa.gnu.org/packages/") ("marmalade" . "http://marmalade-repo.org/packages/") ("melpa" . "http://melpa.milkbox.net/packages/"))))
 '(py-shell-name "python3")
 '(py-split-windows-on-execute-function (quote split-window-horizontally))
 '(scroll-bar-mode nil)
 '(send-mail-function (quote mailclient-send-it))
 '(tool-bar-mode nil)
 '(truncate-lines t))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(default ((t (:family "DejaVu Sans Mono for Powerline" :foundry "unknown" :slant normal :weight normal :height 120 :width normal))))
 '(cursor ((t (:background "light gray" :foreground "pale green")))))
(package-initialize)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;; ESS settings ;;;;;;;;;;;;;;;;;;;;;;;;;
;;ESS
(require 'ess-site)
(ess-toggle-underscore nil)
(setq ess-history-file nil)
(setq ess-help-kill-bogus-buffers t)
(setq
      ac-auto-show-menu 0
      ac-candidate-limit nil
      ac-delay 0.1
      ac-disable-faces (quote (font-lock-comment-face font-lock-doc-face))
      ac-ignore-case 'smart
      ac-menu-height 10
      ac-quick-help-delay 111.5
      ac-quick-help-prefer-pos-tip t
      ac-use-quick-help nil
)

(add-hook 'ess-mode-hook
          (lambda ()
            (ess-set-style 'C++ 'quiet)
            (add-hook 'local-write-file-hooks
                      (lambda ()
                        (ess-nuke-trailing-whitespace)))))
(setq ess-nuke-trailing-whitespace-p 'ask)
;; or even
;; (setq ess-nuke-trailing-whitespace-p t)
;; do not ask for working dir
(setq ess-ask-for-ess-directory nil)
;; always split side by side
(defun forbid-vertical-split ()
  "Only permit horizontal window splits."
  (setq-local split-height-threshold nil)
  (setq-local split-width-threshold 0))
(add-hook 'ess-mode-hook
          'forbid-vertical-split)
;; Let the ESS R console automatically scroll!
(setq comint-scroll-to-bottom-on-input t)
(setq comint-scroll-to-bottom-on-output t)
(setq comint-move-point-for-output t)
(define-key comint-mode-map [C-up] 'comint-previous-matching-input-from-input)
(define-key comint-mode-map [C-down] 'comint-next-matching-input-from-input)
; (define-key ess-mode-map (kbd "C-c d") 'comment-region)
; (define-key ess-mode-map (kbd "C-c u") 'uncomment-region)
;; (define-key ess-mode-map (kbd "C-S-e") 'comment-region)
;; (define-key ess-mode-map (kbd "C-S-d") 'uncomment-region)
;; ESS Mode (.R file)
  (define-key ess-mode-map "\C-l" 'ess-eval-line-and-step)
  (define-key ess-mode-map "\C-p" 'ess-eval-function-or-paragraph-and-step)
  (define-key ess-mode-map "\C-r" 'ess-eval-region)
;; use this one if each help window goes to a new frame
(setq ess-help-own-frame t)
;; use this one if you want all help windows into one frame!
(setq ess-help-own-frame 'one)
;;;;;;;;;;;; ESS settings ;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;; Perl settings ;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'perl-mode-hook
          (lambda () (setq perl-indent-level 4)))
;;;;;;;;;;;; Perl settings ;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;; evil copied to osx ;;;;;;;;;;;;;;;;;;;;;;;;;
;; evil and its plugins (ports from vim, or not?)
(require 'evil)
(evil-mode 1)
;; evil nerd commenter
(evilnc-default-hotkeys)
;;;;;;;;;;;; evil copied to osx ;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;; settings copied to osx ;;;;;;;;;;;;;;;;;;;;;;;;;
;; shift width set to 4
(setq c-basic-offset 4)
(setq-default tab-width 4)

;; autocomplete globally
(require 'auto-complete)
(defun auto-complete-mode-maybe ()
  "I do not want MAYBE, I want real autocomplete!"
  (auto-complete-mode 1))
(global-auto-complete-mode t)

;; only show one window when start up
(add-hook 'emacs-startup-hook 'delete-other-windows)

;; no backup ~n~ nonsense please
(setq make-backup-files nil)
(setq auto-save-default nil)
;; no startup logo and message
(setq inhibit-startup-echo-area-message t)
(setq inhibit-startup-message t)
;; solarized theme
(load-theme 'solarized-dark t)
;;;;;;;;;;;; settings copied to osx ;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;; python stuff copied to osx ;;;;;;;;;;;;;;;;;;;;;;;;;
;; Standard Jedi.el setting
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:setup-keys t)
(setq jedi:complete-on-dot t)

(require 'python-mode)
(add-to-list 'auto-mode-alist '("\.py\'" . python-mode))

;; send line to python console
(require 'python-mode)
(defun py-execute-line-down ()
  "execute python line and move cursor down"
  (interactive)
  (py-execute-line)
  (forward-line 1))
(define-key python-mode-map (kbd "C-c j") 'py-execute-line-down)
;;;;;;;;;;;; python stuff copied to osx ;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;; buffer/win management stuff ;;;;;;;;;;;;;;;;;;;;;;;;;
;; easy buffer switch
(require 'ido)
(ido-mode 'buffers) ;; only use this line to turn off ido for file names!
(setq ido-ignore-buffers '("^ " "*Completions*" "*Shell Command Output*"
               "*Messages*" "Async Shell Command"))

; use meta + arrow keys to switch between visible windows
;; handy in split views
(require 'windmove)
(windmove-default-keybindings 'meta)
;; automatically save buffers associated with files on buffer switch
;; and on windows switch
(defadvice switch-to-buffer (before save-buffer-now activate)
  (when buffer-file-name (save-buffer)))
(defadvice other-window (before other-window-now activate)
  (when buffer-file-name (save-buffer)))
(defadvice windmove-up (before other-window-now activate)
  (when buffer-file-name (save-buffer)))
(defadvice windmove-down (before other-window-now activate)
  (when buffer-file-name (save-buffer)))
(defadvice windmove-left (before other-window-now activate)
  (when buffer-file-name (save-buffer)))
(defadvice windmove-right (before other-window-now activate)
  (when buffer-file-name (save-buffer)))
;;;;;;;;;;;; buffer/win management stuff ;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;; misc ;;;;;;;;;;;;;;;;;;;;;;;
;; enable clipboard
(setq x-select-enable-clipboard t)
;; disable parentheses highlighting
(setq blink-matching-paren nil)
;; autocomplete paired brackets
(electric-pair-mode 1)
(global-set-key [C-tab] 'other-window)
;; tramp mode for editing through ssh
(setq tramp-default-method "ssh")
;;;;;;;;;;;; misc ;;;;;;;;;;;;;;;;;;;;;;;

;; probably a good idea to keep this at the very end!!
(server-start)
(setq server-socket-dir "~/.emacs.d/server")

A: My crystal ball tells me there's an error in your ~/.emacs file which prevents Emacs from reading/processing it to the end.
Try
emacs --debug-init


text:
Q: Default data in core data Is there any way to set data into core data that will be there when a user installs an app?
Example:
I install my notes app. When I open it I already see a couple of notes that are read from core data(but I haven't created those notes, they came with the app).

A: Whenever you add an attribute, open the data model inspector tab. Here you will get a field to set the default value to an attribute. For Attribute of Binary Data  type, the default value field is not available. I think for rest all it should be available.


text:
Q: InvalidOperationException is thrown when a ribbon is clicked Excel AddIn written in C#, .NET4.0, VS2010, When a ribbon is clicked, the exceptio is thrown.
In ribbon click event handler, I basically initialize a WPF window and ShowDialog

Name:InvalidOperationException
      Message:Recursive call to Automation Peer API is not valid.
      Target:System.Collections.Generic.List`1[System.Windows.Automation.Peers.AutomationPeer]
  GetChildren()
      Stack:   at System.Windows.Automation.Peers.AutomationPeer.GetChildren()
         at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer
  parent)
         at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer
  parent)
         at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer
  parent)
         at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer
  parent)
         at System.Windows.Automation.Peers.AutomationPeer.ValidateConnected(AutomationPeer
  connectedPeer)
         at MS.Internal.Automation.ElementProxy.StaticWrap(AutomationPeer peer,
  AutomationPeer referencePeer)
         at System.Windows.Automation.Peers.AutomationPeer.UpdateChildrenInternal(Int32
  invalidateLimit)
         at System.Windows.Automation.Peers.AutomationPeer.UpdateChildren()
         at Microsoft.Windows.Automation.Peers.DataGridItemAutomationPeer.GetChildrenCore()
         at System.Windows.Automation.Peers.AutomationPeer.EnsureChildren()
         at System.Windows.Automation.Peers.AutomationPeer.GetChildren()
         at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer
  parent)
         at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer
  parent)
         at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer
  parent)
         at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer
  parent)
         at System.Windows.Automation.Peers.AutomationPeer.ValidateConnected(AutomationPeer
  connectedPeer)
         at MS.Internal.Automation.ElementProxy.StaticWrap(AutomationPeer peer,
  AutomationPeer referencePeer)
         at System.Windows.Automation.Peers.AutomationPeer.ProviderFromPeer(AutomationPeer
  peer)
         at System.Windows.Automation.Peers.AutomationPeer.RaisePropertyChangedEvent(AutomationProperty
  property, Object oldValue, Object newValue)
         at Microsoft.Windows.Controls.DataGridRow.OnIsSelectedChanged(Object
  sender, DependencyPropertyChangedEventArgs e)
         at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs
  e)
         at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs
  e)
         at Microsoft.Windows.Controls.DataGridRow.OnPropertyChanged(DependencyPropertyChangedEventArgs
  e)
         at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs
  args)
         at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex
  entryIndex, DependencyProperty dp, PropertyMetadata metadata,
  EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean
  coerceWithDeferredReference, Boolean coerceWithCurrentValue,
  OperationType operationType)
         at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp,
  Object value, PropertyMetadata metadata, Boolean
  coerceWithDeferredReference, Boolean coerceWithCurrentValue,
  OperationType operationType, Boolean isInternal)
         at System.Windows.DependencyObject.SetCurrentValueInternal(DependencyProperty
  dp, Object value)
         at System.Windows.Controls.Primitives.Selector.ItemSetIsSelected(Object
  item, Boolean value)
         at System.Windows.Controls.Primitives.Selector.OnGeneratorStatusChanged(Object
  sender, EventArgs e)
         at System.Windows.Controls.ItemContainerGenerator.SetStatus(GeneratorStatus
  value)
         at System.Windows.Controls.ItemContainerGenerator.Generator.System.IDisposable.Dispose()
         at System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size
  constraint)
         at Microsoft.Windows.Controls.Primitives.DataGridRowsPresenter.MeasureOverride(Size
  constraint)
         at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
         at System.Windows.UIElement.Measure(Size availableSize)
         at System.Windows.ContextLayoutManager.UpdateLayout()
         at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
         at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
         at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
         at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object
  resizedCompositionTarget)
         at System.Windows.Media.MediaContext.AnimatedRenderMessageHandler(Object
  resizedCompositionTarget)
         at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate
  callback, Object args, Int32 numArgs)
         at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object
  source, Delegate method, Object args, Int32 numArgs, Delegate
  catchHandler)
         at System.Windows.Threading.DispatcherOperation.InvokeImpl()
         at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object
  state)
         at System.Threading.ExecutionContext.runTryCode(Object userData)
         at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode
  code, CleanupCode backoutCode, Object userData)
         at System.Threading.ExecutionContext.RunInternal(ExecutionContext
  executionContext, ContextCallback callback, Object state)
         at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean
  ignoreSyncCtx)
         at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
         at System.Windows.Threading.DispatcherOperation.Invoke()
         at System.Windows.Threading.Dispatcher.ProcessQueue()
         at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
         at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
         at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
         at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate
  callback, Object args, Int32 numArgs)
         at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object
  source, Delegate method, Object args, Int32 numArgs, Delegate
  catchHandler)
         at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority
  priority, TimeSpan timeout, Delegate method, Object args, Int32
  numArgs)
         at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
         at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
         at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame
  frame)
         at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
         at System.Windows.Window.ShowHelper(Object booleanBox)
         at System.Windows.Window.Show()
         at System.Windows.Window.ShowDialog()
         at CommodityAddIn.Connect.ShowLaunchUI(Functions selectedFunction)
         at CommodityAddIn.Connect.LIMSRBtnClick(CommandBarButton Ctrl, Boolean& CancelDefault)


text:
Q: Why is this true in measure theory? I don't understand something in proof of this implication:
$$\int f \mathbb{1}_A d\mu \leq \int g \mathbb{1}_A d\mu $$ for all $A \in \mathfrak{F} \Rightarrow f \leq g$     $\mu-$ almost everywhere.
Proof: Because f and g are $\mu$-integrable, $\int f \mathbb{1}_A d\mu$ and $\int g \mathbb{1}_A d\mu$ are finite for all $A \in \mathfrak{F}$. Furthermore, from claim f and g are measurable, thus $\left \{ f>g \right \}=\left \{ \omega \in \Omega | f(\omega) > g(\omega) \right \} \in \mathfrak{F}.$ We must show, that $\mu({f>g})=0.$
It holds, that

$$f\mathbb{1}_\left \{ f>g \right \} \geq g \mathbb{1}_\left \{ f > g
> \right \}$$

then proof continues. But, my question is why this last step holds?

A: If $f(x) > g(x)$ for some $x$, then $\mathbb{1}_{\{f > g\}}(x) = 1$, so
$$
f(x) \mathbb{1}_{\{f > g\}}(x)
= f(x)
> g(x)
= g(x) \mathbb{1}_{\{f > g\}}(x).
$$
If $f(x) \leq g(x)$ for some $x$, then $\mathbb{1}_{\{f > g\}}(x) = 0$, so
$$
f(x) \mathbb{1}_{\{f > g\}}(x)
= 0
= g(x) \mathbb{1}_{\{f > g\}}(x).
$$
In either case, $f(x) \mathbb{1}_{\{f > g\}}(x) \geq g(x) \mathbb{1}_{\{f > g\}}(x)$, so
$$
f \mathbb{1}_{\{f > g\}} \geq g \mathbb{1}_{\{f > g\}}
$$


text:
Q: Installed Chrome manually, now cant uninstall it I installed Chrome manually, but now I can't find it anywhere but in the search box. I tried to install Chrome again, but it installed without any hesitation and if I try to uninstall Chrome, it only uninstalls the latest. I can't find it in either the Snap software app or in the Software app.
Both Chromes on search box:

Packages installed:

Uninstalling Chrome:

Still one Chrome is showing:

It still works:


text:
Q: If I know that $P(N(B) = k \mid N(W)=n) = {n \choose k}p^k(1-p)^{n-k}$, and that $B \subset W$, how can I find $P(N(B) = k)$? If I know that $P(N(B) = k \mid N(W)=n) = {n \choose k}p^k(1-p)^{n-k}$, where N(B) = number of events in set $B$,  and that $B \subset W$, how can I find $P(N(B) = k)$ by itself? Is it feasible to do?:
$$
P(N(B) = k) = \sum_{n=0}^{\infty} P(N(B) = k \mid N(W)=n)
$$
Thanks!


text:
Q: Javascript disable button after click, but form doesn't submit I have a code that disables the button after one click perfectly, but the problem is, is the form doesn't submit then.  How do I disabled the button after one click and still have the form submit.
Code
<input id="submitbtn" name="submit" type="submit" value="Submit for Payment" />

<script type="text/javascript">
    $(function(){
        $('#submitbtn').one('click', function() {
        $(this).attr('disabled','disabled');
        });
    });
</script>

A: Try this:
$('form').submit(function() {
  $(this).find("button[type='submit']").prop('disabled',true);
});

A: Add the onsubmit attribute to your form and put the code to disable the button there, so you disable the button but the first submit has already happened:
<form onsubmit="myFunction();">

<script type="text/javascript">
    function myFunction(){
        $('#submitbtn').attr('disabled','disabled');
        // my submit code here
    }
</script>

A: Deferring the button disabling code until after the form submit event fires might be your best option. You can do this a few ways. If you only have one button that you want to disable, add a submit event listener to the form and disable it in the callback. Another simple approach is to use setTimeout which runs after 0 milliseconds.
setTimeout( () => $(this).attr('disabled','disabled') , 0);

Also, if you're using a version of jQuery that supports .prop(), I'd recommend using that instead of attr. Example: $(this).prop('disabled', true).

A:

$(function(){
  $('#submitbtn').on('click', function() {
    $(this).prop('disabled', true);
    $("#formID").submit();
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input id="submitbtn" name="submit" type="submit" value="Submit for Payment" />


text:
Q: Find the solution curve of $xdx+ydy=0$ passing through $(1,0)$ Consider the D.E.
$$
xdx+ydy=0.
$$
we want to find a solution curve  passing through the point $(x_{0},y_{0})=(1,0)$.

*

*The general solution is $x^{2}+y^{2}=c$, where $c>0$ . So we find c=1 and hence the solution curve is $x^{2}+y^{2}=1$. But there is a little confusing thing:

*I write the above equation in the form $\frac{dy}{dx}=-\frac{x}{y}$. The function $f(x,y)=-x/y$ is not cont. in $(1,0)$. But after using separation of variables we find
$x^{2}+y^{2}=1$.

*If I write the equation in the form $\frac{dx}{dy}=-\frac{y}{x}$ we have a unique solution curve passing the point $(1,0)$. The solution is $x=\sqrt{1-y^{2}}$. The interval of existence is $-1<y<1$.
My Questions:
What is the interval of existence in 1? Can I say it is $-1\leq x\leq 1$ or $-1\leq y \leq 1$. What happened exactly in cases 2 and 3?

A: Just integrate. You have $\int xdx = x^2/2$, $\int ydy=y^2/2$ and you can put all the twos and integration constants in the $c$ in the equation $x^2+y^2=c^2$. Now your conditions gives $c=1$. So $x^2+y^2=1$. Sounds familiar ?
You must recognize the equation of a radius-1 circle ! It is then geometrically obvious that this cannot be defined for $|x|>1$... if you stick to reals !
You might know $cosh^2(x)-sinh^2(x)=1$, which is somewhat similar to your circle formula... Now if you have $x>=1$, let $x=cosh(t)$ and you formally have $y=\pm \sqrt{1-x^2} = \pm \sqrt{1-cosh^2(t)} = \pm \sqrt{-sinh^2(t)} = \pm i sinh(t)$. So outside of $[-1,1]$ you get solutions which aren't real, but define an hyperbola in the complex plane (that makes a 4D space, because two axes per variable !).
This is actually useful. For example, you have this Bezout theorem which states that two algebraic curves with degrees $d$ and $q$ intersect exactly $dq$ times... under the assumption that you know how to count !
The unit circle $x^2+y^2=1$ (degree 2) and the line $y=x+2$ (degree 1), for example, never collide. This theorem tells you that, if you count infinity points, multiplicity and imaginary intersection points, you must find exactly two of these, like in the case of $x^2+y^2=1$ and $y=x$ (where this is geometrically obvious).

A: *

*The solutions of the differential equation
$$
d\bigl[\tfrac{1}{2}(x^{2} + y^{2})\bigr] = x\, dx + y\, dy = 0
\tag{1}
$$
are, as you say, circles $x^{2} + y^{2} = c$ centered at the origin.

*Also as you say,
$$
\frac{dy}{dx} = -\frac{x}{y}
\tag{2}
$$
is not problem-free at $(1, 0)$: The formal deduction of (2) from (1) entailed dividing by $y$, which vanishes at $(1, 0)$. That means (2) is suspect as a starting point for separation of variables. (That said, (2) may be viewed geometrically as indicating the solution curve has a vertical tangent at $(1, 0)$.)

*The equation
$$
\frac{dx}{dy} = -\frac{y}{x}
\tag{3}
$$
is logically equivalent to (1) in some neighborhood of $(1, 0)$, so solving by separation of variables gives (a piece of) a solution to (1).
In the sense you ask, the interval of existence in 1. and 3., namely the largest interval in which
$$
x = \sqrt{1 - y^{2}}
\tag{4}
$$
is a smooth solution of (1), is $-1 < y < 1$. The resulting graph is precisely the intersection of the unit circle with the open half-plane $\{0 < x\}$, namely the largest neighborhood of $(1, 0)$ in which (3) is equivalent to (1).


text:
Q: Обновил android studio до 2.3 ошибка Error:The supplied javaHome seems to be invalid. I cannot find the java executable. Tried location: E:\android\Android Studio\jre\bin\java.exe
при установке антивирус удалил случайно java.exe,но я не уверен помогите решить проблему


text:
Q: QGIS 3.22 vertex editor snapping placing vertices in wrong location I've been having a strange issue with my vertex editor over the past couple of days. I am attempting to edit a polygon such that the borders of the polygon line up with a different line segment layer on my map. I have snapping enabled to any line segment for that layer, so I can snap the vertices of the polygon to the line I'm trying to match them to.
Most of the time, this works perfectly fine. I place the vertex and it goes where it's supposed to. But sometimes, the vertex goes somewhere totally different than indicated. I hover my mouse over the magenta indicator for snapping, click it, and the vertex "bounces" over to a totally different area! I have no idea where to even begin on solving this issue, it's unlike anything I've ever seen from a GIS.
The screenshot below is the best illustration I can provide. I clicked on a snap point on one of the yellow lines, and the vertex in the bottom left is where it placed instead.
My snapping tolerance is 11px, if that's relevant.


text:
Q: Proper align li elements on a row I want to create my own calendar using css ul's and li's. Most calendars I have seen on the web use this way better than a table(don't know why is that). I have created some basic layout of the calendar, but seem to have a problem with aligning the day titles on top of the calendar. I am new to css so please be gentle with me. I know I could get one ready, but I like learning by doing and asking. So here is my code and the jsfiddle

Mon

Tue

Wen

Thu

Fri

Sat

Sun

                1

                2

                3

                4

                5

                6

                7

                8

                9

                10

                11

                12

                13

                14

                15

                16

                17

                18

                19

                20

                21

                22

                23

                24

                25

                26

                27

                28

                29

                30

and the css
* {
    margin:0px;
    padding: 0px;
}

#calendar-month{
    margin:auto;
    width: 600px;
    height: 480px;
    background-color:#C2CCD1
}

.title {
    margin:auto;
}

.title .days-title li{
    list-style: none;
    display: inline-block;
    padding-left:0.5em;
    padding-right:0.5em;
}

.days{
    margin:auto;
    width:600px;
    height:475px;

}

#calendar-month .days-item li{
    list-style: none;
    display:inline-block;
    float: left;
    width:70px;
    height:86px;
    background-color:white;
    border:1px solid black;
    margin-left:4px;
    padding-left:8px;
    margin-bottom:2px;
}

.day-label{
    float:right;
    padding-right: 7px;
    padding-top: 2px;
}

It migth not be the right way, maybe you could offer me a better way to understand paddings and margins or how to group them more properly. No it's not homework or anything else :), just getting inot design small step at a time :)

A: It's because you haven't applied the same properties to .title .days-title li as you have #calendar-month .days-item li. Specifically, width, padding and margin.
Add these to .title .days-title li:
width: 70px;
margin-left: 4px;
padding-left: 8px;

WORKING FIDDLE

A: If your days have a fixed width of 70px, why not add the CSS:
.days-title li{
    width:64px;
    text-align:center;
}

Fiddle


text:
Q: estructura de un objeto en json Buenas noches como puedo convertir este arreglo php a un objeto con estructura json
 $arreglo = array(
  ['pv'=>"MATEO BENITEZ 89 COL. centro TUXTEPEC MEXICO CP 38500", 'latitud'=>20.48871324385829, 'longitud'=> -100.65457702572893],
  ['pv'=>"JOSEFINA ENRIQUEZ 102   COL. CENTRO TUXTEPEC CP 68300", 'latitud'=>20.48871324385829, 'longitud'=> -100.65457702572893],
  ['pv'=>"AGUSTINA CARRERA 96   COL. CENTRO TUXTEPEC    CP 68300", 'latitud'=> 20.48871324385829, 'longitud'=>-100.65457702572893]);

A: Puedes utilizar el la funcion json_encode. Esta devuelve un string con la
representación JSON de el valor que le des, o false en caso de que ocurra un
error.
$arreglo_json = json_encode($arreglo);

Referencia


text: Q: How to see the variables current value of a running matlab process on tmux? I have a matlab process in tmux which is running for days. Actually I need to see the values of calculated variables till now. I thought that, it is good(if possible) to duplicate the process and then Ctrl+C one of them and see the variables values.


text:
Q: How to mathematically write a limit of sum of the series starting from a square root of a number between 0 and 1? Suppose, we take a number between 0 and 1 which is x.
How can I write a limit of sum of this series:
sqrt(x) + sqrt(sqrt(x)) .. and so on until a square root limits to 1.
Getting a square root from a number between 0 and 1 on a calculator repeatedly gives us 1. Hence, is my question.

A: Consider that for any convergent infinite sum $\sum_{k = 1}^\infty a_k = L,$ we must have that
$$\begin{align}\lim_{n \to \infty} a_n & = \lim_{n \to \infty} \left(\sum_{k = 1}^n a_k - \sum_{k = 1}^{n - 1} a_k\right)\\ & = \lim_{n \to \infty} \sum_{k = 1}^n a_k  - \lim_{n \to \infty} \sum_{k = 1}^{n - 1}a_k \\ & = L - L = 0\end{align}$$
So essentially, for an infinite sum to converge, the terms of the sum must converge to zero. Conversely, if the terms do not converge to zero, the sum must diverge. In calculus textbooks this is often called the $n^{th}$ term test for divergence, but it also goes by other names, such as the limit test, or simply the divergence test.
So, looking at our sum in particular, I claim that we have $\sum_{k = 1}^\infty x^{2^{-k}},$ for some real number $x$ with $0 < x < 1.$ If the way I've written out the terms with $k$ isn't clear, the point is that $a_1 = x^{2^{-1}} = x^{1/2} = \sqrt{x},$ and $$a_{k+1} = x^{2^{-k-1}} = x^{2^{-k} \cdot 2^{-1}} = \left(x^{2^{-k}}\right)^{1/2} = \sqrt{x^{2^{-k}}} = \sqrt{a_k}$$
so that each term is the square root of the one before it.
So, as stated before, for this sum to converge we would require the limit of the terms to go to zero, but when we compute the limit:
$$\lim_{n \to \infty} x^{2^{-n}} = \lim_{n \to \infty} e^{2^{-n} \ln(x)} = e^{\ln(x) \cdot \lim_{n \to \infty} 2^{-n}} = e^0 = 1$$
we get $1,$ as you indicated, which is clearly nonzero, meaning that the sum is divergent.


text:
Q: Store home partition on and authenticate users with central server? I am planning to roll out a handful of Ubuntu workstations. We have a Debian (samba) fileserver.
I would like to offer a hot-desk situation whereby users could go to any of these ubuntu machines, log on with their username, and pickup their desktop environment.
The server is not high spec; I want programs to run on the desktops, not virtualised on the server or anything like that.
Is this a straight forward thing to do? What technologies or options do I have?

A: I could mount /home on the server (samba or nfs). I could write a script to sync all users in /etc/passwd and /etc/shadow with (say) uid>2000 with a list from the server. Then people would be able to log in (their local machine would have their credentials), and their $HOME would be on the server.
Crude, but perhaps it could work?


text:
Q: how to interchanging data between online mysql database and offline mysql database via c# windows forms application? how to interchanging data between online mysql database and offline mysql database via c# windows forms application?

*

*online database and offline database is same tables and fields

*every one hour updating or interchanging data between online mysql database and offline mysql database.

*how can connect online Mysql database via c# windows forms application?
anybody help me please....

A: 1 : It's up to your library for connect MySQL database. To interchange data it just you SELECT from source DB then UPDATE to destination DB
2 : There are a class Timer you could use to schedule hourly to run function you want
3 : Most of library to connect MySQL would support remote connection, just get the IP of target MySQL DB. It not relate to programming now, It's about IT setup that will provide you IP and Port for making connection


text:
Q: Shall we use a color name like"grey" instead "setBackground(new Color(107, 106, 104));"? Shall we use a color name like"grey" instead "Color(107, 106, 104)" ?
My code returning some error like:
* MessageFrame2.java:14: cannot find symbol
symbol  : constructor Color(java.awt.Color)
location: class java.awt.Color
setBackground(new Color(Color.grey));*

A: Just use
setBackground(Color.gray);

A: All constants defined in Color class are Color objects themselves. So you can directly use
setBackground(Color.GRAY);

A: It is  not Color.grey  it is Color.gray
and you can directly set it with out creating any object.
and the constant define in Color for gray is below
public final static Color gray      = new Color(128, 128, 128);

A: Use Color.gray instead of Color.grey have a look here --> http://www.geom.uiuc.edu/~daeron/docs/apidocs/java.awt.Color.html

A: I think the symbol is Color.gray.


text:
Q: Get Method by CustomAttribute and then Invoke With a massive learning curve into Custom Attributes and Reflection, I still seem to be struggling. Could anyone help me out with this one?
Basically I want to invoke a method based on it's attribute.
This is the CustomAttribute that decorates a method (it will only ever be one method):
[ControllerName(Name="blog")]
public static string GetContent(string controllerName, string singleItemName = "")
{
    string returnVal = null;
    //Get the class type
    Type thisType = typeof(ContentFacade);

    //Get member info
    System.Reflection.MemberInfo info = typeof(ContentFacade);

    Loop through attributes
    foreach (object attrib in info.GetCustomAttributes(true))
    {
        //if the attribute matches the param controller name
        //then invoke
        if (attrib == controllerName)
        {
            //Get the method by attribute not method name
            //I dont want to get the method by MethodName
            MethodInfo theMethod = thisType.GetMethod(controllerName);

            //Return the value as it will be html for the end user
            returnVal = (string)theMethod.Invoke(controllerName, null);
        }
    }

    return returnVal;
}

Again, if possible I would like to get a method by an attribute.
Really looking forward to some help on this.
///Edits
Sorry I added comments in the code to illustrate the issue.
Basically I would like to:

*

*Get an attribute by controllerName == "blog"

*Get the method by attribute and invoke

I don't want to get the method by method name.
Regards,

A: Code sample
public class MyClass
{
    [System.ComponentModel.DisplayName("my test method")]
    public bool TestMethod(string input)
    {
        return input == "OK";
    }

    [System.ComponentModel.DisplayName("my second method")]
    public string TestMethod2(string input)
    {
        return input;
    }

    public void Invoke(string displayName)
    {
        // attribute type we search
        Type attributeType = typeof(System.ComponentModel.DisplayNameAttribute);

        // find method
        var methodInfo = (from e in this.GetType().GetMethods()
                          let attributes = e.GetCustomAttributes(attributeType).Cast<System.ComponentModel.DisplayNameAttribute>().ToArray()
                          where attributes.Length != 0 &&
                                attributes.Any(x => string.Equals(x.DisplayName, displayName, StringComparison.InvariantCultureIgnoreCase))
                          select e).FirstOrDefault();

        if (methodInfo != null)
        {
            // method found
            Console.WriteLine("Invoke {0} method: {1}", methodInfo.Name, methodInfo.Invoke(this, new object[] { "OK" }));
        }
    }
}

Comments

*

*this.GetType().GetMethods() - get all methods, you can specify which kind of methods your want to return by BindingFlags.

*e.GetCustomAttributes(typeof(System.ComponentModel.DisplayNameAttribute)) - get all attributes of specified type

*methodInfo.Invoke(this, new object[] { "OK" }) - method invocation, this - class instance (null for static methods), new object[] { "OK" } - array of arguments.

A: A simple example would be:
public static string GetContent(Type type, string controllerName)
{
    foreach (MethodInfo method in type.GetMethods(BindingFlags.Static | BindingFlags.Public))
    {
        ControllerNameAttribute controller = (ControllerNameAttribute)method.GetCustomAttribute(typeof(ControllerNameAttribute));

        if (controller == null)
        {
            continue;
        }

        if (controller.Name != controllerName)
        {
            continue;
        }

        if (method.IsGenericMethod)
        {
            throw new InvalidOperationException();
        }

        if (method.GetParameters().Length != 0)
        {
            throw new InvalidOperationException();
        }

        if (method.ReturnType != typeof(string))
        {
            throw new InvalidOperationException();
        }

        string result = (string)method.Invoke(null, null);
        return result;
    }

    throw new InvalidOperationException();
}

You use it like:
string result = GetContent(typeof(Program), "blog");

Where Program is the class where the method should be.
Note that, as written, this code will work only on static methods. If you want to use instance methods, change it to:
public static string GetContent(object instance, string controllerName)
{
    Type type = instance.GetType();

    foreach (MethodInfo method in type.GetMethods(BindingFlags.Static | BindingFlags.Public))
    {
        ControllerNameAttribute controller = (ControllerNameAttribute)method.GetCustomAttribute(typeof(ControllerNameAttribute));

        if (controller == null)
        {
            continue;
        }

        if (controller.Name != controllerName)
        {
            continue;
        }

        if (method.IsGenericMethod)
        {
            throw new InvalidOperationException();
        }

        if (method.GetParameters().Length != 0)
        {
            throw new InvalidOperationException();
        }

        if (method.ReturnType != typeof(string))
        {
            throw new InvalidOperationException();
        }

        string result = (string)method.Invoke(instance, null);
        return result;
    }

    throw new InvalidOperationException();
}

In general, both methods don't check if there is a single method with the given controllerName. They simply execute the first one that is found. It is possible to do even the checking, normally using LINQ, but I wanted to keep the foreach cycle simple and linear, and show all the other checks that should be done.


text:
Q: Sign in with Apple Custom button I am using Sign in with apple in my iOS application. I want to localise the language of the button title according to locale. It's working for the languages which are supported by apple, but is it possible to localise the button title when the locale language is a non-apple supported language.
eg: Lithuanian language, it's not supported by apple. While using this language, the system language will be english.
I just read about the custom Apple sign in button option, is this kind of localisation is possible in custom button ? or any other way to tackle this!!

A: Please go with custom button, It will surely help.

*

*You can customised custom button in any manner.


text:
Q: Center align multi line html text to textview I have the following html code I want to set to my TextView. I want the second line to be center aligned.Even after adding the left padding I don't see the text being aligned to the center.
String title = "Howdy doing.
Doing great:"

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        textview.setText(Html.fromHtml(title, Html.FROM_HTML_MODE_LEGACY));
    } else {
        textview.setText(Html.fromHtml(title));
    }


text:
Q: Use Openzipkin Brave for tracing with ForkJoinPool I am trying to apply Openzipkin Brave to an application to help log tracing using Logback. The application is a spring webmvc application and it uses ForkJoinPool.
Tracing in the main thread (spring webmvc part) is working, but I have difficulties on passing the trace context to the ForkJoinThread. In my understanding, trace context is stored in threadlocal, which obviously is not accessible by ForkJoinWorkerThread (or ForkJoinTask). I wonder how I can make it work.

A: EDIT: We discovered during answering of this question that ForkJoinPool does not work currently with Brave. Due to API constraints on the class we were not able to find a solution yet.
The following assumes using Brave version 5 (it might work on 4 also):
The CurrentTraceContext API gives us a method: executorService that we can use to wrap an ExecutorService. So you would need to do something like the following:

    ForkJoinPool fjp = ...;
    CurrentTraceContext ctc = Tracing.currentTraceContext();
    ExecutorService wrappedExecutorService = ctc.executorService(fjp);

Then you use the wrappedExecutorService as you were using your ForkJoinPool


text:
Q: Show that whether a holomorphic function has no zero in the left half space Fix a complex number $0<|\lambda|<1$. For $n\geq 1$, let $f(z)=(z-1)^{n}e^{z}+\lambda(z+1)^{n}$. Show that $f(z)$ has exactly $n$ simple zeros with $Re(z)>0$.
This is the original question that I want to solve. I find this question somehow ambiguous. Does it say

*

*$f(z)$ has exactly $n$ zeros in the right half plane and these are simple zeros and and there are no zeros in the left half plane.

Or

*$f(z)$ has exactly $n$ zeros in the right half plane and these are simple zeros and we don't need to show whether there are any zeros in the left half plane.

I can prove the second statement using the symmetric form of Rouché's theorem. But I can't prove there are no zeros in the left half plane. So my real question is:
Does $f(z)$ have any zeros in the left half plane?


text:
Q: How to execute a query which is stored in a table column PostgreSql? I have a table column which contains following text data:
"drop table log_history_2_2015"
"drop table log_history_3_2015"
"drop table log_history_4_2015"
"drop table log_history_5_2015"
"drop table log_history_6_2015"

How can I execute them in single shot without looping through all these rows and executing them individually.

A: A more general solution is to use a DO block to execute the dynamic SQL:
DO
LANGUAGE plpgsql
$$
DECLARE
  stmt text;
BEGIN
  FOR stmt IN
    SELECT statement FROM the_table
  LOOP
    EXECUTE stmt;
  END LOOP;
END;
$$;

Note that this runs in a single transaction.

A: use SELECT string_agg(COLUMN_NAME,';')||chr(10) - it will give you single line to run


text:
Q: How to copy and save elements from dataGridView? I would like to ask how to copy and save selected elements from one dataGridView to another? In one dataGridView, I have elements, that can be selected, and upon selection, they are then transferred to the other dataGridView, where they will be ready for printing on paper. However, with the code below, it doesn't copy the elements correctly, as it displays ContextMenuStrip, DefaultCellStyle, DividerHeight, etc...
It also doesn't save my selection, but instead overwrites it everytime I choose new rows. How exactly do you copy and save elements (rows) from one dataGridView to another? I would like to avoid doing it with clicking, as there will be multiples of elements that need to be ready for printing.
private void button5_Click(object sender, EventArgs e)
{
    dataGridView2.DataSource = dataGridView1.SelectedRows;
}

A: This is my example, try to following this perhap?
if (GMDSP1.Rows.Count > 0)
            {
             DataTable _dt1 = new DataTable();
             DataTable _dt2 = new DataTable();
                DataGridViewRow gvdr = GMDSP1.CurrentRow;
                DataRow[] drArr = _dt1.Select("Name= '" + gvdr.Cells["Name1"].Value.ToString() + "'");
                if (drArr.Length > 0)
                {
                    DataRow dr = _dt2.NewRow();
                    if (_dt2.Columns.Count == 0)
                    {
                        foreach (DataColumn dc in _dt1.Columns)
                        {
                            DataColumn newDC = new DataColumn(dc.ColumnName, dc.DataType);
                            _dt2.Columns.Add(newDC);
                        }
                    }

                    dr["ID"] = drArr[0]["ID"].ToString();
                    dr["Name"] = drArr[0]["Name"].ToString();

                        _dt2.Rows.Add(dr);
                        _dt1.Rows.Remove(drArr[0]);

                        _dt1.AcceptChanges();
                        _dt2.AcceptChanges();

                    GMDSP1.DataSource = _dt1;
                    GMDSP2.DataSource = _dt2;


text:
Q: How to replace the hostname portion with xauth (OLD: How to redirect output of xauth command?) I would like to generate a new Xauthority file using xauth with another hostname portion and write it to a different file name (as opposed to ~/.Xauthority where the xauth command typically writes to).
[Later on I want to copy this file to another machine with a different hostname. This machine is a container which binds the X socket but does not have the xauth command installed.]
UPDATE: xauth extract ~/.newXauthority $DISPLAY does almost what I want except it does not alter the hostname portion.
I did not find anything useful in xauth's man page.

A: There are 2 sorts of hostname entries managed by xauth, local names such as myhost/unix:0 and remote names such as remote:0. The latter are held as ip addresses, but I imagine you are referring to the local names.
The hostname part of these are not actually of any significance to X11, but can be used by the xdm tools to distinguish between several local name entries, each with different keys. To change this name simply list the entry you want, take the key at the end of the line, and provide it to the add command with your new hostname:
xauth -f ~/.newXauthority add newhostname/unix:0 . $(xauth list "$DISPLAY" |awk '{print $NF}')

This assumes DISPLAY is :0, and you want the same local display number on the new machine.


text:
Q: Power to the home in the UK We have a question about the power available to the home in the UK.
Our product draws a fair amount of current, so we have (so far) designed it to be powered by ~230vac single phase at 48A OR ~230vac 3 phase, 16A for each phase.
We bought IEC 60364-1 and read section 312.1.1 Current-carrying conductors in a.c. circuits.
We understand that we may encounter:
1 phase 2 wire, 1 phase 3 wire, 2 phase 3 wire, 3 phase 3 wire or 3 phase 4 wire.
Our specific question is what kind of coverage will each of these two options give us in the UK (or the continent)

A: Note that he three phase is 230V phase to neutral, 400V phase to phase.
The lions share of UK domestic property is single phase, 230V Phase to Neutral (Usually closer to 240V in reality), and for 40A you would be needing a special purpose circuit installing, you will not (with the exception of some folks who run big machines) see a domestic outlet bigger then 13A (~3kW), but a special purpose circuit can be installed by an electrician.
The common connectors used for such things are Blue 32A or 63A IEC 60309 connectors, in 2 pole plus earth 6H configuration, but they are not something you usually see in domestic situations (I have a 32A example installed in the shed for a welder).
Most UK housing is has an incoming supply fused at either 60 or 100A, with three phase very much the exception rather then the rule, assume single phase is what will be available unless you are selling to light industry.

A: In the UK the most common supply is either Single Phase or 3 phase.
Single Phase is 240V phase to neutral and is found in all homes, offices and light industrial property. All outlets are 3 pin, Live, Neutral and Earth. Single Phase outlets over 13A will be round blue.
Common outlets are the 'standard' 3 pin BS 1363 wall socket and the Industrial IEC 60309 Blue P+N+E round sockets in 16A, 32A and 64A variants.
3 Phase is usually only installed in larger industrial property and will use the Red round IEC 60309 outlets which will be 4 or 5 pin 3P+E or 3P+N+E.
Sometimes 3 phase will be physically in the cable at the meter in UK homes but it is never in the distribution board. There maybe an exception in very large manor houses, stately homes etc. Sometimes it may also be installed if the home owner requires it for large machinery etc (A friend of mine had it installed to run lathes and milling machines in his garage) but it is very rare.
2 Phase is rare, it was usually used for older machinery and is never installed in a new installations now, sometimes very large homes or commercial property will be supplied with two phases but they will be treated as two separate single phase supplies where each single phase doesn't have the required current capacity.
So in summary you will only really encounter:
Single Phase 3Pin
3Phase 4pin
3Phase 5pin
In outlet sizes of 13A, 16A, 32A, 64A and 125A.
Anything else is only used in specialist applications.


text:
Q: Resize gui elements by dragging the corners I have a swing project and noticed that the elements inside the JFrame is statically located inside the JFrame and I do not have the option of resizing the elements as I want to.
My gui app inside the designer window looks like the following:

I want to resize the button (E.g.) by dragging the corners of the button, but I am not allowed to?
As you can see on the following picture, the dragging is not allowed per pixel, but only per section in the JFrame:

How can I disable the static placement of the elements/Enable the self-dragging of elements inside the designer window?

A: Most likely you will need to disable the LayoutManager. On Netbeans, Setting this to null would provide you full control over the location and dimension of the child elements, so I am assuming that something similar should work here (although you seem to be using Eclipse, if that is the case, please state what plugin you are using).
It is to be noticed however that usually you want to have a layout manager taking care of how your components are rendered. I would recommend you take a look here for some more information on layout managers prior to removing them completely.

A: Setting size and position of components in a GUI should be left to the JRE at run-time, using:

*

*The preferred size of the component (with current content, in the current PLAF).

*The borders/padding/insets set to the component.

*The layout used.

*The component spacing defined in the layout constructors.

*The layout constraints used when adding components to the layout (especially important to e.g. BorderLayout and the much maligned GridBagLayout, as well as many 3rd party layouts).

Generally, complex effects are created by using a nested layout.


text:
Q: Entity Framework 6 with an Immutable Class I have a Point class:
// My immutable Point class
public class Point
{
    private readonly Distance _x;
    private readonly Distance _y;
    private readonly Distance _z;

    public Distance X
    {
        get { return _x; }
    }

    public Distance Y
    {
        get { return _x; }
    }

    public Distance Z
    {
        get { return _x; }
    }

    // Ok, so this isn't immutable... but it's purely for EF
    public int DatabaseId { get; set; }

    public Point(Distance x, Distance y, Distance z)
    {
        _x = x;
        _y = y;
        _z = z;
    }
}

(Distance is a custom class that stores a unit and a value.)
That's great. We love immutability. But Entity Framework won't recognize that I need to put X, Y, and Z in the database because they don't have setters. And they shouldn't, because this is an immutable class. There shouldn't even be a private set.
I have this code building my model:
    modelBuilder.Entity<Point>()
        .HasKey(point => point.DatabaseId);

Is there any way to preserve the true immutability of this class but also make it so that EF6 can access and store these values?

A: In a similar situation, I had to create a private parameterless constructor that EntityFramework can use and made the Id as private set. This worked for me fine and it's the best I could do in the time I had in keeping the class immutable.
So in your case, the above class could be updated and simplified as follows:
public class Point
{
    public Distance X { get; private set; }
    public Distance Y { get; private set; }
    public Distance Z { get; private set; }
    public int DatabaseId { get; private set; } // DatabaseId can't be set publicly

    private Point() { } // Private Parameterless Constructor for EntityFramework

    public Point(Distance x, Distance y, Distance z)
    {
        X = x;
        Y = y;
        Z = z;
    }
}

Hope this helps!

A: EF Core 2.0.1:
Model:
public class Point
{
    [Obsolete("For ORM(EF) use only", true)]
    public Point() { }

    public Point(Distance x, Distance y, Distance z)
    {
        _x = x;
        _y = y;
        _z = z;
    }

    public int Id { get; set; }

    public Distance X { get => _x; }
    private Distance _x;

    public Distance Y { get => _y; }
    private Distance _y;

    public Distance Z { get => _z; }
    private Distance _z;
}

Let EF fill the private fields
public class DomainDbContext : DbContext
{
    /*skipping other stuff you have here*/

    public DbSet<Point> Points { get; set; }

    protected override void OnModelCreating(ModelBuilder builder)
    {
        // Fill Properties with private fields
        builder.Entity<Point>().Property(m => m.X).UsePropertyAccessMode(PropertyAccessMode.Field);
        builder.Entity<Point>().Property(m => m.Y).UsePropertyAccessMode(PropertyAccessMode.Field);
        builder.Entity<Point>().Property(m => m.Z).UsePropertyAccessMode(PropertyAccessMode.Field);
    }
}

Final issue is using this with a controller so:
public class PointViewModel // has default parameterless constructcor
{
    public int Id { get; set; }

    public Distance X { get; set; }

    public Distance Y { get; set; }

    public Distance Z { get; set; }
}

Use in controller:
[HttpPost]
public async Task<IActionResult> Create([Bind("X,Y,Z")] PointViewModel info)
{
     if (ModelState.IsValid)
     {
         var point = new Point(info.X, info.Y, info.Z);

         _context.Add(point);
         await _context.SaveChangesAsync();
         return RedirectToAction(nameof(Index));
      }
      return View(info);
}

A: As far as I know EF will store both _x and X in the table so you must make them public with private setters.
They are still immutable except for the primary key witch EF must be able to set.
Alternatively you can add another layer: the immutable class and the EF table model class and when you pull form the database you get an immutable object while the mutable one will be hidden outside of DAL.


text:
Q: computation by commuting I have some doubts about your paper Computing by commuting (abstract is copied below):
What do these sentences say (my REMARKS on what I do not follow are numbered by 1,2):
" the choice of a word to be catenated does not depend on the word erased, "
1.what does it mean that the word catenate does not depend on the word erased, do you have some example when it does depend on it ?
i.e. it what sense it could depend on the word erased ?
I would say that if if the catenation is not dependent then the situation is even more general than if it is not?
" If the deletion and the catenation are done arbitrarily at the opposite ends"

*what does it mean "arbitrarily" in that the deletion and catenation are done arbitrarily at the opposite ends ?

We consider the power of the following rewriting: given a finite or regular set X of words and an initial word w, apply iteratively
the operation which deletes a word from X from one of the ends of w and simultaneously catenates another word from X to the
opposite end of w. We show that if the deletion is always done at the beginning and the catenation at the end, and the choice of a
word to be catenated does not depend on the word erased, then the generated language is always regular, though the derivability
relation is not, in general, rational. If the deletion and the catenation are done arbitrarily at the opposite ends, the language need not
be regular. If the catenation is done at the same end as the deletion, the relation of derivability is rational even if the catenated word
can depend on the word erased.

A: *

*I guess this is just to emphasize that you do not restrict to operations of the form $w \to (x^{-1}w)y$ with $y = x$.

*This means that two types of operations are allowed: $w \to (x^{-1}w)y$ and $w \to x(wy^{-1})$.


text:
Q: Cannot open PDF in PDFViewer by GrepheneOS I'm trying to built https://github.com/GrapheneOS/PdfViewer. I have downloaded the submodule as well but I cannot open the PDF. The logs from logcat are below. I'm using Windows OS
2022-11-02 00:12:37.712 21225-21279 PdfViewer D  path /viewer.html
2022-11-02 00:12:37.748 21225-21225 chromium  I  [INFO:CONSOLE(0)] "Error with Permissions-Policy header: Unrecognized feature: 'ambient-light-sensor'.", source:  (0)
2022-11-02 00:12:37.748 21225-21225 chromium  I  [INFO:CONSOLE(0)] "Error with Permissions-Policy header: Unrecognized feature: 'battery'.", source:  (0)
2022-11-02 00:12:37.748 21225-21225 chromium  I  [INFO:CONSOLE(0)] "Error with Permissions-Policy header: Unrecognized feature: 'hid'.", source:  (0)
2022-11-02 00:12:37.748 21225-21225 chromium  I  [INFO:CONSOLE(0)] "Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'interest-cohort'.", source:  (0)
2022-11-02 00:12:37.748 21225-21225 chromium  I  [INFO:CONSOLE(0)] "Error with Permissions-Policy header: Unrecognized feature: 'payment'.", source:  (0)
2022-11-02 00:12:37.748 21225-21225 chromium  I  [INFO:CONSOLE(0)] "Error with Permissions-Policy header: Unrecognized feature: 'picture-in-picture'.", source:  (0)
2022-11-02 00:12:37.748 21225-21225 chromium  I  [INFO:CONSOLE(0)] "Error with Permissions-Policy header: Unrecognized feature: 'serial'.", source:  (0)
2022-11-02 00:12:37.749 21225-21225 chromium  I  [INFO:CONSOLE(0)] "Error with Permissions-Policy header: Unrecognized feature: 'speaker-selection'.", source:  (0)
2022-11-02 00:12:37.749 21225-21225 chromium  I  [INFO:CONSOLE(0)] "Error with Permissions-Policy header: Unrecognized feature: 'usb'.", source:  (0)
2022-11-02 00:12:37.749 21225-21225 chromium  I  [INFO:CONSOLE(0)] "Error with Permissions-Policy header: Unrecognized feature: 'xr-spatial-tracking'.", source:  (0)
2022-11-02 00:12:37.752 21225-21279 PdfViewer D  path /pdfjs-dist/webpack.js
2022-11-02 00:12:37.752 21225-21271 PdfViewer D  path /viewer.css
2022-11-02 00:12:37.753 21225-21271 PdfViewer D  path /pdf.js
2022-11-02 00:12:37.760 21225-21271 PdfViewer D  path /viewer.js
2022-11-02 00:12:37.764 21225-21225 chromium  I  [INFO:CONSOLE(1)] "Uncaught SyntaxError: Unexpected token '.'", source: https://localhost/pdf.js (1)
2022-11-02 00:12:37.770 21225-21225 chromium  I  [INFO:CONSOLE(3)] "Uncaught ReferenceError: pdfjsLib is not defined", source: https://localhost/viewer.js (3)
2022-11-02 00:12:37.772 21225-21279 PdfViewer D  path /favicon.ico
2022-11-02 00:12:37.773 21225-21225 chromium  I  [INFO:CONSOLE(203)] "Uncaught ReferenceError: pdfjsLib is not defined", source: https://localhost/viewer.js (203)


text:
Q: Does swap() cause undefined behaviour? I'm trying to understand the conditions on std::swap from [C++11: utility.swap]. The template is defined as
template <typename T> void swap(T &, T &)

(plus some noexcept details) and as having the effect of "exchanging the values stored at the two locations".
Is the following program have well-defined?
#include <utility>

int main()
{
    int m, n;
    std::swap(m, n);
}

If I wrote swap code myself (i.e. int tmp = m; m = n; n = tmp;), it would have undefined behaviour, since it would attempt lvalue-to-rvalue conversion on an uninitialized object. But the standard std::swap function does not seem to come with any conditions imposed on it, nor can one derive from the specification that there is any lvalue-to-rvalue and thus UB.
Does the standard require std::swap to perform some magic that is well-defined on uninitialized objects?
To clarify the point, consider the function void f(int & n) { n = 25; }, which never has undefined behaviour (since it does not read from n).

A: Very nice question. However, I would say this is covered by [res.on.arguments]§1:

Each of the following applies to all arguments to functions defined in the C++ standard library, unless
  explicitly stated otherwise.

*

*If an argument to a function has an invalid value (such as a value outside the domain of the function
  or a pointer invalid for its intended use), the behavior is undefined.

To address your concern about f(n), the function f from your question is not a part of the C++ standard library and thus the above clause does not apply to it.

A: As the value of M is undefined, I would expect it to taint the call to swap.
Nasal Demons may fly, when swap is called.


text:
Q: JCS LTCP AUX cache configuration and usage Background:
We have 4 physical servers (4 IPS), each one running in JBOSS 6 EAP running on port 80.All requests are redirected to any one of these servers via Load balancer.
Now I tried to implement Java cache system for such distributed env so that our properties gets updated in each servers cache.
POC:
For that we did a small POC on our local systems implementing JCS v1.3 lateral caching.
Enabled it in our maven project. The following config is used in .ccf file :
  jcs.default=
  jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
  jcs.default.cacheattributes.MaxObjects=1000
  jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
 # PRE-DEFINED CACHE REGION

##############################################################
##### AUXILIARY CACHES
# LTCP AUX CACHE
   jcs.auxiliary.LTCP=org.apache.commons.jcs.auxiliary.lateral.socket.tcp.LateralTCPCacheFactory
   jcs.auxiliary.LTCP.attributes=org.apache.commons.jcs.auxiliary.lateral.socket.tcp.TCPLateralCacheAttributes
  #jcs.auxiliary.LTCP.attributes.TcpServers=152.144.219.209:8080
   jcs.auxiliary.LTCP.attributes.TcpListenerPort=1118
   jcs.auxiliary.LTCP.attributes.UdpDiscoveryAddr=228.5.6.8
   jcs.auxiliary.LTCP.attributes.UdpDiscoveryPort=6780
   jcs.auxiliary.LTCP.attributes.UdpDiscoveryEnabled=true
   jcs.auxiliary.LTCP.attributes.Receive=true
   jcs.auxiliary.LTCP.attributes.AllowGet=true
   jcs.auxiliary.LTCP.attributes.IssueRemoveOnPut=false
   jcs.auxiliary.LTCP.attributes.FilterRemoveByHashCode=false
   jcs.auxiliary.LTCP.attributes.SocketTimeoOt=1001
   jcs.auxiliary.LTCP.attributes.OpenTimeOut=2002
   jcs.auxiliary.LTCP.attributes.ZombieQueueMaxSize=2000

And implementing the getter and setter methods for saving a string attribute in cache and getting it from cache
public void addProp(String propId)
        throws PimsAppException {
    try {
        configMSCache.put(propId, propId);
    } catch (CacheException e) {
        e.printStackTrace();
    }

}

@Override
public String testProp(String propId) throws PimsAppException {
    if(configMSCache!=null){
        return (String) configMSCache.get(propId);
    }else{
    return "It dint work";
    }
}

The application is deployed fine no error in getting it up.
TEST METHOD:
deployed the project.war in my local server and in a remote server with different IP. Both machines are in same network, so no firewall issue in accessing each others IP.
Have saved a property in my server and get it. (Worked fine)
Tried to get the saved property via my local by the remote machine. (It returns blank response).
Means the distributed cache feature is NOT achieved.
Doubts :
1. Does the auxiliary caches set up properly? I mean the configurations
2. Am I testing it properly or how can I test it in dev environment.
3. As  JCS UDP Discovery,lets us support the same config on multiple machines, then why it dint work on remote machine?
4. Or is there any caching mechanism, with good examples and documentation can suffice my application needs(as mentioned in background section).
Thanks in advance.

A: This reply might be too late. But I will suggest in case, to log the stats on both servers and see. As could be possible that it is propagating the cache but just in the processing time, there is an issue reading it.
For example:
JCSAdminBean admin = new JCSAdminBean();
LinkedList linkedList = admin.buildCacheInfo();
ListIterator iterator = linkedList.listIterator();
while (iterator.hasNext()) {
    CacheRegionInfo info = (CacheRegionInfo)iterator.next();
    CompositeCache compCache = info.getCache();
    System.out.println("Cache Name: " + compCache.getCacheName());
    System.out.println("Cache Type: " + compCache.getCacheType());
    System.out.println("Cache Misses (not found): " + compCache.getMissCountNotFound());
    System.out.println("Cache Misses (expired): " + compCache.getMissCountExpired());
    System.out.println("Cache Hits (memory): " + compCache.getHitCountRam());
    System.out.println("Cache value: " + compCache.get(propId));

}