text:
Q: Is ./ (dot slash) a command? Core of the question:
The question arose while I could not install the software, so I am genuinely asking about ./ because I didn't know about it and the output "command not found" was confusing me about what actually the command was.
Context:
I would like to install the file truecrypt-7.2-setup-x86.
Instructions say to use the command:
sudo ./truecrypt-7.2-setup-x86

But the output is:
sudo: ./truecrypt-7.2-setup-x86: command not found

UPDATE: for completeness, in the test I was in the file folder but had not yet made the file executable (chmod +x).

A: How does calling commands in shell work
No, it is not a command. The way shells work is when you type in a line of text, first word is going to be treated as command, and if the command is not one of the shell built-in ones then the shell will look at all locations listed in PATH  environment variable.
What happens if when the command you want to run is in the same directory as you currently located but that directory isn't on the list of PATH directories ? That's when you need to use ./. It is in a way exactly the same as doing /bin/bash - you are telling the shell where your desired command located, a full path to it. And in case of ./ you're saying to shell "look in this directory".  So important part is that you have to be in the same directory where the file is located.
Of course, in order to actually run an executable, it must have executable bit set, so  you'll need to chmod +x ./my_file.
So the important steps:

*

*cd where you saved the file; if it's in ~/Downloads, then cd ~/Downloads

*Run chmod +x ./truecrypt-7.2-setup-x86 , this says "make file truecrypt-7.2-setup-x86 that is in this directory executable"

*And now do sudo ./truecrypt-7.2-setup-x86
Note that use of ./ is not random behavior, but actually is a standard, specified by Portable Operating System Interface standard ( aka POSIX ), specifically see "Command Search and Execution" section.
Reproducing the error
$ # my script is in ~/Downloads folder
$ stat -c "%n" /home/xieerqi/Downloads/my_script.sh
/home/xieerqi/Downloads/my_script.sh
$ # if I run sudo ./my_script.sh, we get an error
$ sudo ./my_script.sh
[sudo] password for xieerqi:
sudo: ./my_script.sh: command not found
$ # of course the command not found because file is not in ./, not in this dir
$ # this is not  sudo's problem
$ # but sudo does indeed show the same error even if you're in same directory
$ cd ./Downloads/
$ sudo ./my_script.sh
[sudo] password for xieerqi:
sudo: ./my_script.sh: command not found

NOTE: the error message given by sudo is obviously misleading so this is something to be kept in mind; however please note that this wasn't the core of the question that OP is asking.
Documentation and references
From bash 4.3 manual,  "COMMAND EXECUTION" section:

If  the name is neither a shell function nor a builtin, and contains no slashes, bash searches each element of the PATH for  a  directory containing  an executable file by that name.

From Why do you need ./ (dot-slash) before script name to run it in bash?:

It works with ./ because POSIX specifies that a command name that contain a / will be used as a filename directly, suppressing a search in $PATH. You could have used full path for the exact same effect, but ./ is shorter and easier to write.

A: ./ is not a command. The command is ./truecrypt-7.2-setup-x86.
Your shell and programs like sudo will treat a command as a pathname when it contains at least one / character. Since . represents whatever directory you are currently in, ./truecrypt-7.2-setup-x86 names the file truecrypt-7.2-setup-x86 in the current directory. If there is no such file,  or there is but the file cannot be run, then you will get an error message.
When a command does not contain a slash, the directories listed in $PATH are searched for it, as Sergiy Kolodyazhnyy says. The current directory is not automatically searched--and it is not recommended to put . in $PATH. That way, you don't accidentally run things you didn't expect to run because you happened to have cdd to a directory that contains them.
Writing ./ before the name of an executable in the current directory the common way to run it, but this is not actually a special syntax. For example, if you messed up your $PATH and you needed to run a command like ls, you could write /bin/ls. No . is necessary in that case or in general; what's needed  is a / somewhere in the pathname to signify that you mean it is a pathname.
Since . is always the current directory and / is just the directory separator, the first thing to do is check that the file you've named really exists in the current directory. (If it does, then check its permissions, as Charles Green explains. But if you extracted the file from an archive, then it usually will already have executable permissions if it is intended to be run.)

A: The ./ part of the command is saying "Look in the current directory, and execute the command 'truecrypt-7.2-setup-x86' from here". You need to run this command from the directory where you unpacked the file.
This can be tested:  In the same terminal window where you are trying the command, enter the command ls -l true* - if the file is present in the current working directory, then a listing showing the file (and a bunch of additional information) will be displayed.
As Zanna has noted in the comments, your file may not have execute permissions - this can be fixed easily.  As a test case, my directory shows
chick@dad:~/test$ ls -l
total 4
-rw-r--r-- 1 chick chick 788 Oct 27 06:15 rFullBack
chick@dad:~/test$

and the file "rFullBack" lists '-rw-' as my permission, to read and write the file.  I can execute the command chmod +x rFullBack and the directory listing changes to
chick@dad:~/test$ ls -l
total 4
-rwxr-xr-x 1 chick chick 788 Oct 27 06:15 rFullBack
chick@dad:~/test$

There my permissions are now '-rwx', indicating I can execute the file.

In short, if the file exists in your directory
run the command
chmod +x ./truecrypt-7.2-setup-x86

and then the command
sudo ./truecrypt-7.2-setup-x86


text:
Q: Exact alignment of Radio buttons in Rows and Columns How do I align Radio buttons exactly in HORIZONTAL ROWS and at the same time exactly in VERTICAL COLUMNS. I have to align radio buttons in four rows. The radio buttons are like so:

whenever the text is bigger, the radio buttons move to the right. If the text associated with radio button is shorter then radio buttons move to the left. I want them to be aligned properly in rows and columns.Below is my HTML:

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">
      A

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2">
      B

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3">
       cccc

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3">
      DDDDDDDDDDDDDDDDDDDDDD

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">
      XXXXXXXXXXXXXXXXXXX

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2">
      ssss

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3">
      rrrr

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3">
      sdsdsd

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">
      jjjjjj

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2">
      jjjj

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3">
      rtrtrtrtrtrtrtrtrt

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3">
      hhhhhhhh

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">
      jjjjjj

Any help will be greatly appreciated.

A: You can use bootstrap for this

A

B

ccc

GGG

Please refer for more details:- https://www.w3schools.com/bootstrap4/tryit.asp?filename=trybs_grid_ex_structure&stacked=h

A:
using bootstrap class="form-check-inline" you can create a radio button inline.

<!DOCTYPE html>

 <meta charset="utf-8">
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
 <title></title>
 <link rel="stylesheet" href="">
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

Radio Buttons

     <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">
     A

     <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2">
     B

     <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3">
     C

     <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3">
     D

     <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">
     A

     <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2">
     B

     <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3">
     C

     <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3">
     D

I think your query will be solved. Thank You..!

A: I can think of wrapping around the classes will give your result.

Since you need to retain horizontal and vertical alignment you have to fix the width of the blocks and make it wrap to the next line when there is more data.

you can try something like this:

.Align {
  display: flex;
  width: 100%;
}

.form-check-inline {
  width: 22%; /* Fix the block, ofcourse it will work for all screens */
  border: 1px solid black;
  margin: 5px;
}

.form-check-label {
  padding:2px;
  overflow-wrap: break-word;
  width: 90%;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" />

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">
      A

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2">
      B

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3">
       cccc

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3">
      DDDDDDDDDDDDDDDDDDDDDD

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">
      XXXXXXXXXXXXXXXXXXX

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2">
      ssss

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3">
      rrrr

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3">
      sdsdsd

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">
      jjjjjj

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2">
      jjjj

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3">
      rtrtrtrtrtrtrtrtrt

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3">
      hhhhhhhh

      <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">
      jjjjjj

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to merge multiple router via gin before run Lets say I have some routes in a subemenuRoutes.go file like this:
package routes

import(
    "github.com/IamFrost/api-5/pkg/middlewares"

    "github.com/gin-gonic/gin"
)

// GetSubMenuRoutes return a group of routes for login
func GetSubMenuRoutes() *gin.Engine{
    router := gin.Default()
    menuRoutes := router.Group("/submenu")
    {
        getRoutes := menuRoutes.Group("/get")
        {
            getRoutes.GET("/getallsubmenus", middlewares.GetAllSubMenus)
        }
    }
    return router
}

And I am running them from main.go like this :
package main

import(
    "fmt"

    "github.com/IamFrost/api-5/pkg/routes"

    "github.com/gin-gonic/gin"
    "github.com/gin-contrib/cors"
)

func main(){

    fmt.Println("from main")

    router := gin.Default()

    router = routes.GetSubMenuRoutes()

    router.Use(cors.Default())
    router.Run(":3000")
}

Up to this, all working.
Now my question is :
lets say I have some other routes in a file menuRoutes.go :
package routes

import(
    "github.com/IamFrost/api-5/pkg/middlewares"

    "github.com/gin-gonic/gin"
)

// GetMenuRoutes return a group of routes for login
func GetMenuRoutes() *gin.Engine{
    router := gin.Default()
    menuRoutes := router.Group("/menu")
    {
        getRoutes := menuRoutes.Group("/get")
        {
            getRoutes.GET("/getallmenus", middlewares.GetAllMenus)
        }
    }
    return router
}

Now, I want to run both menu routes and submenu routes from main .
But In my main.go , you see, I did this before running,
router = routes.GetSubMenuRoutes()

So How Can I merge all routes coming from routes.GetSubMenuRoutes() and routes.GetMenuRoutes()
before I call router.Run in main.go?
Update:
As their doc said I wanted something like this in main.go, But my routes are coming from function. You see : I cant hardcode my route like v1 or v2 like them, because mine is coming from getMenuRoute() and getSubmenuRoute() function
func main() {
    router := gin.Default()

    // Simple group: v1
    v1 := router.Group("/v1")
    {
        v1.POST("/login", loginEndpoint)
        v1.POST("/submit", submitEndpoint)
        v1.POST("/read", readEndpoint)
    }

    // Simple group: v2
    v2 := router.Group("/v2")
    {
        v2.POST("/login", loginEndpoint)
        v2.POST("/submit", submitEndpoint)
        v2.POST("/read", readEndpoint)
    }

    router.Run(":8080")
}

A: instead of declaring your gin.Default() inside each function you can pass it as a parameter to your router functions.
func GetMenuRoutes(router *gin.Engine){

    menuRoutes := router.Group("/menu")
    {
        getRoutes := menuRoutes.Group("/get")
        {
            getRoutes.GET("/getallmenus", middlewares.GetAllMenus)
        }
    }
    return
}

or
you can register all these routes on to a main router using
a for loop.
your main func() will have the following lines
   func main() {
    v1 := getGroup1().Routes()
    v2 := getGroup2().Routes()
    rt := gin.Default()
    for _, a := range v1 {
        {
            rt.Handle(a.Method, a.Path, a.HandlerFunc)
        }
    }
    for _, a := range v2 {
        {
            rt.Handle(a.Method, a.Path, a.HandlerFunc)
        }
    }
    rt.Run(":8080")
   }

A: @whitespace 's answer is good. But I found another solution.
So, as you remember, I have a lot of routes coming from 2 functions.
I need to merge them, before main calls all of them
So my first route function from : menuRoutes.go
    package routes

    import(
        "github.com/IamFrost/api-5/pkg/middlewares"

        "github.com/gin-gonic/gin"
    )

    // GetMenuRoutes return a group of routes for menu
    func GetMenuRoutes(router *gin.Engine) *gin.Engine{

        menuRoutes := router.Group("/menu")
        {
            getRoutes := menuRoutes.Group("/get")
            {
                getRoutes.GET("/getallmenus", middlewares.GetAllMenus)
            }
        }

        return router
    }

My second route function from: submenuRoutes.go
package routes

import(
    "github.com/IamFrost/api-5/pkg/middlewares"

    "github.com/gin-gonic/gin"
)

// GetSubMenuRoutes return a group of routes for submenu
func GetSubMenuRoutes(router *gin.Engine) *gin.Engine{

    menuRoutes := router.Group("/submenu")
    {
        getRoutes := menuRoutes.Group("/get")
        {
            getRoutes.GET("/getallsubmenus", middlewares.GetAllSubMenus)
        }
    }
    // router.GET("/getallsubmenus", middlewares.GetAllSubMenus)
    return router
}

Finally, I merged both route groups to : main.go
package main

import(
    "fmt"

    "github.com/IamFrost/api-5/pkg/routes"

    "github.com/gin-gonic/gin"
    "github.com/gin-contrib/cors"
)

func main(){

    fmt.Println("from main")

    router := gin.Default()

    // router = routes.GetSubMenuRoutes()

    routes.GetMenuRoutes(router)
    routes.GetSubMenuRoutes(router)

    router.Use(cors.Default())
    router.Run(":3000")
}


text:
Q: Sharepoint web-form submit Thanks Message issue I have a web-part that includes a simple web-form. After submitting the web-form the user will receive an apropiate succes/error  message.
In the codeBehind for the Click_event of the submit button I have:
lblMessage.Text = "Your Profile Details were updated successfully";

And code in the asxc file:
<asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>

The problem is that message don't disappear after page refresh F5.
Any ideas?

A: The problem is that F5 isn't reload page, but replay last request. So pressing F5 will post the previous content once more.
Instead of showing a readonly form with a message will cause a lot of users to press F5 in order to get a new form ready for input the two following solutions will be better:

*

*Redirect to a new page with confirmation

*Show form ready for new input and include javascript to show a notification that previous input was accepted


text:
Q: Write JSON Object to file- append not working I'try to save my custom JSONObject into the file.Everything working correct but I can't append json into file.For example,If I click twice to save json,in my file I have one element.Here is a my source
public class TransactionFileManager {
public static final File path = Environment.
        getExternalStoragePublicDirectory(Environment.getExternalStorageState() + "/myfolder/");
public static final File file = new File(path, "transaction1.json");

public static String read() {
    String ret = null;
    try {
        BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
        try {
            String receiveString;
            StringBuilder stringBuilder = new StringBuilder();
            while ((receiveString = bufferedReader.readLine()) != null) {
                stringBuilder.append(receiveString);
            }
            ret = stringBuilder.toString();
            bufferedReader.close();
        } catch (NumberFormatException | IOException e) {
            e.printStackTrace();
        }
    } catch (FileNotFoundException e) {
        try {
            file.createNewFile();
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
        e.printStackTrace();
    }
    return ret;
}

public static void writeToFile(JSONObject data) {
    if (!path.exists()) {
        path.mkdirs();
    }
    try {
        FileOutputStream fOut = new FileOutputStream(file);
        OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fOut);
        outputStreamWriter.append(data.toString());
        outputStreamWriter.close();
        fOut.flush();
        fOut.close();
    } catch (IOException e) {
        Log.e("Exception", "File write failed: " + e.toString());
    }
}

}
How I can append json object into my .json file.What's a wrong in my code
thanks


text:
Q: Android textview autoscroll back and forth I have a textView, which looks like this:
             <TextView
                android:id="@+id/text_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="start"
                android:scrollHorizontally="true"
                android:ellipsize="marquee"
                android:marqueeRepeatLimit ="marquee_forever"
                android:singleLine="true" />

And this makes my textView scroll if I set it as selected programmatically with textView.isSelected = true.
What I want, though, is for the text view to scroll horizontally to the left and once it reaches the end to scroll back to the right, automatically. And I want this to happen only if the text cannot fit the layout.
Any ideas?
I thought about wrapping it in a horizontal view but still, how do I make it work like this?


text:
Q: Beyond compare ignore one side comments I found some instructions on how to show/hide differences in comments using beyond compare. However most of the answers show how to set comment as important text or not. That is, if a portion of code is commented on both sides then check if the comment are different or not.
I would like to ignore when only one side of the comparison is commented. In other words if I have
# # line1
# line2

on one side and
# line1
line2

I would like both lines to be marked as "unimportant differences" (if indeed the text is the same, otherwise to be marked as differences).

A: Beyond Compare will only compare text if it is of the same grammar element type. If one side is regular code and the other side is a comment, it will always mark it as an important difference.
To make regular text on one side and the same text commented on the other side show as a match, you'll need to edit the definition of a comment in the file format.

*

*To edit a format, open Tools > File Formats.

*Select the format that matches your files.

*Go to the Grammar tab.

*Select the Comment grammar element, which might be defined as # to end of line.

*Click the Edit (gear) button.

*Set the Category radio button to Basic.

*Text matching: ^#\s

*Check Regular expression.

*Click OK, then Save.

The updated file format will treat # followed by a whitespace character as an unimportant comment, the remaining text in the line will be treated as regular text and compared to the other side.


text:
Q: Ramda JS: How to perform a map where I call R.replace for a given property on each object? Given the following data:
const my_data = [
  {
    name: "John",
    age: 22
  },
  {
    name: "Johnny",
    age: 15
  },
  {
    name: "Dave",
    age: 27
  }
]

I want to transform the data such that the substring "John" is replaced with "Ben" in each of the name properties so it looks like this:
[
  {
    name: "Ben",
    age: 22
  },
  {
    name: "Benny",
    age: 15
  },
  {
    name: "Dave",
    age: 27
  }
]

I want to do so in the proper functional way (I think is points-free but I am still learning), so I can reuse this in a pipeline, say first reducing by age and then doing the replace, or doing the replace first then doing a sort.  How would I do this using the Ramda functions?
var fix_names = ???
var fixed_data = R.map( fix_names, my_data );

A: R.map(R.over(R.lensProp('name'), R.replace('John', 'Ben')))(my_data)

See R.over and R.lensProp.

A: There's no reason to prefer point-free functions. Readability is what really matters:

var myData = [ new Person("John",   22)
             , new Person("Johnny", 15)
             , new Person("Dave",   27)
             ];

var fixedData = myData.map(fixName);

alert(JSON.stringify(fixedData, null, 4));

function fixName(person) {
    return Object.assign(new Person, person, {
        name: person.name.replace(/John/g, "Ben")
    });
}

function Person(name, age) {
    this.name = name;
    this.age  = age;
}

Point-free functions are useful in very limited cases like eta conversion and function composition. Point-free functions should not be treated as the cornerstone of functional programming.


text:
Q: ASP.NET & Javascript: Setting values from one window to another I have a child browser window (aspx) opened from the parent application. The child window has some controls, and a textbox. When the user is finished, s/he clicks a button and the following code takes the value from the child window and populates the parent, like so:
window.opener.document.form1.InputContainer$LetterInput$txtReasons.value = txtVal;

This works great for the textbox I have on the parent page. But now, I need to populate a listbox and am not having much luck. I've tried these two methods but to no avail:
o.text = txtVal;
o.value = "1";
window.opener.document.form1.InputContainer$LetterInput$lstReasons.add(o);

window.opener.document.form1.InputContainer$LetterInput$lstReasons.add("Text", "Value");

I get "htmlfile: No such interface supported" with both.
Anybody have any ideas?
Thanks,
Jason

A: var newOption = document.createElement('option');
newOption.value = textbox.value; // The value that this option will have
newOption.innerHTML = textbox.value; // The displayed text inside of the <option> tags

// Finally, add the new option to the listbox
window.opener.document.form1.InputContainer$LetterInput$lstReasons.appendChild(newOption);

A: Okay, took a little reworking but found a solution!
First off, create a function in the parent aspx like this:
function NewOption(newVal)
{
//alert("The entry is: " + newVal);
var sel = document.getElementById("<%= MyListbox.clientID %>");
sel.options[sel.options.length]=new Option(newVal, newVal, true, true);
}

Then, call that function from the child page like this:
function SendValues()
{
var txtVal = document.form1.txtReasons.value;
var sel = window.opener.NewOption(txtVal);
}

There's still a kink or two (it only passes the text, not the value) but it that can be easily fixed by adding an extra parameter...
Hopefully someone else out there can use it!


text:
Q: Setting up an FTP share folder access from remote desktop Here is the setup: I have a computer running windows 7 where i connect to a remote desktop. I want to set up a shared folder using FTP so i can copy files from the remote desktop to my local machine. I've created the shared folder using the ISS tool. I set it up so that no credentials are needed (allowed access to all users and anonymous users). I tested it with other computers in the network and it works.
To access the file i want to use NET USE but when i try it from the remote desktop i get asked for a password.
How do I add the user from the remote desktop or what password and username is it expecting.
I am not the admin on the remote desktop, only on the local machine.
I can view the contents from the shared folder if i type ftp://3.xx.xx.x/   . This works on the remote desktop as well.
Please help.... im loosing my mind!!
Thanks

A: Try using Active mode from the FTP client. Worked for me, I couldn't even get a directory listing before.


text:
Q: haskell GHCi cant import module I'm having a weird problem.
I have a module, which is called "Compiler", the file itself is called compiler.hs.
If I try to import this module in another module (in the same directory), GHCi gives an error and says it cant find the file.
Now I have another module in the same directory, and works just fine when importing.
I use ghci program.hs to interpret the program. "program.hs" imports the compiler module.
My OS is a debian based linux distro and running GHCi, version 6.12.1:

A: Rename compiler.hs to Compiler.hs (with upper case "C"). Linux file names are case-sensitive.


text:
Q: If $D$ is the closed unit disk with the origin removed, is $D$ a closed set? A closed unit disk around P is the set of points whose distance from P is less than or equal to 1. In other words, $D(P)=\{Q:|P-Q|\leq 1\}$. Mathematically, the point removing the point $(0, 0)$ does not satisfy this condition and thus the disk is not closed. But intuitively, I am unable to rationalize this.
Any guidance is greatly appreciated!
Edit: My confusion stems from the fact that this new disk is not closed, but is also not open as per my understanding. So I am unable to rationalize the nature of this set.

A: Have you seen the characterization of closed sets as sets containing all their limit points? If you remove the origin from your closed disc $D$, then any sequence converging to it previously will now converge to a point outside of $D$, thus it is not closed. To give a concrete example, if you take the space $\mathbb{R}^2$ and look at the unit closed disk, you can take the sequence $(x_n)_{n\geq 1}$ where $x_n=(\frac{1}{n},0)$. This sequence converges to $(0,0)$ but it's fully contained in your closed unit disk, showing that puncturing the origin from that disk results in a non-closed set.
Here's a link to the limit points characterization: Prove that a set is closed iff it contains all its accumulation points

A: You can just work from the definition. A set $X$ is closed iff the complementary $X^C$ is open. But the complementary of your set is the exterior of the disk and the point $(0, 0)$. This set is not open because any open disk around $(0,0)$ is not contained in $X^C$ (this is, $(0,0)$ is not an interior point of $X^C$). Therefore, $X$ is not closed.


text:
Q: libvirt qemu-system-aarch64: Property '.pflash0' not found Goal
I'm currently trying to emulate an Raspberry Pi 3 using QEMU and libvirt (on Arch). I'm (mostly) following dhruvvyas90/qemu-rpi-kernel's native guide.
Just to have a starting (working) place to expand on, I'm using the following which runs fine
#!/bin/bash

sudo qemu-system-aarch64 \
  -m 1G \
  -smp 4 \
  -M raspi3 \
  -dtb "/.../bcm2710-rpi-3-b-plus.dtb" \
  -kernel "/.../kernel8.img" \
  -append "rw earlyprintk loglevel=8 console=ttyAMA0,115200 dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootdelay=1" \
  -sd "/.../image.qcow2" \
  -usb -device usb-mouse -device usb-kbd \
  -serial stdio

Now I'm trying to add it to libvirt. I've got the following XML (which also includes some extras over the QEMU command)
<domain type="qemu">
  <name>rpi3</name>
  <uuid>...</uuid>
  <metadata>
    <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
      <libosinfo:os id="http://debian.org/debian/10"/>
    </libosinfo:libosinfo>
  </metadata>
  <memory>2097152</memory>
  <currentMemory>2097152</currentMemory>
  <vcpu>4</vcpu>
  <os>
    <type arch="aarch64" machine="raspi3">hvm</type>
    <kernel>/.../kernel8.img</kernel>
    <cmdline>rw earlyprintk loglevel=8 console=ttyAMA0,115200 dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootdelay=1</cmdline>
    <dtb>/.../bcm2710-rpi-3-b-plus.dtb</dtb>
    <loader readonly="yes" type="pflash">/usr/share/AAVMF/AAVMF_CODE.fd</loader>
  </os>
  <features>
    <acpi/>
  </features>
  <clock offset="utc"/>
  <devices>
    <emulator>/usr/bin/qemu-system-aarch64</emulator>
    <disk type="file" device="disk">
      <driver name="qemu" type="qcow2"/>
      <source file="/.../image.qcow2"/>
      <target dev="sda" bus="sd"/>
    </disk>
    <interface type="network">
      <source network="default"/>
      <mac address="..."/>
    </interface>
    <console type="pty"/>
    <input type="mouse" bus="usb"/>
    <input type="keyboard" bus="usb"/>
    <redirdev bus="usb" type="spicevmc"/>
    <graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
      <gl enable="no"/>
      <image compression="off"/>
    </graphics>
    <video>
      <model type="qxl"/>
    </video>
    <controller type="usb" model="qemu-xhci" ports="15"/>
  </devices>
</domain>

When I try to add this with virt-manager, I get qemu-system-aarch64: Property '.pflash0' not found.
virt-install
I used the following to generate the XML (I went through every flag in virt-install --help and tried to map them from the original QEMU command in order):
sudo virt-install \
  --connect qemu:///system \
  --name rpi3 \
  --memory 2048 \
  --vcpus 4 \
  --import \
  --boot \
    "dtb=/.../bcm2710-rpi-3-b-plus.dtb,\
kernel=/.../kernel8.img,\
kernel_args=rw earlyprintk loglevel=8 console=ttyAMA0,115200 dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootdelay=1" \
  --os-variant debian10 \
  --disk "/.../image.qcow2,bus=virtio" \
  `# --input mouse,bus=usb` \
  `# --input keyboard,bus=usb` \
  `# --serial stdio` \
  --video qxl \
  --virt-type qemu \
  --arch aarch64 \
  --machine raspi3 \
  --print-xml \
  --check path_in_use=off

Checking the UEFI firmware files and related config
This is when using edk2-avmf AUR. After installing it, restarting libvirtd and checking virt-manager I have the firmwares showing up:

The package gives the following message:
 1. Uncomment or add/edit these lines in /etc/libvirt/qemu.conf

 nvram = [
 "/usr/share/AAVMF/AAVMF_CODE.fd:/usr/share/AAVMF/AAVMF_VARS.fd"
 "/usr/share/AAVMF/AAVMF32_CODE.fd:/usr/share/AAVMF/AAVMF32_VARS.fd"
 ]
 2. systemctl restart libvirtd

When I do this (with a trailing comma added on line 2) and restart, libvirtd fails to start. Status:
Nov 05 13:13:02 ... systemd[1]: libvirtd.service: Unit process 788 (dnsmasq) remains running after unit stopped.
Nov 05 13:13:02 ... systemd[1]: libvirtd.service: Unit process 818 (dnsmasq) remains running after unit stopped.
Nov 05 13:13:02 ... systemd[1]: libvirtd.service: Unit process 819 (dnsmasq) remains running after unit stopped.
Nov 05 13:13:02 ... systemd[1]: libvirtd.service: Start request repeated too quickly.
Nov 05 13:13:02 ... systemd[1]: libvirtd.service: Failed with result 'start-limit-hit'.
Nov 05 13:13:02 ... systemd[1]: libvirtd.service: Unit process 787 (dnsmasq) remains running after unit stopped.
Nov 05 13:13:02 ... systemd[1]: libvirtd.service: Unit process 788 (dnsmasq) remains running after unit stopped.
Nov 05 13:13:02 ... systemd[1]: libvirtd.service: Unit process 818 (dnsmasq) remains running after unit stopped.
Nov 05 13:13:02 ... systemd[1]: libvirtd.service: Unit process 819 (dnsmasq) remains running after unit stopped.
Nov 05 13:13:02 ... systemd[1]: Failed to start Virtualization daemon.

When I don't include the trailing comma (as the message suggests), I get the same issue but with a config parse error:
Nov 05 13:16:10 ... libvirtd[86519]: hostname: ...
Nov 05 13:16:10 ... libvirtd[86519]: Cannot find 'dmidecode' in path: No such file or directory
Nov 05 13:16:10 ... libvirtd[86519]: configuration file syntax error: /etc/libvirt/qemu.conf:770: expecting a value
Nov 05 13:16:10 ... libvirtd[86519]: Initialisation of QEMU state driver failed: configuration file syntax error: /etc/libvirt/qemu.conf:770: expecting a value
Nov 05 13:16:10 ... libvirtd[86519]: Driver state initialisation failed
Nov 05 13:16:10 ... systemd[1]: libvirtd.service: Succeeded.
Nov 05 13:16:10 ... systemd[1]: libvirtd.service: Unit process 787 (dnsmasq) remains running after unit stopped.
Nov 05 13:16:10 ... systemd[1]: libvirtd.service: Unit process 788 (dnsmasq) remains running after unit stopped.
Nov 05 13:16:10 ... systemd[1]: libvirtd.service: Unit process 818 (dnsmasq) remains running after unit stopped.
Nov 05 13:16:10 ... systemd[1]: libvirtd.service: Unit process 819 (dnsmasq) remains running after unit stopped.

I also made my own package that just installs Debian's UEFI aarch64 package and I get the same issue:
pkgname=qemu-efi-aarch64
pkgver=20181115.85588389
pkgrel=1
pkgdesc="A build of EDK II for 64-bit ARM virtual machines"
conflicts=("edk2-avmf")
arch=("any")
url="https://packages.debian.org/buster/qemu-efi-aarch64"
source=("http://ftp.<region>.debian.org/debian/pool/main/e/edk2/qemu-efi-aarch64_0~20181115.85588389-3+deb10u1_all.deb")
sha256sums=("08156f2b483958ea0cf3058adacb6ac2b70314d9825ccfe5e431e688024b7200")
package() {
    tar -xf data.tar.xz -C "${pkgdir}"
}

Considering an XML issue
The error suggests that there's a missing item in the XML file but virt-manager with no manual XML editing can trigger this issue and I can't see any other relavent mentions of pflash other than the loader tag.
Removing UEFI
The existing QEMU command doesn't even use UEFI (I also double-checked this with /sys/firmware/efi, it didn't exist), so I tried to remove it.
When I remove the loader tag, I get unsupported configuration: ACPI requires UEFI on this architecture.
When I remove <acpi/> (as well as the previous change), I get qemu-system-aarch64: Property '.acpi' not found.


text:
Q: how to do Angularjs authentication? Logincontroller.js
    angular
        .module('app.pages.auth.login')
        .controller('LoginController', LoginController);

    /** @ngInject */

    function LoginController($http, $location)
    {
        var vm = this;

        vm.submitPost =  function(userData){
            $http({
                url: 'http://localhost:7200/api/pages/auth/login',
                method: 'POST',
                data: userData
            }).then(function(res) {
                if(res.data.success){
                    $location.path('/pages/profile');
                    //console.log(res.data.success);
                    //vm.message=res.data.message;
                } else {
                    //console.log(res.data.message);
                    vm.message=res.data.message;
                    $location.path('/pages/auth/login');
                }
            }, function(error) {
                console.log(error);
                alert('here');
            });
        };
    }

route.js
    var User = require('../models/user');
    var config = require('../config');
    var secretKey = config.secretKey;
    var jsonwebtoken = require('jsonwebtoken');
    var validator = require('validator');
    var express = require('express');
    //var router = express.Router();
    var passport = require('passport');
    var LocalStrategy   = require('passport-local').Strategy;
    var flash = require('connect-flash');

    module.exports = function(app, express, passport){
    var router = express.Router();

    passport.use(new LocalStrategy({
        usernameField: 'username',
        passwordField: 'password'},
        function(username, password, done) {
            User.findOne({ name : username}, function(err, user) {
                if (!user){
                    return done(null, false,{message: 'Incorrect username' });
                }

                if(user){
                    var validPassword = user.comparePassword(password);

                    if(!validPassword){
                        return done(null, false,{message: 'Incorrect password' });
                    }
                }
                return done(null, user);
            });
        }
    ));

    router.post('/pages/auth/login', function(req, res, next) {
        passport.authenticate('local', function(err, user, info) {
            if (user === false) {
                console.log("login error ");
                return res.json({
                    success:false,
                    message: info.message,
                });
            } else {
                console.log("login success");
                return res.json({
                    success:true,
                    //message: 'Login Success',
                });
            }
        })(req, res, next);
    });

    router.post('/pages/auth/register',function(req, res){

        var user = new User({
            name: req.body.username,
            email: req.body.email,
            password: req.body.password
        });
        user.save(function(err){
            if(err){
                res.send(err);
                return;
            }
            res.json({
                success:true,
                message: 'User has been created!',
            });
        });
    });
    return router;
}

login.html

            F

Log in to your account

        <form name="loginForm">

{{vm.message}}

            <md-input-container flex md-no-float>
                <input ng-model="vm.form.username" placeholder="Username" translate
                       translate-attr-placeholder="LOGIN.USERNAME" name="username" required="true">

This field is required

            </md-input-container>

            <md-input-container flex md-no-float>
                <input ng-model="vm.form.password" type="password" placeholder="Password" translate
                       translate-attr-placeholder="LOGIN.PASSWORD" name="password" required="true">

This field is required

            </md-input-container>

                <md-checkbox class="remember-me" ng-model="data.cb1" aria-label="Remember Me">
                    Remember Me
                </md-checkbox>

                Forgot Password?

            <md-button class="md-raised md-accent" aria-label="LOG IN" translate="LOGIN.LOG_IN"
                       translate-attr-aria-label="LOGIN.LOG_IN"
                       ng-click="vm.submitPost(vm.form);">
                LOG IN
            </md-button>
        </form>

            OR

        <md-button class="md-raised google">

                <md-icon md-font-icon="icon-google-plus" class="s16"></md-icon>
                Log in with Google

        </md-button>

        <md-button class="md-raised facebook">

                <md-icon md-font-icon="icon-facebook" class="s16"></md-icon>
                Log in with Facebook

        </md-button>

            Don't have an account?
            Create an account

When i give http://localhost:7200/api/pages/profile in the address bar it directly goes to that page, it doesn't asking any login authentication. Pleas help me what are the changes i want to do for angularjs authentication.


text:
Q: How to prevent multiple login with same credentials from different device in angular Firebase application? How to prevent multiple login with same credentials from different device in angular Firebase application ?

A: Make an UUID and register it in the db on every login.
Then check if it match, if it not match, then logout.
Can do something like:
import { v4 as uuid } from 'uuid';
// on login
this.uuidValue = uuid();
//Add to db I would say realtime not firestore
this.doCheck();
//Check like
private doCheck() {
  this.checkSub = this.db.object(`uuid/$ID`).valueChanges().subscribe((_uuid: any) => {
  if(this.uuidValue !== _uuid) {
    //logout
    this.checkSub.unsubscribe();

A: I can think of two options. A simple not so secure one, and a more complicated more secure one:

*

*You could create a folder in your database that keeps track of logged in users. Then you can query it before or after someone tries to login and handle the event accordingly. Of course this way you can't prevent users from tampering with the javascript.

*If you want to make sure that people cannot circumvent your blocker you could implement custom authentication during which you check the database on the server and only return a token if nobody else is logged in. https://firebase.google.com/docs/auth/web/custom-auth


text:
Q: Net 6 DLL can't load System.Runtime.Caching when called from a /clr:netcore DLL I have a .Net 6.0 class library (trtDatatypesCore.dll) that uses the package System.Runtime.Caching.  The package version is: 6.0.0.
When I call it from a .Net 6.0 console application everything loads and runs fine.
To call this DLL from a cpp executable I created a managed cpp DLL  with the following settings:
/clr:netcore
Target Framework: net6.0
When it tries to load the trtDatatypesCore.dll I get the following Error:

System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Runtime.Caching, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.'

All of my DLLs are complied and run from  a common directory.  The package dll is in my user directory.
The trtDatatypesCore.deps.json contains:
"runtimeTarget": {"name": ".NETCoreApp,Version=v6.0","signature": ""},"compilationOptions": {},"targets": {".NETCoreApp,Version=v6.0": {"trtDatatypesCore/1.0.0": {"dependencies": {"Microsoft.Extensions.Caching.Memory": "6.0.0","Microsoft.Win32.Registry": "5.0.0","Newtonsoft.Json": "13.0.1","System.Runtime.Caching": "6.0.0","WinSCP": "5.19.6"},"runtime": {"trtDatatypesCore.dll": {}}},And

  "System.Runtime.Caching/6.0.0": {
    "dependencies": {
      "System.Configuration.ConfigurationManager": "6.0.0"
    },
    "runtime": {
      "lib/net6.0/System.Runtime.Caching.dll": {
        "assemblyVersion": "4.0.0.0",
        "fileVersion": "6.0.21.52210"
      }
    },

I created test console applications (both c++ and NetCore) to test the calling of the c# library to remove the possibility of another version of the DLL being loaded elsewhere.
I verified my Configuration Manager settings are:
Debug: x86
C++ Projects- Platform = WIn32
Core Projects- Platform = Any CPU
Edit:
I deleted the package and referenced the DLL directly with the 'copy local' set.  The dll was copied into the directory with all the other dlls.  Same result.


text:
Q: Android runtime permission passes even if it doesn't have permission I'm developing an app on two different computers, and using github to sync the project using Android Studios git tools.
I can't get the permissions right after I ran my app from my secondary workstation.
It seems ActivityCompat.checkSelfPermission() returns true even if the app doesn't have the required permissions, which leads the app to skip the ActivityCompat.requestPermissions()  method.
Android Studio asks me to reinstall the app every time I switch workstations, as the signatures doesn't match or something. I assume the app might remember the old permissions even if it haven't gotten new ones?
compileSdkVersion 27
minSdkVersion 19
targetSdkVersion 27

Why the hell is ActivityCompat.checkSelfPermission()  returning true when I have no permissions?
I ask for all the permissions in my MainActivity in the oncreate() method:
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED &&
            ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
                    != PackageManager.PERMISSION_GRANTED &&
            ActivityCompat.checkSelfPermission(this, Manifest.permission.INTERNET)
                    != PackageManager.PERMISSION_GRANTED) {

        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.INTERNET}, 123);
        Toast.makeText(this, "This app needs camera and storage permissions", Toast.LENGTH_LONG).show();

    }else{
        onCreateAfterPermission();
    }

}

I then handle the response:
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {

    if (requestCode == 123) {
        if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            onCreateAfterPermission();

        }else{
            // close the app
            Toast.makeText(this, "Sorry!!!, you can't use this app without granting permissions", Toast.LENGTH_LONG).show();
            this.finish();
        }
    }
}

A: Remove following check from your if condition:
ActivityCompat.checkSelfPermission(this, Manifest.permission.INTERNET)!= PackageManager.PERMISSION_GRANTED

The above condition will be always evaluate to false since Internet permission is classified as normal permission and is granted at installation time.
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED &&
            ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
                    != PackageManager.PERMISSION_GRANTED) {

        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 123);
        Toast.makeText(this, "This app needs camera and storage permissions", Toast.LENGTH_LONG).show();

    }else{
        onCreateAfterPermission();
    }

}

One more thing, you should segregate the checking for CAMERA & WRITE_EXTERNAL_STORAGE permission. This is because, there could be case where CAMERA permission is granted but WRITE_EXTERNAL_STORAGE permission is not granted.
With your checking the condition will not satisfy hence WRITE_EXTERNAL_STORAGE wont be asked.
Check out this SO for implementation details for better approach.

A: AS per my above comment
No need to ask runtime permission for INTERNET because it is granted at the time of app installation
FYI
Dangerous  permission are need to ask runtime from os  marshmallow and above
The  INTERNET is normal
For more information please check this post  Normal permissions and dangerous permissions
Try this
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED &&
            ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
                    != PackageManager.PERMISSION_GRANTED ) {

        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 123);
        Toast.makeText(this, "This app needs camera and storage permissions", Toast.LENGTH_LONG).show();

    }else{
        onCreateAfterPermission();
    }

}

to ask multiple runtime permission please check below post

*

*Android 6.0 multiple permissions

*Ask Multiple Permissions Android

*How to ask multiple permissions at the same time in android 6.0+

*How to ask multiple permissions at same time in Android Marshmelllow


text:
Q: How to write the regex expression?
The input string: A+SUM(A)C+AB-C+SUM(A)+1
I want to replace A with 0, the result like this:0+SUM(A)C+AB-C+SUM(A)+1
or replace SUM(A) with 0,  the result like this:A+SUM(A)C+AB-C+0+1
Thanks

A: Without Regex (because Regex is overkill for this):
var s = "A+SUM(A)+B-C";

var replaceBeginningA = s.Replace("A+", "0+");
var replaceSumA = s.Replace("SUM(A)", "0");

Console.WriteLine(replaceBeginningA); // 0+SUM(A)+B-C
Console.WriteLine(replaceSumA); // A+0+B-C

As pointed out in the comments though, you need to provide more detail if this input is expected to have a different format.

A: maybe:
replace ^A with 0
replace SUM\(A\) with 0

A: Try thus:
string replaced = Regex.Replace(input, @"\b(\w+)\+SUM\(\1\)", "0+0");

This will match anything of the form
foo+SUM(foo)

and replace it with 0+0


text:
Q: Implementing a C preprocessor Much has been written over the years on implementing parsers, but the C preprocessor is not quite the same as any of the stages of a typical parser, and implementation thereof doubtless has its share of particular pitfalls to watch out for. Does anyone know of anything written on the topic of implementing a C preprocessor?

A: Hartmut Kaiser, the author of Boost Wave, wrote a nice article on CodeProject http://www.codeproject.com/KB/recipes/wave_preprocessor.aspx about the Boost Wave project. You can use Boost Wave to make your own C preprocessor with custom extensions.

A: I found a useful discussion in the document mcpp-summary at http://mcpp.sourceforge.net/

A: I've based mine on the gnu internals


text:
Q: material-ui TextField type number up/down arrows not appearing I added TextField type='number' to my react component but up/down arrows are not appearing
<TextField type="number"  />
<TextField
          id="filled-number"
          label="Number"
          type="number"
          InputLabelProps={{
            shrink: true,
          }}
          margin="normal"
          variant="filled"/>

Both are not working what can cause this?


text:
Q: Get the most recent submission from a team in a submissions table (SQL) I have a table that can be simplified as:
ID  |team_id |  submission file  | date
========================================
1   |  1756  |  final_project.c  |2018-06-22 19:00:00
2   |  1923  |       asdf.c      |2018-06-22 16:00:00
3   |  1756  |     untitled.c    |2018-06-21 20:00:00
4   |  1923  |   my_project.c    |2018-06-21 14:00:00
5   |  1756  |     untitled.c    |2018-06-21 08:00:00
6   |  1814  |   my_project.c    |2018-06-20 12:00:00

This is a table of people submitting their projects to me, but I only want each individual students' most recent submission, with each student having a unique team_id.
How do I recall the most recent row of each team_id so that my recall looks like this:
ID  |team_id |  submission file  | date
========================================
1   |  1756  |  final_project.c  |2018-06-22 19:00:00
2   |  1923  |       asdf.c      |2018-06-22 16:00:00
6   |  1814  |   my_project.c    |2018-06-20 12:00:00

Thank you for the help!

A: Subquery will do what you want with correlation approach :
select t.*
from table t -- Need to replace table with your table-name i.e. Projecttble, etc..
where id = (select t1.id
            from table t1 -- Need to replace table with your table-name
            where t1.team_id = t.team_id
            order by t1.date desc
            limit 1
           );

A: You could use a self join to pick most recent row per team
select a.*
from your_table a
join (
    select team_id, max(date) date
    from your_table
    group by team_id
) b on a.team_id = b.team_id and a.date = b.date

A: EDIT: Yogesh beat me to the MySQL 5 answer while I was AFK. You'll want to join your subquery on both the team_id and the submission_file in case you get multiple file submissions from a team on the same day.
Depending on what version of MySQL you are using, this can be done different ways.
SETUP

CREATE TABLE t1 (ID int, team_id int, submission_file varchar(30), the_date date) ;

INSERT INTO t1 (ID,team_id,submission_file,the_date)
SELECT 1, 1756, 'final_project.c', '2018-06-20 19:00:00' UNION ALL
SELECT 2, 1923, 'asdf.c', '2018-06-22 16:00:00' UNION ALL  /**/
SELECT 3, 1756, 'untitled.c', '2018-06-21 20:00:00' UNION ALL  /**/
SELECT 4, 1923, 'my_project.c', '2018-06-21 14:00:00' UNION ALL  /**/
SELECT 5, 1756, 'untitled.c', '2018-06-21 08:00:00' UNION ALL
SELECT 6, 1814, 'my_project.c', '2018-06-20 12:00:00'  UNION ALL/**/

SELECT 7, 1756, 'final_project.c', '2018-06-21 19:00:00' UNION ALL
SELECT 8, 1756, 'final_project.c', '2018-06-22 00:00:00' /**/

;

QUERIES
If you are using MySQL 5.x or lower, then you'll want to use a correlated subquery with a LIMIT on it to pull up just the rows you want.

/* MySQL <8 */
SELECT a.*
FROM t1 a
WHERE a.id = (
    SELECT b.id
    FROM t1 b
    WHERE b.team_id = a.team_id
      AND b.submission_file = a.submission_file
    ORDER BY b.the_date DESC
    LIMIT 1
) ;

ID | team_id | submission_file | the_date
-: | ------: | :-------------- | :---------
 2 |    1923 | asdf.c          | 2018-06-22
 3 |    1756 | untitled.c      | 2018-06-21
 4 |    1923 | my_project.c    | 2018-06-21
 6 |    1814 | my_project.c    | 2018-06-20
 8 |    1756 | final_project.c | 2018-06-22

MySQL 8 added window functions (FINALLY), and this makes a problem like this MUCH easier to solve, and likely much more efficient, too. You can sort the rows you need with a ROW_NUMBER() window function.

/* MySQL 8+ */
SELECT s1.ID, s1.team_id, s1.submission_file, s1.the_date
FROM (
  SELECT ID, team_id, submission_file, the_date
    , ROW_NUMBER() OVER (PARTITION BY team_id, submission_file ORDER BY the_date DESC) AS rn
  FROM t1
) s1
WHERE rn = 1
;

ID | team_id | submission_file | the_date
-: | ------: | :-------------- | :---------
 8 |    1756 | final_project.c | 2018-06-22
 3 |    1756 | untitled.c      | 2018-06-21
 6 |    1814 | my_project.c    | 2018-06-20
 2 |    1923 | asdf.c          | 2018-06-22
 4 |    1923 | my_project.c    | 2018-06-21

db<>fiddle here
NOTE: After re-reading the OP, the intent may be different than what I originally read. In my queries, my filtering will return the most recent of all unique submission_file names that a team submitted. So if a team submitted 3 files, you will get all 3 of the most recent versions of those files. If you remove submission_file from the 5 subquery and the 8 PARTITION BY, it will return only the most recent single file a team submitted regardless of name.


text:
Q: Fail to write model history to a json file in the end of 2nd epoch of a keras fit_generator training I am using a customized callback to save model history parameters (loss, acc, etc.) to a json file on_epoch_end. I used a keras fit_generator to train the data. In the end of 1st epoch, everything works fine and i can get the json file with parameters. However, after 2nd epoch, i always encounter an long error ending with "TypeError: Object of type 'float32' is not JSON serializable". I am very confused, because the model history is a dictionary.
I have tried:
1) change json.dumps to json.dump. But the same error in the end of 2nd epoch
2) I have commented out json file portion, and add a code "print(self.H)" in my callback class. It works. By every end of epoch, the model history dictionary can be printed out and my training can be completed without error.
3) I use lr decay. One observation is that there is no "lr" parameter in the model history dictionary for the 1st epoch, and a "lr" parameter will be added since 2nd epoch onwards for the history dictionary.
class TrainingMonitor(BaseLogger):
    def __init__(self, figPath, jsonPath=None, startAt=0):
        # store the output path for the figure, the path to the JSON
        # serialized file, and the starting epoch
        super(TrainingMonitor, self).__init__()
        self.figPath = figPath
        self.jsonPath = jsonPath
        self.startAt = startAt

    def on_train_begin(self, logs={}):
        # initialize the history dictionary
        self.H = {}

    def on_epoch_end(self, epoch, logs={}):
        # loop over the logs and update the loss, accuracy, etc.
        # for the entire training process
        for (k, v) in logs.items():
            l = self.H.get(k, [])
            l.append(v)
            self.H[k] = l

        # check to see if the training history should be serialized to the file
        if self.jsonPath is not None:
            f = open(self.jsonPath, "w")
            f.write(json.dumps(self.H))
            f.close()

A: problem solved by changing "l.append(v)" to "l.append(float(v))". The error is because that data type of "lr" is numpy.float32 and json's encoder might not be able to encode it. Below shows data type has been changed to native Python float type then no problem to be written into json.
acc <class 'numpy.float64'>

acc <class 'float'>

lr <class 'numpy.float32'>

lr <class 'float'>


text:
Q: Can we have nonsimple graph from random graph? From the definition given by Alon and Spencer:

Let $n$ be a positive integer, $ 0 \leq p \leq 1$. The random graph
  $G(n,p)$ is a probability space over the set of graphs on the vertex
  sex $\{1,...,n\}$ determined by Pr$[\{i,j\} \in G] = p$ with these
  events mutually independent.

It seems here that there is no restriction from having nonsimple graph.
But the definition given in Newman's Network:

$G(n,p)$ is the ensemble of networks with $n$ vertices in which each
  simple graph $G$ appears with probability $P(G) = p^m(1-p)^{{n \choose2}-m}$, where $m$ is the number of edges in the graph, and non-simpe
  graphs have probability zero.

Clearly from this definition there is no nonsimple graphs? But how is that consistent with Alon's definition?
Thanks in advance.


text:
Q: Lock on object in multi threading I have a question here in object locking in java.
Ex. code:
public class A
{
    private static A a = null; // singleton instance

    private A()
    {

    }

    public static synchronized A getInst()
    {
        if (a == null)
        {
            a = new A();
        }
        return a;
    }

    public synchronized void method1()
    {
        //some action
    }

    public synchronized void method2()
    {
        //some action
    }
}

When a thread (say thread-1) is working inside method1() then thread-1 acquires lock on the singleton object. But another thread (say thread-2) wants to enter in to the method2() then it will enter without waiting thread-1 to release the lock. How this lock is shared by both thread-1 and thread-2?
Thanks

A:
But another thread (say thread-2) wants to enter in to the method2 then it will enter without waiting thread-1 to release the lock.

It won't.
At one time only one thread can acquire the lock on an object.
So, unless thread-1 releases the lock, thread-2 can't execute method2.
Read this.

A: You should use a synchronized blocks using a specific lock object instead of synchronizes methods.
In such a case it is also easy to block just specific parts of methods where the lock is needed which might speed up multithreaded access if you don't need to synchronize the whole method.
e.g.
Object lock = new Object;
public void method1() {
    synchronized(lock) {
      // do stuff here
    }
}

A: In a singleton class only one instance will be available. so when calling synchronized methods it will lock that single instance. If more than one synchronized methods present,only one method will be executed at a time. Other need to wait for previous method to release the lock. So basically only one thread exists for this singleton class.
If you want other methods not to be affected because of other methods lock, use synchronized block with object lock in singleton class.
private final Object object1 = new Object();
private final Object object2 = new Object();

public void method1 {
    synchronized(object1) {
    ....
    }
}

public void method2 {
    synchronized(object2) {
    ....
    }
}

A: Both synchronized methods are instance methods so, multiple threads will not be able to access them at same time if all of them refer to same instance. In you case this is true, because you only have one instance of your class (singleton pattern), and as a result if one thread is accessing method1() then other thread accessing method2() will go in wait state, until thread1 releases the lock or method1() is executed completely.

A:
But another thread (say thread-2) wants to enter in to the method2
  then it will enter without waiting thread-1 to release the lock.

While thread1 executes method1() which is synchronized using the instance of A, thread2 will wait before it can execute method2() which is also synchronized using the same instance of A (since it is Singleton)
You can consider it as synchronized code blocks (Critical Section) instead of synchronized methods such as :
public void method1()
{
    synchronized (this)
    {
        //some action
    }
}

public void method2()
{
    synchronized (this)
    {
        //some action
    }
}

Considering such, you can see this refers to the same instance (object lock) for both methods


text:
Q: Formula for the sum $\sum_{k=0}^a \frac{x^k}{k!}$ How does one find a formula for the sum $\sum_{k=0}^a \frac{x^k}{k!}$ ? According to the post mentioned in the comments:
$$\sum_{k=0}^n \frac{x^k}{k!}=\frac{ \Gamma (n+1,x)}{n!}e^x$$
...but how do you actually evaluate $\Gamma (n+1,x)$ for the positive integer n?


text:
Q: Define the integral for the powerset of a countable set. Say I have a countable set. I can sum over the elements of this set. Now, I take its powerset. I am no longer sum, but I can use the integral. How do I define an integral on the powerset of a countable set?
$$
\sum_{q\in\mathbb{N} } \to \int _{2^\mathbb{N}}dq
$$
It seems that the reals have so much more structure to support an integral than the powerset of a countable set. For example, they are ordered, and continuous and form ranges, etc...


text:
Q: Как правильно производить сериализацию объекта Доброго времени суток!
Как правильно производить сериализации объектов? Предполагается реализовать красиво метод сохранения настроек приложения в xml формат. Сейчас сделано топорно через xmlwriter переписывается файл при закрытии приложения.
Видел в примерах кода атрибуты serizable и прочее, наверняка что-то полезное. Расскажите, как правильно организовать в коде логику, где почитать умные слова на эту тему?
Спасибо.
A: Авторы говорят так: Примеры XML-сериализации

XML-сериализация может иметь несколько форм, от простой до сложной. Например, можно сериализовать класс, который состоит всего лишь из открытых полей и свойств, как показано в разделе Введение в XML-сериализацию. В следующих примерах кода представлены различные сложные сценарии, включая способы использования XML-сериализации для создания потока XML, соответствующего определенному документу схемы XML (XSD).


text:
Q: setOnChildClickListener of expandablelistview doesn't take action I am newbie to android development .
My goal to make  an Expandable List view  and on each child of a group of that expandable
list view I want to set an event when that child clicked.
So  I have downloaded  a ready android project from here .
http://mylifewithandroid.blogspot.com/2011/06/hiding-group-indicator-for-empty-groups.html
and run it by eclipse IDE .

I add this code to ExpList3 class to test an event.
but no  event gained when press any   child of a list view group
getExpandableListView().setOnChildClickListener(new OnChildClickListener()
            {
            @Override
            public boolean onChildClick(ExpandableListView arg0, View v,
                        int groupPosition, int childPosition, long id) {

                    if(groupPosition==0&&childPosition==0 )
                    {
                        TextView myTextView =
                                 (TextView)findViewById(R.id.groupname);
                                 myTextView.setText("Text Changed");
                    }

                    else if(groupPosition==0&&childPosition==1)
                    {
                        TextView myTextView =
                                 (TextView)findViewById(R.id.groupname);
                                  myTextView.setText("Text Changed");
                    }
                    else if(groupPosition==1&&childPosition==0&&id==0)
                    {
                        TextView myTextView =
                                 (TextView)findViewById(R.id.groupname);
                                 myTextView.setText("Text clicked");

                    }
                    return false;

                }

            });

A: You have used a textview and setting clicked list item in the textview. Use Toast to view the clicked item. Also location of the textview matters in displaying your clicked item.


text:
Q: What does "in camphor" mean? A part of Circular Staircase, by Mary Roberts Rinehart:

However, I did the best I could.  When Gertrude got past the hair-ribbon age, and Halsey asked for a scarf-pin and put on long trousers--and a wonderful help that was to the darning.--I sent them away to good schools.  After that, my responsibility was chiefly postal, with three months every summer in which to replenish their wardrobes, look over their lists of acquaintances, and generally to take my foster-motherhood out of its nine months' retirement in camphor.

Was it a misspelling or dead expression?
I can't find any proper meaning of this word in any dictionary to fit in the above sentence.

A: It's another way of saying "mothballed"

A: Camphor is used (among other applications) as a repellent against moths and other insect pests.
So I take the mention of 'retirement in camphor' in the extract you cited as a somewhat laboured reference to the fact that for nine months of the year, the author's foster-motherhood was 'in mothball storage'.
Her comment that during the three months of the year in which she was actively involved with her foster children she would replenish their wardrobes subtly encourages or emphasises this interpretation.


text:
Q: How to resolve gradle warning: Ignoring InnerClasses attribute for an anonymous inner class How to resolve the following gradle warning? I added the library by this line:
implementation 'org.apache.commons:commons-collections4:4.1'

Warning:warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.collections.ReferenceMap$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.

A: Try to add -keepattributes InnerClasses in your ProGuard config
edit : try with -dontoptimize


text:
Q: Why am I getting a different expected response to my actual? Im trying to match an actual response to expected Json file I have within my project which currently looks like this.
         [
          {
            "id": "1",
            "createdAt": "2020-10-27T19:10:01.232Z",
            "title": "title 1",
            "sensitive": false,
            "topics": [
              "business",
              "politics",
              "technology"
            ],
            "image": null,
            "priority": 89
          },
          {
            "id": "2",
            "createdAt": "2020-10-28T07:45:21.526Z",
            "title": "title 2",
            "sensitive": true,
            "topics": [],
            "image": {
              "url": "https://imgur.com",
              "fileType": ".jpg"
            },
            "priority": 45
          },
          {
            "id": "3",
            "createdAt": "2020-10-27T13:09:32.347Z",
            "title": "£31 million pounds shortfall in economy",
            "sensitive": false,
            "topics": [],
            "image": {
              "url": "https://imgur.com",
              "fileType": ".svg"
            },
            "priority": 25
          },
          {
            "id": "4656364867443",
            "createdAt": "2020-10-27T17:03:33.158Z",
            "title": "title 4",
            "sensitive": true,
            "topics": [
              "USA"
            ],
            "image": {},
            "priority": 0
          },
          {
            "id": "5",
            "createdAt": "2020-10-28T02:46:16.766Z",
            "title": "title 5",
            "sensitive": false,

    "topics": [],
        "image": {},
        "p

riority": 56
  }
]

However when I get my expected and actual they look totally different to what I want? It seems to be placing a <> in my expected which isn't there.
Expected: a collection containing <[{createdAt=2020-10-27T19:10:01.232Z, image=null, topics=[busine

ss, politics, technology], id=1, sensitive=false, title=title 1, priority=89}, {createdAt=2020-10-28T07:45:21.526Z, image={url=https://imgur.com, fileType=.jpg}, topics=[], id=2, sensitive=true, title=title 2, priority=45}, {createdAt=2020-10-27T13:09:32.347Z, image={url=https://imgur.com, fileType=.svg}, topics=[], id=3, sensitive=false, title=£31 million pounds shortfall in economy, priority=25}, {createdAt=2020-10-27T17:03:33.158Z, image={}, topics=[USA], id=4656364867443, sensitive=true, title=title 4, priority=0}, {createdAt=2020-10-28T02:46:16.766Z, image={}, topics=[], id=5, sensitive=false, title=title 5, priority=56}]>

Actual: [{createdAt=2020-10-27T19:10:01.232Z, image=null, topics=[business, politics, technology], id=1, sensitive=false, title=title 1, priority=89}, {createdAt=2020-10-28T07:45:21.526Z, image={url=https://imgur.com, fileType=.jpg}, topics=[], id=2, sensitive=true, title=title 2, priority=45}, {createdAt=2020-10-27T13:09:32.347Z, image={url=https://imgur.com, fileType=.svg}, topics=[], id=3, sensitive=false, title=£31 million pounds shortfall in economy, priority=25}, {createdAt=2020-10-27T17:03:33.158Z, image={}, topics=[USA], id=4656364867443, sensitive=true, title=title 4, priority=0}, {createdAt=2020-10-28T02:46:16.766Z, image={}, topics=[], id=5, sensitive=false, title=title 5, priority=56}]

My code: I've played around with the expectedJson.getList thinking it might be something to do with that however I'm a bit stumped.
@Test
public void GetArticlesJson() {
    JsonPath expectedJson = new JsonPath(new File(pathJson));

    given().

      when().
                get(allArticles).
                then().
                assertThat().
                contentType(ContentType.JSON).
                and().
                body("", hasItem(expectedJson.getList("")));
        System.out.println("Expected " + expectedJson.getList(""));
    }

A: I think you can converse .toString() and compare them. Even though, you can put it in object and compare them or compare a small parameter like id,createdAt,etc...
compare text evidence


text:
Q: How to integrate with Windows Phone's Office's/Pictures Share window? Windows phone 8 applications enables to share information over some platforms, such as Email and Tap+Send (Consider this image).
Can I compose a program that will be launchable from that Share window?
And if so, what Capability should I define in the WMAppManifest?
(Oh, and same goes for the WP8's Office Share Window)

A: Regarding the "Photo Share" option, I found this article in MSDN.
I still haven't found anything to allow the same functionality via Office.


text:
Q: Passing a thread local variable to JUnit test I have a thread which inits a thread local class variable and starts with running unit tests:
public class FooThread extends Thread {
    TestRunner runner;
    Foo foo;

    public void run() {
        initSomeThreadLocalStuff(); // inits foo and runner
        runner.runJUnitTests(); // JUnitCore.runTest(TestClass)
    }

    private void initSomeThreadLocalStuff() {
        foo = new Foo(this);
        // ...
    }
}

public class Foo() {
    public Foo(FooThread t) {
        // ...
    }
}

Now I want to run the JUnit tests with access (or a reference) to the thread local object foo. Is this possible? I tried to keep it simple but the complicated thing seemed not to be clear (so I added some code): the Foo object needs the current FooThread to be initialized.

A: Looks like JUnit parameterized unit tests is what you're looking for.
Edit: Sample code based on the example provided on the JUnit wiki:
@RunWith(Parameterized.class)
public class Test {

    @Parameters
    public static Collection<Object[]> data() {
        return Arrays.asList(new Object[][] {{ new ThreadLocalProvider() }});
    }

    @Parameter(value = 0) // first data value (0) is default
    public /* NOT private */ ThreadLocalProvider tloProvider;

    public ThreadLocal<Object> tlo;

    @Before
    public void setup() {
        // getNew() will be called in the same thread in which the unit test will run.
        tlo = tloProvider.getNew();
    }

    @Test
    public void test() {
        // Test using tlo.
    }
}

class ThreadLocalProvider {
    public ThreadLocal<Object> getNew() {
        // Instantiate a *new* ThreadLocal object and return it.
    }
}

Note: If you use a provider, you can run your tests without using the Parameterized runner as well (just get a new object from the provider in the @Before method) but since I don't know much about your code or requirement, I'll leave that choice to you.
Also, you don't need to instantiate your own JUnit Runner. You can use a Runner provided by JUnit (reference) along with the @RunWith annotation.

A: no idea why do you need threadLocal. if you need run same tests with different parameters then just create a list of those parameters and use parameterized tests (junit's native or of many libraries like zohhak or junit-dataprovider).
if for any reason you need to access thread local inside your tests then you also need to insert data to it inside the test because before running tests you don't know what thread will be used to run the test. but still it seems like you can write one tests to check if your code correctly uses threadLocal and then parameterized tests to check if your code correctly handles value taken from threadLocal


text:
Q: npm WARN tarball tarball data for @expo/traveling-fastlane-darwin@1.10.0 seems to be corrupted. Trying one more time E:\React native\Demo>npm install -g expo-cli
npm WARN deprecated joi@14.0.4: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated joi@11.4.0: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated hoek@4.2.1: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated topo@2.0.2: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated hoek@6.1.3: This module has moved and is now available at @hapi/hoek. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
npm WARN deprecated topo@3.0.3: This module has moved and is now available at @hapi/topo. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
npm WARN tarball tarball data for @expo/traveling-fastlane-linux@1.10.0 (sha512-+9Mjvs9m15Meexp00A2JDXLfQHwcgua1dI0ldqVboHblzTACTMvXrfHmewxBoIBLZ45c1lLuIHD7+3UAnBHVCA==) seems to be corrupted. Trying one more time.
npm WARN tarball tarball data for @expo/traveling-fastlane-darwin@1.10.0 (sha512-Ry9gHhDIPjSnP5lvtUcR7LoE5vU2Ngn893B22PYEk1RuwJG5m7ezKSGyXjs3W1WVUvPW/2+ikF1YjrNyPAIrqQ==) seems to be corrupted. Trying one more time.
[            ......] \ extract:rxjs: WARN tarball tarball data for @e**strong text**

A: Install @expo/traveling-fastlane-linux first with
npm i -g @expo/traveling-fastlane-linux

before installing expo-cli globally via npm.
This worked for me. Hope this helps others who are facing the same issue.


text:
Q: Transform training data into array in Neural network I am trying a time prediction model in deeplearning4j for text processing which takes no of words,sentences,char as input features and produces time as output.But while modelling input data to output i am having difficulties to transform these values and how to tell the network for these values of input these are respective output values.
Also should i reduce dimensionality from just having x1 and y.instead of x1-x4?
training-data.csv has the below columns with 100 values.
x1,x2,x3,x4(inputs) y(output)
I tried using SequenceRecorder and Iterator which can capture variant inputs.
below is my code
public static void main(String[] args) throws Exception
{
    // Initlizing parametres
    final Logger log = LoggerFactory.getLogger(MainExpert.class);
    final int seed =123;
    final int numInput = 4;
    final int numOutput = 1;
    final int numHidden = 20;
    final double learningRate = 0.015;
    final int batchSize =30;
    final int nEpochs =30;
    //final int inputFeatures =4;

    //Constructing Training data

    final File baseFolder =new File("/home/aj/my/samples/corpus");
    final File testFolder = new File("/home/aj/my/samples/corpus/train_data_0.csv");
    SequenceRecordReader trainReader = new CSVSequenceRecordReader(0,",");
    trainReader.initialize(new NumberedFileInputSplit(baseFolder.getAbsolutePath() + "/train_data_%d.csv",0,0));
    DataSetIterator trainIterator = new SequenceRecordReaderDataSetIterator(trainReader,batchSize,-1,4,true);

    SequenceRecordReader testReader = new CSVSequenceRecordReader(0,",");
    testReader.initialize(new NumberedFileInputSplit(baseFolder.getAbsolutePath() + "/test_data_%d.csv",0,0));
    DataSetIterator testIterator = new SequenceRecordReaderDataSetIterator(testReader,batchSize,-1,4,true);

    DataSet trainData = trainIterator.next();
    System.out.println(trainData);
    DataSet testData = testIterator.next();

    NormalizerMinMaxScaler normalizer = new NormalizerMinMaxScaler(0, 1);
    normalizer.fitLabel(true);
    normalizer.fit(trainData);
    normalizer.transform(trainData);
    normalizer.transform(testData);

    //Configuring Network
    log.info("Building Model");
    MultiLayerConfiguration config = new NeuralNetConfiguration.Builder()
            .seed(seed)
            .iterations(1)
            .optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
            .learningRate(learningRate)
            .updater(Updater.NESTEROVS).momentum(0.9)
            .list()
            .layer(0, new DenseLayer.Builder()
                    .nIn(numInput)
                    .nOut(numHidden)
                    .weightInit(WeightInit.XAVIER).
                    activation(Activation.RELU)
                    .build())
            .layer(1, new DenseLayer.Builder()
                    .nIn(numHidden)
                    .nOut(numHidden)
                    .weightInit(WeightInit.XAVIER)
                    .activation(Activation.RELU)
                    .build())
            .layer(2, new OutputLayer.Builder(LossFunction.MSE)
                    .nIn(numHidden)
                    .nOut(numOutput)
                    .weightInit(WeightInit.XAVIER)
                    .activation(Activation.IDENTITY)
                    .build())
            .pretrain(false).backprop(true).build();

    //Initializing network
    log.info("initlizing model");
    MultiLayerNetwork model = new MultiLayerNetwork(config);
    model.init();
    model.setListeners(new ScoreIterationListener(1));

    log.info("Training Model");
    for(int i=0;i<nEpochs;i++)
    {
        model.fit(trainData);
    }
    //Evaluation
    RegressionEvaluation reval=new RegressionEvaluation(1);

        while(testIterator.hasNext())
        {
    INDArray feat =testData.getFeatureMatrix();
    INDArray labels =testData.getLabels();
    INDArray prediction =model.output(feat);
    reval.eval(labels, prediction);
}
    System.out.println(reval.stats());
}

}
my data has four input values and one output values.
But i get an exception
 org.deeplearning4j.exception.DL4JInvalidInputException: Input that is not a matrix; expected matrix (rank 2), got rank 3 array with shape [1, 4, 107]

A: We have an end to end csv classifier example here: https://github.com/deeplearning4j/dl4j-examples/blob/master/dl4j-examples/src/main/java/org/deeplearning4j/examples/recurrent/seqClassification/UCISequenceClassificationExample.java
 An rnn can handle multi variate input. In fact I encourage it. Having only 1 input feature doesn't do much for you.
I don't see the need to reduce it down to x1 and y.


text:
Q: PostgreSQL slow WHERE clause in sparse join I am currently working on a project which will use a PostgreSQL database of (eventually) about 200 million rows in which two of the tables have an interesting relationship. Table A contains items with, among others, fields A.a, A.b and A.c while table B contains B.a, B.b, B.c and a value B.v for each of these. The objective here is to be able to join the tables A and B such that I can obtain the value B.v for each entry in A. I currently have B setup with B.a, B.b and B.c as a multi-column index with a unique property. This is the best way I could think of to represent this relationship (keeping in mind that table A might contain millions of rows while B will contain only 10,000). If there is a better way to store this, I would love to know.
To complicate matters, I also require some information from a third table C, which I also join into both A and B.
To illustrate the table structures:
                        Table "A"
    Column    |   Type   | Modifiers | Storage | Stats target | Description
--------------+----------+-----------+---------+--------------+-------------
 id           | bigint   |           | plain   |              |
 a            | boolean  | not null  | plain   |              |
 b            | integer  |           | plain   |              |
 c            | smallint |           | plain   |              |
 user_id      | bigint   |           | plain   |              |
Indexes:
    PRIMARY KEY, btree (id)
    UNIQUE CONSTRAINT, btree (id)
    btree (user_id)
    btree (a)
    btree (b)
    btree (c)

                                                Table "B"
    Column    |   Type   |                         Modifiers                          | Storage | Stats target | Description
--------------+----------+------------------------------------------------------------+---------+--------------+-------------
 id           | integer  | not null default nextval('A_id_seq'::regclass)             | plain   |              |
 a            | boolean  | not null                                                   | plain   |              |
 b            | integer  | not null                                                   | plain   |              |
 c            | smallint | not null                                                   | plain   |              |
 v            | bigint   | not null                                                   | plain   |              |
Indexes:
    PRIMARY KEY, btree (id)
    UNIQUE CONSTRAINT, btree (a, b, c)
    btree (c)
    btree (b)
    btree (b, c, a)
    btree (v)
Foreign-key constraints:
    ...

                                Table "C"
    Column    |           Type           | Modifiers | Storage  | Stats target | Description
--------------+--------------------------+-----------+----------+--------------+-------------
 user_id      | bigint                   | not null  | plain    |              |
 p            | integer                  |           | plain    |              |
Indexes:
    PRIMARY KEY, btree (user_id)
    UNIQUE CONSTRAINT, btree (user_id)
    btree (p)

The objective is then to find all rows in table A where the corresponding value in B is greater than 1000 and the value in C is greater than 100. Currently, my query for this is as follows:
SELECT * FROM A
    INNER JOIN B ON
        A.a = B.a AND
        A.b = B.b AND
        A.c = B.c
    LEFT JOIN C ON
        A.user_id = C.user_id
    WHERE C.p < 100 AND B.v > 1000
    LIMIT 100;

This is, however, very slow, taking several seconds to finish. Peculiarly, removing the B.v > 1000 contraint speeds up the query from about 6 seconds to only 20 milliseconds. I suspect that this is because entries with a B.v value over 1000 are very rare (about 20,000 in millions). I then used the EXPLAIN ANALYSE clause on the query to produce the following:
 Limit  (cost=0.00..1133.08 rows=100 width=215) (actual time=18.516..6571.243 rows=100 loops=1)
   ->  Nested Loop  (cost=0.00..1940860.96 rows=171291 width=215) (actual time=18.513..6571.113 rows=100 loops=1)
         ->  Nested Loop  (cost=0.00..1232018.65 rows=1171013 width=64) (actual time=9.293..6326.114 rows=3303 loops=1)
               ->  Seq Scan on A (cost=0.00..81726.86 rows=3888586 width=36) (actual time=0.018..857.948 rows=452207 loops=1)
               ->  Index Scan using [...] on B  (cost=0.00..0.28 rows=1 width=28) (actual time=0.010..0.010 rows=0 loops=452207)
                     Index Cond: (a = a AND b = b AND c = c)
                     Filter: (v > 1000)
         ->  Index Scan using user_id_pk on C  (cost=0.00..0.59 rows=1 width=151) (actual time=0.072..0.072 rows=0 loops=3303)
               Index Cond: (user_id = A.user_id)
               Filter: (p < 80)
 Total runtime: 6571.550 ms

It seems odd to me that it would take so much longer to add a single constraint to a query just because the number of matches to that constraint is small (as a sidenote, reducing it from 1000 to 10, which yields many more results, also provides a huge speedup).
So, my question is this: can the database server not use the index I applied to B.v in this query? Also, is it possible to speed up this query in any way?
Thank you for reading and please excuse me if I have made a very obvious mistake, but I haven't been able to find any solution to my problem so far.
Edit:
Execution plan without the B.v > 1000 clause:
 Limit  (cost=0.00..13278.28 rows=100 width=215) (actual time=76.185..237.820 rows=100 loops=1)
   ->  Nested Loop  (cost=0.00..1383862.57 rows=10422 width=215) (actual time=76.183..237.739 rows=100 loops=1)
         ->  Nested Loop  (cost=0.00..1322702.97 rows=71251 width=64) (actual time=18.270..121.272 rows=840 loops=1)
               ->  Seq Scan on A  (cost=0.00..85715.82 rows=4078382 width=36) (actual time=0.037..2.520 rows=1377 loops=1)
               ->  Index Scan using [...] on B  (cost=0.00..0.28 rows=1 width=28) (actual time=0.082..0.083 rows=1 loops=1377)
                     Index Cond: (a = a AND b = b AND c = c)
         ->  Index Scan using user_id_pk on C (cost=0.00..0.85 rows=1 width=151) (actual time=0.136..0.136 rows=0 loops=840)
               Index Cond: (user_id = A.user_id)
               Filter: (C.p < 80)
 Total runtime: 238.076 ms

A: If the predicate on B.v is very selective, then place an index on that column.
I suspect that the reason for the slowness with that predicate in place is that the query cannot be performed based only on accessing the unique index on B -- instead every row in the table needs to be accessed to check the value of v as well.


text:
Q: How to use attribute autocomplete in chips in PrimeFaces I have a chips tag in primefaces and it has attribute autocomplete but I dont know how to use it as suggestion.
See my code below
<p:chips id="chips" value="#{partner.listString}" autocomplete="how to use auto complete here">
    <p:ajax event="itemSelect" update="itemList"/>
    <p:ajax event="itemUnselect" update="itemList"/>
</p:chips>

This is my expectation. But I dont know how to do it?

[link showcase]https://www.primefaces.org/showcase/ui/input/chips.xhtml

A: You may be looking for the autocomplete component with multiple=true: https://www.primefaces.org/showcase/ui/input/autoComplete.xhtml

A: If you are using JSF 2.2 you can use JSF Passthrough attributes.
First declare the namespace pt at the top of your XHTML document.
xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"

Then in your chips add pt: to the attribute.
<p:chips id="chips" pt:autocomplete="how to use auto complete here">

A: The autocomplete attribute you are referring to is a property of javax.faces.component.html.HtmlInputText. From Mozilla Developer documentation:

The source of the suggested values is generally up to the browser; typically values come from past values entered by the user, but they may also come from pre-configured values. For instance, a browser might let the user save their name, address, phone number, and email addresses for autocomplete purposes. Perhaps the browser offers the ability to save encrypted credit card information, for autocompletion following an authentication procedure.

But I don't think it is actually used in Chips component, but @melloware gave you the workaround using passthrough attributes.
Basically, Chips is a free words picker where you get all your words typed represented as a list (after conversion/validation). While, Autocomplete component is based on a preset list defined by the developer. Depending on what you want to do, @melloware and @tandraschko gave you the proper answers ;)


text:
Q: ElasticSearch multiple languages I am currently trying to figure out analysis schemes for my ElasticSearch cluster. I am using ES to index pdf, word, powerpoint and excel documents. I am using Apache Tika to extract the text.
My problem is that I do not know before hand what languages to expect the file contents to be. They could be written in any language.
My question is, is there a way to make ES analyze text regardless of the language? Or should I have a pre-defined field for each language with its own tokenizer, analyzer and stopwords?

A: I suggest taking a look at the ElasticSearch plugin elasticsearch-mapper-attachments. I used it to build document search functionality.
When it comes to supporting multiple languages, we have had the best experience with one index per language. If you can identify the language before indexing you can insert the document into the appropriate index. This makes it easier to add new languages vs. a field per language approach.
One thing to remember is the Don't use Types for Languages note at the bottom of one language per document page. Doing that can mess up search in a very difficult to debug way.
If you need to detect the language, there are two options mentioned at the bottom of the Pitfalls of Mixing Languages page.


text:
Q: Deploy Web application over Azure using VSTS (Visual studio Team Service) I want to fully automate the deployment of a web application using VSTS. I have a sample azure application and I want to create a build definition on it that contains building the solution, running unit tests, and deploying it over azure on IIS as its build steps. I am new to VSTS, I am finding it hard to automate the deployment using VSTS. Seeking some help on how to create the above build definition. Any slightest guidance will be helpful.

A: Madhur,
You will find step by step up to date examples on the Visual Studio website:

*

*Build and deploy your ASP.NET 4 code to an Azure web app

*Deploy ASP.NET apps to Azure web apps
First create a build definition to test and package you web app.
Second get familiar with release definition to deploy it on Azure. Or if you just want to do it in one place you can have everything in your build definition, it's up to you.
Also when creating a build or release definition on VSTS, the templates offered are very useful, everything is done so you juste have to feel the gaps. I advise you to take a look at it.

A: Ive written up a walkthrough of this process at my blog site, its for an asp.net core app but the principal is the same for a normal .net framework one, in fact its even easier because you just choose the Visual Studio Build template when creating the build definition.  My walkthrough also takes you through how to deploy the Azure resources you need to host the website - its good practise to use infrastructure as code for these, and maintain that code in the same way you treat source code, with CI and CD processes.