text:
Q: Java int[][] array object I have defined an int[][] object. Because it is an object, if i send it to a method as a parameter, it will only send it's reference, so any changes to the array in the method, will influence it in the main program. So i would like to make a clone of this object inside the method, but i'm not sure how to accomplish this.
I was thinking of something like so:
private void myMethod( int[][] array )
{
    //Define our temporary array (clone)
    int[][] newArray = new int[3][3];

    //Go through the elements of the array
    for .... row = 0; row < ..; row++
        for ..... col = 0; col < ..; col++
           //Copy individual elements from one array to another
           newArray[row][col] = array[row][col];
}

but will the above code copy each element from array into newArray as value (so... a clone of the item), or just the reference?
If so, how can this be accomplished. If i were to use ArrayLists instead of int[][] objects, there is the clone() method or something like that, but i haven't got that method for int[][] objects :(
Also, if i'm not mistaken if i do this inside the method newArray = array , that will copy just the reference again, so both will point to the same int[][] object :(
P.S. I know i could just test this, but i'd like to discuss it with you guys a bit, and see what's what exactly.

A:
but will the above code copy each element from array into newArray as value (so... a clone of the item), or just the reference?

You're copying each element of the array, and each element is an int, so you're fine. The new array will be completely independent of the original.
Note that if instead you'd done:
int[][] newArray = new int[3][];
for (int i = 0; i < 3; i++) {
    newArray[i] = array[i];
}

... then that would just have copied references to the three existing int[] arrays into newArray. But you've allocated a completely new set of arrays (one int[][] and 3x int[]) so it's all independent.

A: Primitive types, such as int, are not reference types. Thus, going through all the items and copying them one by one will make a copy-by-value.
In short, your code is correct.

A: int is a primitive type, you always pass them around as value, not as reference, so you code will indeed create a new copy of the array.
You might want to consider using Arrays.copyOf(), it may be faster.

A: You could use clone() on the matrix and on each array corresponding to a row in the matrix, it will work without problems because you're cloning a matrix of primitive values, like this:
int[][] matrix = new int[3][3];
// ... matrix gets filled ...
int[][] copy = matrix.clone();
for (int i = 0; i < matrix.length; i++)
    copy[i] = matrix[i].clone();

The above will create a copy matrix which is independent of matrix, meaning that you can change the values of the copy without affecting the original.


text:
Q: Is there a tool for sending a daily digest from a set of SVN repositories? My team has a range of projects spanning several SVN repositories.  Along with the daily updates from meetings and emails, I would like a daily digest email that summarises the commits from the set of repositories that we're using.  I've seen similar things within project management tools like Unfuddle, but wondered if there was a simple utility out there that did just this.

A: Not sure if there is a widget out there that does this or not.  But I would think that if you stood up (or perhaps already have) a continuous integration environment (I use CruiseControl and NAnt) then you could aggregate all of the reports generated in a day across all of your repositories from a single CruiseControl project and build file that runs at the end of the day.  This project would be reponsible for picking up the various reports/logs from the other build and including them into a build email...  Sounds like that would work.
Perhaps there is something more elegant out there!  I can't wait to see the other responses.

A: (On windows) you could install CommitMonitor. You can configure any number of SVN repositories to be watched/monitored at configurable intervals. The tool shows you all new commits and allows you to check each commit in details.

A: I suggest to take a look at http://devpulse.com/ (disclaimer: I am part of the team behind it). At the moment it doesn't exactly have a daily digest, but it let's you have RSS/Twitter stream of all events/changes in your repositories (and other tools).

A: Trac
"It provides an interface to  Subversion (or other version control systems), an integrated Wiki and convenient reporting facilities."

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to add a second level column header/index to dataframe by matching to dictionary values? I have an existing dataframe.
l1 | a    b    c  |  d    e    f
--------------------------------
0  | 1    1    1  |  1    1    1
1  | 1    1    1  |  1    1    1
2  | 1    1    1  |  1    1    1

And this dictionary.
{
  "a": "dog",
  "b": "dog",
  "c": "dog",
  "d": "fish",
  "e": "fish",
  "f": "fish",
}

What is the simplest way to create a second column level matching the existing columns to their category from the dictionary?
The real columns and dictionary are much bigger and less organized.
The result should look like this.
l2 |     dog      |     fish
l1 | a    b    c  |  d    e    f
--------------------------------
0  | 1    1    1  |  1    1    1
1  | 1    1    1  |  1    1    1
2  | 1    1    1  |  1    1    1

A: Add an extra mapping for the first series, then use pd.MultiIndex.from_tuples:
d.update({'l1': 'l2'})
df.columns = pd.MultiIndex.from_tuples([(d[k], k) for k in df.columns])

print(df)

  l2 dog       fish
  l1   a  b  c    d  e  f
0  0   1  1  1    1  1  1
1  1   1  1  1    1  1  1
2  2   1  1  1    1  1  1

A: Different method from groupby and concat since you already have the mapper
d['l1']='l2'

pd.concat(dict(tuple(df.groupby(d,axis=1))),1)#From jpp more succinct
  dog       fish       l2
    a  b  c    d  e  f l1
0   1  1  1    1  1  1  0
1   1  1  1    1  1  1  1
2   1  1  1    1  1  1  2

d={
  "a": "dog",
  "b": "dog",
  "c": "dog",
  "d": "fish",
  "e": "fish",
  "f": "fish",
}


text:
Q: extending c# syntax with roslyn I'm trying to implement a "return if"/"return value if" without an else case, since I only want to return or return a value if a condition is valid.
I know, there is the if (condition) return; or if (condition) return value; but I want to have the code a bit cleaner AND it would be nice to have that syntax since it is more readable.
I heard with roslyn this is possible and read the question with its answeres here: Is there a way to implement custom language features in C#? but I have no clue how to implement it.
So the code would be something like this:
public class Testclass
{
    public static void Main(String[] args)
    {
        Testclass t = new Testclass();
        t.TestMyClassWithVoid();
        bool success = t.TestMyClassWithInt(3) == 3;
        bool fail = t.TestMyClassWithInt(2) == 2;
    }

    public void TestMyClassWithVoid()
    {
        int value = GetValueFromSomeWhere();
        return if value == 3;

        DoSomeOtherStuffSinceValueIsNotThree();
    }

    public int TestMyClassWithInt(int value)
    {
        return value if value == 3;

        DoSomeOtherStuffSinceValueIsNotThree();
        return -1;
    }
}

any idea how I could solve this? I started trying with the Roslyn.Compilers.CSharp-namespace but I have no clue how to start implementing.

A: If you can generate the correct IL for this, this should be work.
Because this is not a new CLR capability you don't need do anything with dot net core, just Roslyn.
To do that you have two options,
One is to leave Roslyn as is and rewrite your new syntax to the correspond C# syntax and then compile as regular.
Second option, because Roslyn is an open source, is to add the ability to compile you new syntax to your own Roslyn and compile your code with it.

A: Here is an alternative suggestion that may work for someone who is looking for extension points into roslyn. It can even be provided as a nuget package! Create an analyser and a code fix provider for your syntax.
Essentially what you would get is a red squiggly line under any syntax of your choosing, with a auto-fix hint which would let you transform it into the regular C# equivalent.
It could also be used for validating the usage of your library, checking that the right attributes are in the right locations, detect common code smells, etc.
Read up more on code analysers at this post: https://msdn.microsoft.com/en-us/magazine/dn879356.aspx
A quick summary of that link (but by no means a replacement):

*

*Install VS SDK, Roslyn SDK, Compiler Platform SDK

*Create new project: Analyzer with Code Fix (NuGet + VSIX) template.

*There will be 3 samples on how to create an analyser / code fix provider

*Set the VSIX project as the startup project and run


text:
Q: n objects in circle with fixed placement; number of permutations made only of transpositions The problem is given as follows:
There are n people sitting in n seats, with n $\geq$ 3
Any person can either stay in the same seat, or move to an adjacent seat.
How many ways can this be done?
A diagram is given with the problem and it is clear that the seats are considered fixed and rotations which end up in different seats are not considered equivalent.

Clearly the identity permutation is one.
There are two rotations of one place, one clockwise and one counterclockwise.
These three permutations exist for every n.
All other permutations fulfilling the conditions must consist solely of collections of 2-cycles or transpositions.
For n = 3 there are three possible transpositions, so the total number of permissible permutations for n = 3 is 6
For n = 4 we can have four possible transpositions, (AB)(BC)(CD) and (DA)
If one of these transpositions is chosen and the other two elements are left unmoved, we have four choices so there are four possible permutations.
If two transpositions are used, the first necessarily restricts the choice of the second so there are two possible permutations.
Thus there are 4 + 2 + 3 = 9 permissible permutations for n = 4
For n = 5 we can have one transposition, or two transpositions and a singleton left.
There are five choices of single transpositions. If we use two transpositions there are five choices of singleton left over.
There is a total of 5 + 5 + 3 = 13 permissible permutations for n = 5
I tried various combinatorics methods. A try at stars and bars, but placement of the bars is problematic; transpositions cannot overlap. For k transpositions, n - k objects of which k are pairs and n - 2k are singletons. Placement is problematic again because the pairs take two seats.
I was wondering if there might be a Fibonacci pattern as the number of permissible permutations grows rapidly.
It occurred to me that perhaps odd and even n could be studied separately, doing induction on adding 2 each step.
I've been puzzling over this for a few days and have a few ideas but nothing has jelled yet

A: For such arrangements $f(n)$ of $n$ people in a straight line the $n^{\text{th}}$ person may either take seat $n$ in $f(n-1)$ ways or swap with person $n-1$ in $f(n-2)$ ways so
$$f(n) = f(n-1)+f(n-2)\tag{1}$$
with $f(1)=1$ and $f(2)=2$.
In a circle there are $g(n)$ seatings. Person $n$ may take their own seat in $f(n-1)$ ways, swap with person $n-1$ in $f(n-2)$ ways, swap with person 1 in $f(n-2)$ ways or is part of a clockwise or anticlockwise rotation of all people by 1 seat. So, for $n\ge 3$ we have
$$g(n)=f(n-1)+2f(n-2)+2$$
$$\implies g(n)=f(n)+f(n-2)+2\tag{2}$$
since $f(n)$ is the sequence
$$1,2,3,5,8,13,21,34,\ldots$$
$g(n)$ is for $n\ge 3$ (using $g(1)=1$ and $g(2)=2$)
$$1,2,6,9,13,20,31,49,\ldots$$
Extra:
By rearranging $(2)$ for $f(n)$ and substituting into $(1)$ we have a recurrence for $g(n)$ only
$$g(n)-f(n-2)-2=(g(n-1)-f(n-3)-2)+(g(n-2)-f(n-4)-2)$$
$$\implies g(n)=g(n-1)+g(n-2)-2\tag{3}$$
which is true for $n\ge 5$ and $g(1)=1,\, g(2)=2,\, g(3)=6,\, g(4)=9$.


text:
Q: Call Screen Lock Activity from a background service in android I am running a timer using service. i has to call new activity from the service which holds the code of locking screen . I am using intent to start that activity from the service. then i am getting an error
   java.lang.RuntimeException: Unable to instantiate activity ComponentInfo

I already registered the screenlock activity in manifest file.
My Service .java
 public class BgTimerService extends Service
 {

  static long second;
  static long min;
  Intent I;
  Bundle b;
  @Override
  public void onCreate()
  {
    super.onCreate();
    showTime();
  }
  public void showTime()
  {
    CountDownTimer countdowntimer;
    long time;

    time = (1 * 10 * 1000);
    countdowntimer = new CountDownTimer(time, 1000)
    {

        @Override
        public void onTick(long millisUntilFinished)
        {
            // TODO Auto-generated method stub

            BgTimerService.second = millisUntilFinished / 1000;
            BgTimerService.min = 0;
            while (BgTimerService.second >60)
            {
                if (BgTimerService.second > 60)
                {
                    BgTimerService.second = BgTimerService.second - 60;
                    BgTimerService.min++;

                }
            }
        }

        @Override
        public void onFinish()
        {
            // TODO Auto-generated method stub
            Toast.makeText(getApplicationContext(), "Hello World",
                    Toast.LENGTH_SHORT).show();
            stopSelf();
            Intent in=new Intent(BgTimerService.this,LockScreenActivity.class);
            in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(in);
        }
    }.start();
}

@Override
public IBinder onBind(Intent arg0)
{
    // TODO Auto-generated method stub
    return null;
}

LockscreenActivity.java
 public class LockScreenActivity extends DeviceAdminReceiver
 {

  public void onEnabled(Context context, Intent intent)
  {
    showToast(context, "Sample Device Admin: enabled");
  }

@Override
 public CharSequence onDisableRequested(Context context, Intent intent)
 {
    return "This is an optional message to warn the user about disabling.";
     }

@Override
public void onDisabled(Context context, Intent intent)
{
    showToast(context, "Sample Device Admin: disabled");
}

void showToast(Context context, CharSequence msg)
{
    Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();

}

public static class Myclass extends Activity
{

    protected PowerManager.WakeLock mWakeLock;
    DevicePolicyManager mDPM;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        // setContentView(R.layout.main);

        mDPM = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
        // mDPM.lockNow();

        ComponentName mAdminName = new ComponentName(Myclass.this,
                LockScreenActivity.class);

        if (!mDPM.isAdminActive(mAdminName))
        {
            Intent intent = new Intent(
                    DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
            intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN,
                    mAdminName);
            intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
                    "is locked");
            intent.putExtra("force-locked",
                    DeviceAdminInfo.USES_POLICY_FORCE_LOCK);

            startActivityForResult(intent, 1);
            System.out
                    .println("The Device Could not lock because device admin not enabled");
            // mDPM.lockNow();
        } else
        {
            System.out.println("The Device  device admin enabled");
            Intent intent = new Intent(
                    DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
            intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN,
                    mAdminName);
            intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
                    "onEnabled");
            mDPM.lockNow();
            mDPM.setMaximumTimeToLock(mAdminName, 0);
            intent.putExtra("force-locked",
                    DeviceAdminInfo.USES_POLICY_FORCE_LOCK);

            startActivityForResult(intent, 1);

        }

    }
}

}

my manifest.xml is
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp.screenlock"
android:versionCode="1"
android:versionName="1.0" >
 <uses-sdk
    android:minSdkVersion="8" />
<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".BgTimerActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <service android:name=".BgTimerService" />

    <activity android:name=".LockScreenActivity" >
    </activity>
    <activity
        android:name=".LockScreenActivity$Myclass"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
        </intent-filter>
    </activity>
    <receiver
        android:name=".LockScreenActivity"
        android:label="device_admin"
        android:permission="android.permission.BIND_DEVICE_ADMIN" >
        <meta-data
            android:name="android.app.device_admin"
            android:resource="@xml/my_admin" />
        <intent-filter>
            <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
        </intent-filter>
    </receiver>
</application>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />

could anyone figure it out where i went wrong?


text:
Q: (Android)How to get data from JSON to show on listview This is my JSON data
{
    "success": "1",
    "results": [
        {
            "type": "1.popmusic",
            "posts": [
                {
                    "music": "1.AAA"
                },
                {
                    "music": "2.BBB"
                }
            ]
        }
    ]
}

I need to click some kind of music such as I click "popmusic" on my listview and then,Intent to new activity to show music in popmusic ,From my json It have to show "1.AAA" and "2.BBB" on listview.
I can't get "posts" from my json.How can I get it.
This is Blog1 Class
public class Blog1 {
    String success;
    List<Post> results;
    public List<Post> getResults() {
        return results;
    }

}

This is Post1 class
public class Post1 {
String name;
public String getName() {
    return name;
}

public String getAuthor() {
    return author;
}

// Getter and Setter

This is main class
  private void showData(String jsonString) {
        Gson gson = new Gson();
        Blog1 blog = gson.fromJson(jsonString, Blog1.class);
        List<Post> results = blog.getResults();

        mAdapter = new CustomAdapter1(this, results);
        mListView.setAdapter(mAdapter);

}

A: You can use the in build android JSON library
Refer How to get json array values in android?
Refer android get json array nested in array
First you need to get results
JSONArray json2 = json.getJSONArray("results");

Then loop inside ( I am assuming 0 for first element )
JSONObject json3 = json2.getJSONObject(0);

Then you need to get posts
JSONArray json4 = json3.getJSONArray("posts");

Then gain you can loop inside json4
--- EDIT ---
I see that you are using Gson but your class structure should be
public class Blog {
    String success;
    List<Result> results;
    public List<Result> getResults() {
        return results;
    }
}

public class Result {
   String type;
   public String getType() {
       return type;
   }
   List<Post> posts;
   public List<Post> getPosts() {
        return posts;
   }
}

public class Post {
   String music;
   public String getMusic() {
       return music;
   }
}

In your main code
Blog blog = gson.fromJson(jsonString, Blog.class);
//I am assuming 0th item for both
blog.getResults().get(0).getPosts().get(0).getMusic();

If you are constructing a custom adapter then, assuming that you are going to show all posts for one blog entry then you can get all posts as
List<Post> posts = blog.getResults().get(0).getPosts()

And pass the posts to your custom adapter.
If you have two adapters then blog.getResults() for first adapter then clicking on an item of that adapter results.get(itemindex).getPosts() for the second adapter

A: Your JSON
{
    "success": "1",
    "results": [
        {
            "type": "1.popmusic",
            "posts": [
                {
                    "music": "1.AAA"
                },
                {
                    "music": "2.BBB"
                }
            ]
        }
    ]
}

Is actually mapped to
public class Response {
    private String success;
    private List<Result> results;

    //getter, setter
}

public class Result {
    private String type;
    private List<Post> posts;

    //getter, setter
}

public class Post {
    private String music;

    //getter, setter
}

Then you can make GSON get a Result out of it.


text:
Q: How to get payment method for the products which is placed under buy 1 get 1 50% I the customer placing order for the product which is placed under BUY 1 GET 1 50%.
But when i place order am getting struck at shipping method.
Can i know why it is happening like this and what changes should i do to get shipping method?
Can someone suggest me?


text:
Q: Exampels on a Server-Client-Chat applikation on JAVA I have been "googeling" around for a long time for examples over Server-client-chat application, but I can't really understand them. Many of them are using a class and creates the GUI from it, and I don't want to copy straight from it. Alot of examples doesn't either really explain how you send messages from a client to the server and then it sends the message out to all the other clients.
I am using NetBeans and I was wondering if there is some good tutourials or examples that can help me with this?

A: Here is a super simple I made just now with some comments of what is going on. The client connects to the server can can type messages which the server will print out. This is not a chat program since the server receives messages, and the client send them. But hopefully you will understand better it better :)
Server:
    import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class Main {

    public static DataInputStream in;
    public static DataOutputStream out;

    public static void main(String[] args) throws IOException {

    int port = 4444;
    ServerSocket server = null;
    Socket clientSocket = null;

    try {

    //start listening on port
    server = new ServerSocket(port);

    System.out.println("Listening on port: " + port);

    //Accept client
    clientSocket = server.accept();

    System.out.println("client Connected!");

    //initialize streams so we can send message
    in = new DataInputStream(clientSocket.getInputStream());
    out = new DataOutputStream(clientSocket.getOutputStream());

    String message = null;

        while (true) {
            // as soon as a message is being received, print it out!
            message = in.readUTF();
            System.out.println(message);
        }

    }
    catch (IOException e){
        e.printStackTrace();
        if (!server.isClosed()){server.close();}
        if (!clientSocket.isClosed()){clientSocket.close();}
    }

    }

}

Client:
    import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.util.Scanner;

public class Main
{
   public static void main(String[] args) throws IOException {

       //declare a scanner so we can write a message
       Scanner keyboard = new Scanner(System.in);

       // localhost ip
       String ip = "127.0.0.1";
       int port = 4444;
       Socket socket = null;

       try {

       //connect
       socket = new Socket(ip, port);

       //initialize streams
       DataInputStream in = new DataInputStream(socket.getInputStream());
       DataOutputStream out = new DataOutputStream(socket.getOutputStream());

       while (true){
           System.out.print("\nMessage to server: ");
           //Write a message :)
           String message = keyboard.nextLine();
           //Send it to the server which will just print it out
           out.writeUTF(message);
       }

       }
       catch (IOException e){
           e.printStackTrace();
            if (!socket.isClosed()){socket.close();}
       }
   }
}

A: Here comes the multiThreading program :) the server has two classes, and client has one. Hope you Like it!
SERVER MAIN CLASS:
    import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class Main {

    public static void main(String[] args) throws IOException {
        int MAXCLIENTS = 20;
        int port = 4444;
        ServerSocket server = null;
        Socket clientSocket = null;
        // An array of clientsConnected instances
        ClientThread[] clientsConnected = new ClientThread[MAXCLIENTS];

        try {
            server = new ServerSocket(port);
            System.out.println("listening on port: " + port);
        } catch (IOException e) {// TODO Auto-generated catch block
            e.printStackTrace();

        }

        while (true) {
            try {
                clientSocket = server.accept();

            } catch (IOException e) {
                e.printStackTrace();
                if (!server.isClosed()){server.close();}
                if (!clientSocket.isClosed()){clientSocket.close();}
            }

            System.out.println("Client connected!");

            for (int c = 0; c < clientsConnected.length; c++){
                if (clientsConnected[c] == null){
                    // if it is empty ( null) then start a new Thread, and pass the socket and the object of itself as parameter
                    (clientsConnected[c] = new ClientThread(clientSocket, clientsConnected)).start();
                    break; // have to break, else it will start 20 threads when the first client connects :P
                }
            }
        }

    }

}

SERVER CLIENT CLASS:
    import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;

public class ClientThread extends Thread{

    private ClientThread[] clientsConnected;
    private Socket socket = null;
    private DataInputStream in = null;
    private DataOutputStream out = null;
    private String clientName = null;

    //Constructor
     public ClientThread(Socket socket, ClientThread[] clientsConnected){
        this.socket = socket;
        this.clientsConnected = clientsConnected;
    }

    public void run(){
        try {
            // Streams :)
            in = new DataInputStream(socket.getInputStream());
            out = new DataOutputStream(socket.getOutputStream());

            String message = null;

            clientName = in.readUTF();

            while (true){
                message = in.readUTF();

                for (int c = 0; c < clientsConnected.length; c++){
                    if (clientsConnected[c]!= null && clientsConnected[c].clientName != this.clientName){ //dont send message to your self ;)
                        clientsConnected[c].sendMessage(message, clientName); // loops through all the list and calls the objects sendMessage method.
                    }
                }

            }

        } catch (IOException e) {
            System.out.println("Client disconnected!");
            this.clientsConnected = null;
        }
    }
    // Every instance of this class ( the client ) will have this method.
    private void sendMessage(String mess, String name){
        try {
            out.writeUTF(name + " says: " + mess);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}

AND FINALLY THE CLIENT:
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.util.Scanner;

public class Main
{
   public static void main(String[] args) throws IOException {

       Main m = new Main();
       m.connect();
   }

   public void connect() throws IOException{
     //declare a scanner so we can write a message
       Scanner keyboard = new Scanner(System.in);

       // localhost ip
       String ip = "127.0.0.1";
       int port = 4444;
       Socket socket = null;

       System.out.print("Enter your name: ");
       String name = keyboard.nextLine();

       try {

       //connect
       socket = new Socket(ip, port);

       //initialize streams
       DataInputStream in = new DataInputStream(socket.getInputStream());
       DataOutputStream out = new DataOutputStream(socket.getOutputStream());

       //start a thread which will start listening for messages
       new ReceiveMessage(in).start();

       // send the name to the server!
       out.writeUTF(name);

       while (true){
           //Write messages :)
           String message = keyboard.nextLine();
           out.writeUTF(message);
       }

       }
       catch (IOException e){
           e.printStackTrace();
            if (!socket.isClosed()){socket.close();}
       }
   }

   class ReceiveMessage extends Thread{

       DataInputStream in;

       ReceiveMessage(DataInputStream in){
           this.in = in;
       }

       public void run(){
           String message;
           while (true){
               try {
                    message = in.readUTF();
                    System.out.println(message);

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

           }
       }

   }

}

I ran the server in eclipse, and started two clients from the CMD, looks like this:


text:
Q: Page Breaks In Excel VB.Net I'm working with the Office Interop and having trouble inserting page breaks in Excel. My code is working fine with the horizontal page break but I also need to set the vertical pagebreak.
Can somone modify my code below, to make a vertical page break on column I?
This code is making the correct horizontal pagebreaks but is still 150 pages long because the vertical pagebreak is not set correctly.
Dim r As Excel.Range = CType(xlWorkSheet.Cells(27, 1), Excel.Range)

r.PageBreak = 1

A: This
sheet.VPageBreaks.Add(sheet.Range["J1"]);

worked for me to set a vertical page break. As shown in the picture, it seems to put the page break before the specified column:

A: Try setting the vertical pagebreak for the right Column object itself, rather than the cells range.

A: If you want page like A1:D15
for that
excelWorksheet.Range(E16).PageBreak = 1

It will create both vertical and horizontal page break.
This is just example. Code accordingly.


text:
Q: Vertical scrolling with snap/align to div/element/anchor I found some lovely websites - http://www.mini.jp/event_campaign/big-point/, http://www.twenty8twelve.com/ and http://www.scozzese.com - all vertical scrolling, and all using a technique that aligns the 'pages' to the top of the browser when you scroll onto a new 'page' - even if you scroll half way into one.
Could anyone give me any pointers e.g. the right terminology/words I could use to search for more info, or a brief intro on the basics behind this technique, or if any jQuery etc plugins exist I can play and learn with?
I did a search of their code but nothing jumped out as how to do it, my Javascript and jQuery are still novice level.

A: Javascript Has some native methods like scroll(), scrollTo(), scrollBy() which (with some tricks) you can use to smoothly scroll the page. Together with offsetTop(), offsetLeft() you can achieve effects like on these sites.
There are also a lot of jQuery Plugins out there (e.g. like this google hit) to save you a lot of work with this.
Just search for these Methodnames, this should give you enough hits I guess.

A: Basic scrolling...
// Scroll
h = $(window).height();
t = $("mydiv").offset().top + $("mydiv").height();

if(t > h) {
    $(window).scrollTop(t - h);
}

A: Their scrolling script isn't very smart. If I scroll the webpage down by repeatedly clicking on the down arrow, every time I click, it scrolls back up. So inevitably it doesn't work.


text:
Q: How to list and unlist Azure artifacts Package version based on testing using PowerShell script I have setup a pipeline in azureDevops to publish new version of artefact, test this version and if it passes success criteria then list it otherwise unlist it. Kindly let me know how to list and unlist based on success criteria.

A: Sorted this by setting a variable and based on results unlist a package by using below command using Nuget Custom task
delete $(Package)-Source $(SourcePath) -ApiKey $(APIKey)


text:
Q: What is the cache strategy of TDengine? What is the cache strategy of TDengine? LRU,LFU or others?
How can I config it?
I found some configurations in taos.cfg:
cache
blocks
cacheLast

A: I think TDengine use LRU as the default cache update policy. Not sure if other strategies are also implemented so not sure if its configurable.


text:
Q: OpenMP error message I got the following output with error message while executing the program that uses openmp in VS2008 C++

thread number: 0
thread number: 1
Fatal User Error 1002: 'for' loop executed with inconsistent parameters between
threads

My program does the following:
    omp_set_dynamic(0);
    omp_set_num_threads(2);

    int i = 0;
    int start_pos   = 0;
    int end_pos     = 0;

#pragma omp parallel default(none) private(i, start_pos, end_pos)
    {
        int nThreadNum = omp_get_thread_num();
        printf("thread number: %d\n", nThreadNum);
        start_pos   = 0;
        end_pos     = (number_of_model_points / 2 + 1);
        if (nThreadNum != 0) {
            start_pos   = (number_of_model_points / 2) + 1;
            end_pos     = (number_of_model_points);
        }

#pragma omp for
        for(i = start_pos; i < end_pos; i++) {
                      ...some code here...
        }
}

What is the problem here? Please correct me if I made a mistake.

A: So why there is an additional pragma for the for loop? You already did fork your processes.
If you really want to fork again (don't do that, please!) then "i" needs to be set private again. However I think you just would want to remove the "omp for" pragma.

A: Jonathan Dursi is right, so in summary, for loop bounding parameters can not be private. In your example, for(i = start_pos; i < end_pos; i++), start_pos and end_pos are private per omp thread, hence consistency is not guaranteed and you get error 1002. Otherwise you can definitely have #pragma omp for inside #pragma omp parallel.


text:
Q: Should one use singular or plural form when the number is equivalent to one or negative one? I understand that for a countable noun, one is supposed to use the singular form if and only if the number is equal to one or negative one; for example:

*

*one degree

*negative one degree

*0.75 degrees
Now my question is, what if the number is not expressed explicitly as one or negative one, but is essentially equal to one? For example, which of the following is correct:

*

*1.0 degree or 1.0 degrees?

*negative four over four degree or negative four over four degrees?

Edit: I just realised that for the difference between 1.0 degrees and 1.0 degree, it has been answered here. However, the question about negative four over four degree or negative four over four degrees remains unclear to me.


text:
Q: DIY USB-C Coupler with two receptacles I need to create a USB-C coupler that connects two USB-C cables, passes the data from one to another while splitting out the USB 2.0 signal from the incoming USB-C plug to an additional receptacle or plug. It is sort of Y-type splitter.
As a first step, I'm trying to recreate a $5 USB-C coupler I'm using successfully to couple a Thunderbolt 3 connection. My current attempt connects all 24 USB-C pins of both connectors, starting with A1 on the first plug to A1 on the second plug and so on. It does not work, in which order do the pins from both plugs need to be connected?

A: What you are trying to do is non-standard and will loose some Type-C features, namely: orientation detection, Power delivery and cable marking.
Look for Table 3-10 in USB Type-C spec. Notice how data pairs are wired, and try to undo this in your receptacle to receptacle fixture in order for a cable+fixture assembly to be looking like a passive extender.
You'll have one problem: cables do not propagate both CC pins. In a plug-to-plug cable, CC is A5 on both ends, B5 is Vconn or tied to ground through Ra and is not wired from one end to the other (see Figures 4-5 and 4-41).
Still, if you dont care about orientation detection and accept to try both possible orientations of your cables on the fixture, you may create such thing.
Note the breakout you have in the picture will most certainly degrade the signal enough for high speed pairs to be unusable, and USB3 be unavailable.


text:
Q: Misunderstanding sub function I'm working on a Shiny app that loops through an html file replacing an instance of a phrase with a different phrase relative to its position.
That is, the first time "aa" comes, I put "bluh",
the second time "aa" comes, I put "gfgf".
I have a table of all the 2nd phrases in order.
I think I'm misunderstanding the sub function documentation:

The two *sub functions differ only in that sub replaces only the first
  occurrence of a pattern whereas gsub replaces all occurrences.

But here a smallest reproducible example:
tt <- c("aa", "aa","bb","aa")

sub("aa","test",tt)
# [1] "test" "test" "bb"   "test"

gsub("aa","test",tt)
# [1] "test" "test" "bb"   "test"

tt
# [1] "aa" "aa" "bb" "aa"

I expected
sub("aa","test",tt)
# [1] "test" "aa" "bb"   "aa"

so that I could loop through and go:
og.list <- c("aa","cat","aa","cat","aa")

repl.list <- c("the","is","happy")

for(i in 1:3){
  og.list <- sub("aa",repl.list[i], og.list)
}

instead all "aa" become "the". I thought that's what gsub did, but instead it's both sub and gsub.
Thank you.

A: I think you might want just this:
og.list[og.list == "aa"] <- repl.list
#[1] "the"   "cat"   "is"    "cat"   "happy"

A:  Thank you Wiktor^.

I now understand that I would need to separate each item into its own string and then sub.
 og.list <- c("aa","cat","aa","cat","aa"
 repl.list <- c("the","is","happy")
 og.index <- grep("aa",og.list)

 for(i in 1:3){
 curr.index <- og.index[i]
 og.list[curr.index] <- sub("aa",
                             repl.list[i],
                             og.list[curr.index])
 }


text:
Q: Array manipulation Hey I am stuck in the middle of my code. I am getting some input data from my partner and I get an array. At the 0 index of the array there are 3 strings. The array looks like this
array
0 =>
   object(MunichInnovationGroup\PatentBundle\Entity\PatentIdJson)[1405]
   private 'patentId' => string 'EP.02708872.A' (length=13)
   private 'jsonData' => string '{"ops:world-patent-data": {
    "@xmlns":   {
    "ops": "http://ops.epo.org",
    "$": "http://www.epo.org/exchange",
    "ccd": "http://www.epo.org/ccd",
    "xlink": "http://www.w3.org/1999/xlink"
  },
  "ops:meta":   {
  "@name": "elapsed-time",
  "@value": "69"
  }
  private 'status' => string 'Found' (length=5)

What I am interested in is the 'jsonData' String. Can I covert this whole array to a multidimensional array or just get the 'jsonData' and convert it into an array so that I get the information what I need from the 'jsonData'.
Thanks

A: what you need is json_decode and you can do the following:
$jsonObject = json_decode($myArray[0]->getjsonData(), true);

That will generate an object from the jsonData your partner is providing in the array

A: Based on your comment, you can get to the data using:
$jsonData = $your_array[0]->getjsonData();

Assuming that the MunichInnovationGroup\PatentBundle\Entity\PatentIdJson extends the MunichInnovationGroup\PatentBundle\Entity class.


text:
Q: fullPage.js scrolling on top of select box element in IE and Firefox Basically I've encountered a problem with fullPage.js scrolling when a select tag is open.
This only happens in IE (all versions) and only Firefox in a mac.
I don't know if this is an issue or if I'm simply forgetting something.
What have I tried :

*

*Adding normalScrollElements to the select or form.

*Disabling fullPage scroll when the user is in the form or select
Both of them didn't work.
1st try:
Codepen: http://codepen.io/anon/pen/doGEgo
Snippet:
Doesn't work properly here

$(document).ready(function () {
    $('#fullpage').fullpage({
        anchors: ["contact-form","contact"],
        navigation: true,
        scrollOverflow: true,
        navigationPosition: 'right',
        navigationTooltips: ["Form","Meh"],
        responsive: 991,
        easingcss3: 'cubic-bezier(0.175, 0.885, 0.320, 1.275)',
        paddingTop: '110px',
        normalScrollElements: '#country'
    });
});

        Some section
        <form action="">
            <select name="country" id="country" class="form-control" style="margin-top:20px;" data-fv-field="country">
                <option selected="" disabled="">Country</option>
                <optgroup label="Frequent Visitors">
                    <option value="France">France</option>
                    <option value="Germany">Germany</option>
                    <option value="Italy">Italy</option>
                    <option value="Norway">Norway</option>
                    <option value="Spain">Spain</option>
                    <option value="United Kingdom">United Kingdom</option>
                    <option value="United States">United States</option>
                </optgroup>
                <optgroup label="All Countries">
                    <option value="Afghanistan">Afghanistan</option>
                    <option value="Albania">Albania</option>
                    <option value="Algeria">Algeria</option>
                    <option value="American Samoa">American Samoa</option>
                    <option value="Andorra">Andorra</option>
                    <option value="Angola">Angola</option>
                    <option value="Anguilla">Anguilla</option>
                    <option value="Antarctica">Antarctica</option>
                    <option value="Antigua and Barbuda">Antigua and Barbuda</option>
                    <option value="Argentina">Argentina</option>
                    <option value="Armenia">Armenia</option>
                    <option value="Aruba">Aruba</option>
                    <option value="Australia">Australia</option>
                    <option value="Austria">Austria</option>
                    <option value="Azerbaijan">Azerbaijan</option>
                    <option value="Bahamas">Bahamas</option>
                    <option value="Bahrain">Bahrain</option>
                    <option value="Bangladesh">Bangladesh</option>
                    <option value="Barbados">Barbados</option>
                    <option value="Belarus">Belarus</option>
                    <option value="Belgium">Belgium</option>
                    <option value="Belize">Belize</option>
                    <option value="Benin">Benin</option>
                    <option value="Bermuda">Bermuda</option>
                    <option value="Bhutan">Bhutan</option>
                    <option value="Bolivia">Bolivia</option>
                    <option value="Bosnia and Herzegovina">Bosnia and Herzegovina</option>
                    <option value="Botswana">Botswana</option>
                    <option value="Bouvet Island">Bouvet Island</option>
                    <option value="Brazil">Brazil</option>
                    <option value="British Indian Ocean Territory">British Indian Ocean Territory</option>
                    <option value="Brunei Darussalam">Brunei Darussalam</option>
                    <option value="Bulgaria">Bulgaria</option>
                    <option value="Burkina Faso">Burkina Faso</option>
                    <option value="Burundi">Burundi</option>
                    <option value="Cambodia">Cambodia</option>
                    <option value="Cameroon">Cameroon</option>
                    <option value="Canada">Canada</option>
                    <option value="Cape Verde">Cape Verde</option>
                    <option value="Cayman Islands">Cayman Islands</option>
                    <option value="Central African Republic">Central African Republic</option>
                    <option value="Chad">Chad</option>
                    <option value="Chile">Chile</option>
                    <option value="China">China</option>
                    <option value="Christmas Island">Christmas Island</option>
                    <option value="Cocos (Keeling) Islands">Cocos (Keeling) Islands</option>
                    <option value="Colombia">Colombia</option>
                    <option value="Comoros">Comoros</option>
                    <option value="Congo">Congo</option>
                    <option value="Congo, the Democratic Republic of the">Congo, the Democratic Republic of the</option>
                    <option value="Cook Islands">Cook Islands</option>
                    <option value="Costa Rica">Costa Rica</option>
                    <option value="Cote D'Ivoire">Cote D'Ivoire</option>
                    <option value="Croatia">Croatia</option>
                    <option value="Cuba">Cuba</option>
                    <option value="Cyprus">Cyprus</option>
                    <option value="Czech Republic">Czech Republic</option>
                    <option value="Denmark">Denmark</option>
                    <option value="Djibouti">Djibouti</option>
                    <option value="Dominica">Dominica</option>
                    <option value="Dominican Republic">Dominican Republic</option>
                    <option value="Ecuador">Ecuador</option>
                    <option value="Egypt">Egypt</option>
                    <option value="El Salvador">El Salvador</option>
                    <option value="Equatorial Guinea">Equatorial Guinea</option>
                    <option value="Eritrea">Eritrea</option>
                    <option value="Estonia">Estonia</option>
                    <option value="Ethiopia">Ethiopia</option>
                    <option value="Falkland Islands (Malvinas)">Falkland Islands (Malvinas)</option>
                    <option value="Faroe Islands">Faroe Islands</option>
                    <option value="Fiji">Fiji</option>
                    <option value="Finland">Finland</option>
                    <option value="French Guiana">French Guiana</option>
                    <option value="French Polynesia">French Polynesia</option>
                    <option value="French Southern Territories">French Southern Territories</option>
                    <option value="Gabon">Gabon</option>
                    <option value="Gambia">Gambia</option>
                    <option value="Georgia">Georgia</option>
                    <option value="Ghana">Ghana</option>
                    <option value="Gibraltar">Gibraltar</option>
                    <option value="Greece">Greece</option>
                    <option value="Greenland">Greenland</option>
                    <option value="Grenada">Grenada</option>
                    <option value="Guadeloupe">Guadeloupe</option>
                    <option value="Guam">Guam</option>
                    <option value="Guatemala">Guatemala</option>
                    <option value="Guinea">Guinea</option>
                    <option value="Guinea-Bissau">Guinea-Bissau</option>
                    <option value="Guyana">Guyana</option>
                    <option value="Haiti">Haiti</option>
                    <option value="Heard Island and Mcdonald Islands">Heard Island and Mcdonald Islands</option>
                    <option value="Holy See (Vatican City State)">Holy See (Vatican City State)</option>
                    <option value="Honduras">Honduras</option>
                    <option value="Hong Kong">Hong Kong</option>
                    <option value="Hungary">Hungary</option>
                    <option value="Iceland">Iceland</option>
                    <option value="India">India</option>
                    <option value="Indonesia">Indonesia</option>
                    <option value="Iran, Islamic Republic of">Iran, Islamic Republic of</option>
                    <option value="Iraq">Iraq</option>
                    <option value="Ireland">Ireland</option>
                    <option value="Israel">Israel</option>
                    <option value="Jamaica">Jamaica</option>
                    <option value="Japan">Japan</option>
                    <option value="Jordan">Jordan</option>
                    <option value="Kazakhstan">Kazakhstan</option>
                    <option value="Kenya">Kenya</option>
                    <option value="Kiribati">Kiribati</option>
                    <option value="Korea, Democratic People's Republic of">Korea, Democratic People's Republic of</option>
                    <option value="Korea, Republic of">Korea, Republic of</option>
                    <option value="Kuwait">Kuwait</option>
                    <option value="Kyrgyzstan">Kyrgyzstan</option>
                    <option value="Lao People's Democratic Republic">Lao People's Democratic Republic</option>
                    <option value="Latvia">Latvia</option>
                    <option value="Lebanon">Lebanon</option>
                    <option value="Lesotho">Lesotho</option>
                    <option value="Liberia">Liberia</option>
                    <option value="Libyan Arab Jamahiriya">Libyan Arab Jamahiriya</option>
                    <option value="Liechtenstein">Liechtenstein</option>
                    <option value="Lithuania">Lithuania</option>
                    <option value="Luxembourg">Luxembourg</option>
                    <option value="Macao">Macao</option>
                    <option value="Macedonia, the Former Yugoslav Republic of">Macedonia, the Former Yugoslav Republic of</option>
                    <option value="Madagascar">Madagascar</option>
                    <option value="Malawi">Malawi</option>
                    <option value="Malaysia">Malaysia</option>
                    <option value="Maldives">Maldives</option>
                    <option value="Mali">Mali</option>
                    <option value="Malta">Malta</option>
                    <option value="Marshall Islands">Marshall Islands</option>
                    <option value="Martinique">Martinique</option>
                    <option value="Mauritania">Mauritania</option>
                    <option value="Mauritius">Mauritius</option>
                    <option value="Mayotte">Mayotte</option>
                    <option value="Mexico">Mexico</option>
                    <option value="Micronesia, Federated States of">Micronesia, Federated States of</option>
                    <option value="Moldova, Republic of">Moldova, Republic of</option>
                    <option value="Monaco">Monaco</option>
                    <option value="Mongolia">Mongolia</option>
                    <option value="Montserrat">Montserrat</option>
                    <option value="Morocco">Morocco</option>
                    <option value="Mozambique">Mozambique</option>
                    <option value="Myanmar">Myanmar</option>
                    <option value="Namibia">Namibia</option>
                    <option value="Nauru">Nauru</option>
                    <option value="Nepal">Nepal</option>
                    <option value="Netherlands">Netherlands</option>
                    <option value="Netherlands Antilles">Netherlands Antilles</option>
                    <option value="New Caledonia">New Caledonia</option>
                    <option value="New Zealand">New Zealand</option>
                    <option value="Nicaragua">Nicaragua</option>
                    <option value="Niger">Niger</option>
                    <option value="Nigeria">Nigeria</option>
                    <option value="Niue">Niue</option>
                    <option value="Norfolk Island">Norfolk Island</option>
                    <option value="Northern Mariana Islands">Northern Mariana Islands</option>
                    <option value="Oman">Oman</option>
                    <option value="Pakistan">Pakistan</option>
                    <option value="Palau">Palau</option>
                    <option value="Palestinian Territory, Occupied">Palestinian Territory, Occupied</option>
                    <option value="Panama">Panama</option>
                    <option value="Saint Lucia">Saint Lucia</option>
                    <option value="Saint Pierre and Miquelon">Saint Pierre and Miquelon</option>
                    <option value="Saint Vincent and the Grenadines">Saint Vincent and the Grenadines</option>
                    <option value="Samoa">Samoa</option>
                    <option value="San Marino">San Marino</option>
                    <option value="Sao Tome and Principe">Sao Tome and Principe</option>
                    <option value="Saudi Arabia">Saudi Arabia</option>
                    <option value="Senegal">Senegal</option>
                    <option value="Serbia and Montenegro">Serbia and Montenegro</option>
                    <option value="Seychelles">Seychelles</option>
                    <option value="Sierra Leone">Sierra Leone</option>
                    <option value="Singapore">Singapore</option>
                    <option value="Slovakia">Slovakia</option>
                    <option value="Slovenia">Slovenia</option>
                    <option value="Solomon Islands">Solomon Islands</option>
                    <option value="Somalia">Somalia</option>
                    <option value="South Africa">South Africa</option>
                    <option value="South Georgia and the South Sandwich Islands">South Georgia and the South Sandwich Islands</option>
                    <option value="Sri Lanka">Sri Lanka</option>
                    <option value="Sudan">Sudan</option>
                    <option value="Suriname">Suriname</option>
                    <option value="Svalbard and Jan Mayen">Svalbard and Jan Mayen</option>
                    <option value="Swaziland">Swaziland</option>
                    <option value="Sweden">Sweden</option>
                    <option value="Switzerland">Switzerland</option>
                    <option value="Syrian Arab Republic">Syrian Arab Republic</option>
                    <option value="Taiwan">Taiwan</option>
                    <option value="Tajikistan">Tajikistan</option>
                    <option value="Tanzania, United Republic of">Tanzania, United Republic of</option>
                    <option value="Thailand">Thailand</option>
                    <option value="Timor-Leste">Timor-Leste</option>
                    <option value="Togo">Togo</option>
                    <option value="Tokelau">Tokelau</option>
                    <option value="Tonga">Tonga</option>
                    <option value="Trinidad and Tobago">Trinidad and Tobago</option>
                    <option value="Tunisia">Tunisia</option>
                    <option value="Turkey">Turkey</option>
                    <option value="Turkmenistan">Turkmenistan</option>
                    <option value="Turks and Caicos Islands">Turks and Caicos Islands</option>
                    <option value="Tuvalu">Tuvalu</option>
                    <option value="Uganda">Uganda</option>
                    <option value="Ukraine">Ukraine</option>
                    <option value="United Arab Emirates">United Arab Emirates</option>
                    <option value="United States Minor Outlying Islands">United States Minor Outlying Islands</option>
                    <option value="Uruguay">Uruguay</option>
                    <option value="Uzbekistan">Uzbekistan</option>
                    <option value="Vanuatu">Vanuatu</option>
                    <option value="Venezuela">Venezuela</option>
                    <option value="Viet Nam">Viet Nam</option>
                    <option value="Virgin Islands, British">Virgin Islands, British</option>
                    <option value="Virgin Islands, U.s.">Virgin Islands, U.s.</option>
                    <option value="Wallis and Futuna">Wallis and Futuna</option>
                    <option value="Western Sahara">Western Sahara</option>
                    <option value="Yemen">Yemen</option>
                    <option value="Zambia">Zambia</option>
                    <option value="Zimbabwe">Zimbabwe</option>
                </optgroup>
            </select>

        </form>

Some section

  <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/2.6.5/jquery.fullPage.css">

2nd try:
Codepen: http://codepen.io/anon/pen/LVGoMY
Snippet:
Doesn't work here as a snippet

$(document).ready(function () {
    $('#fullpage').fullpage({
        anchors: ["contact-form","contact"],
        navigation: true,
        scrollOverflow: true,
        navigationPosition: 'right',
        navigationTooltips: ["Form","Meh"],
        responsive: 991,
        easingcss3: 'cubic-bezier(0.175, 0.885, 0.320, 1.275)',
        paddingTop: '110px',
        normalScrollElements: '#country'
    });

  $('#country').on('click', function(){$.fn.fullpage.setAllowScrolling(false);})
    $('#country').on('change', function(){$.fn.fullpage.setAllowScrolling(false, "all");})
});

        Some section
        <form action="">
            <select name="country" id="country" class="form-control" style="margin-top:20px;" data-fv-field="country">
                <option selected="" disabled="">Country</option>
                <optgroup label="Frequent Visitors">
                    <option value="France">France</option>
                    <option value="Germany">Germany</option>
                    <option value="Italy">Italy</option>
                    <option value="Norway">Norway</option>
                    <option value="Spain">Spain</option>
                    <option value="United Kingdom">United Kingdom</option>
                    <option value="United States">United States</option>
                </optgroup>
                <optgroup label="All Countries">
                    <option value="Afghanistan">Afghanistan</option>
                    <option value="Albania">Albania</option>
                    <option value="Algeria">Algeria</option>
                    <option value="American Samoa">American Samoa</option>
                    <option value="Andorra">Andorra</option>
                    <option value="Angola">Angola</option>
                    <option value="Anguilla">Anguilla</option>
                    <option value="Antarctica">Antarctica</option>
                    <option value="Antigua and Barbuda">Antigua and Barbuda</option>
                    <option value="Argentina">Argentina</option>
                    <option value="Armenia">Armenia</option>
                    <option value="Aruba">Aruba</option>
                    <option value="Australia">Australia</option>
                    <option value="Austria">Austria</option>
                    <option value="Azerbaijan">Azerbaijan</option>
                    <option value="Bahamas">Bahamas</option>
                    <option value="Bahrain">Bahrain</option>
                    <option value="Bangladesh">Bangladesh</option>
                    <option value="Barbados">Barbados</option>
                    <option value="Belarus">Belarus</option>
                    <option value="Belgium">Belgium</option>
                    <option value="Belize">Belize</option>
                    <option value="Benin">Benin</option>
                    <option value="Czech Republic">Czech Republic</option>
                    <option value="Denmark">Denmark</option>
                    <option value="Djibouti">Djibouti</option>
                    <option value="Dominica">Dominica</option>
                    <option value="Dominican Republic">Dominican Republic</option>
                    <option value="Ecuador">Ecuador</option>
                    <option value="Egypt">Egypt</option>
                    <option value="El Salvador">El Salvador</option>
                    <option value="Equatorial Guinea">Equatorial Guinea</option>
                    <option value="Eritrea">Eritrea</option>
                    <option value="Estonia">Estonia</option>
                    <option value="Ethiopia">Ethiopia</option>
                    <option value="Falkland Islands (Malvinas)">Falkland Islands (Malvinas)</option>
                    <option value="Faroe Islands">Faroe Islands</option>
                    <option value="Fiji">Fiji</option>
                    <option value="Finland">Finland</option>
                    <option value="French Guiana">French Guiana</option>
                    <option value="French Polynesia">French Polynesia</option>
                    <option value="French Southern Territories">French Southern Territories</option>
                    <option value="Gabon">Gabon</option>
                    <option value="Gambia">Gambia</option>
                    <option value="Georgia">Georgia</option>
                    <option value="Ghana">Ghana</option>
                    <option value="Gibraltar">Gibraltar</option>
                    <option value="Greece">Greece</option>
                    <option value="Greenland">Greenland</option>
                    <option value="Grenada">Grenada</option>
                    <option value="Guadeloupe">Guadeloupe</option>
                    <option value="Guam">Guam</option>
                    <option value="Guatemala">Guatemala</option>
                    <option value="Guinea">Guinea</option>
                    <option value="Guinea-Bissau">Guinea-Bissau</option>
                    <option value="Guyana">Guyana</option>
                    <option value="Haiti">Haiti</option>
                    <option value="Heard Island and Mcdonald Islands">Heard Island and Mcdonald Islands</option>
                    <option value="Holy See (Vatican City State)">Holy See (Vatican City State)</option>
                    <option value="Honduras">Honduras</option>
                    <option value="Hong Kong">Hong Kong</option>
                    <option value="Hungary">Hungary</option>
                    <option value="Iceland">Iceland</option>
                    <option value="India">India</option>
                    <option value="Indonesia">Indonesia</option>
                    <option value="Iran, Islamic Republic of">Iran, Islamic Republic of</option>
                    <option value="Iraq">Iraq</option>
                    <option value="Ireland">Ireland</option>
                    <option value="Israel">Israel</option>
                    <option value="Jamaica">Jamaica</option>
                    <option value="Mali">Mali</option>
                    <option value="Malta">Malta</option>
                    <option value="Marshall Islands">Marshall Islands</option>
                    <option value="Martinique">Martinique</option>
                    <option value="Mauritania">Mauritania</option>
                    <option value="Mauritius">Mauritius</option>
                    <option value="Mayotte">Mayotte</option>
                    <option value="Mexico">Mexico</option>
                    <option value="Micronesia, Federated States of">Micronesia, Federated States of</option>
                    <option value="Moldova, Republic of">Moldova, Republic of</option>
                    <option value="Monaco">Monaco</option>
                    <option value="Mongolia">Mongolia</option>
                    <option value="Montserrat">Montserrat</option>
                    <option value="Morocco">Morocco</option>
                    <option value="Mozambique">Mozambique</option>
                    <option value="Myanmar">Myanmar</option>
                    <option value="Namibia">Namibia</option>
                    <option value="Nauru">Nauru</option>
                    <option value="Nepal">Nepal</option>
                    <option value="Netherlands">Netherlands</option>
                    <option value="Netherlands Antilles">Netherlands Antilles</option>
                    <option value="New Caledonia">New Caledonia</option>
                    <option value="New Zealand">New Zealand</option>
                    <option value="Nicaragua">Nicaragua</option>
                    <option value="Niger">Niger</option>
                    <option value="Nigeria">Nigeria</option>
                    <option value="Niue">Niue</option>
                    <option value="Panama">Panama</option>
                    <option value="Papua New Guinea">Papua New Guinea</option>
                </optgroup>
            </select>

        </form>

Some section

  <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/2.6.5/jquery.fullPage.css">

fullPage doesn't work as a snippet
So the question is, what am I missing? Or is this an issue?

A: Your 2nd approach seems to be the way to go for it.
You should disable and enable the scrolling feature by detecting whether the user opens or closes the select box.
When you do this, make sure you are not using the option normalScrollElements as you are doing it now.
Also, whenever you enable or disable the scrolling feature, make sure to use the same function with the same arguments to prevent mistakes:
//enabling
$.fn.fullpage.setAllowScrolling(true);

//disabling
$.fn.fullpage.setAllowScrolling(false);

//vs the one you were using now
$.fn.fullpage.setAllowScrolling(false, "all");

Right now, I noticed in Chrome the click event gets fired even before change gets fired as well, which makes it a bit more tricky to deal with, but that's a matter of javascript rather than about fullPage.js.
If you manage to deal with the click, focus and change events in a proper way to detect whether the select box is opened or not, then you will have it working.


text:
Q: Clicking on links in Outlook gives an error message When I click on a link within an email in Outlook 2010, I get the following error:

I can fix this by setting my default browser to IE, which then opens the link fine. If I set my default browser to Chrome (which is what I actually want), I get the above error again.
How can I fix it so that the links open in Chrome?
Background:
I recently had a problem auto-updating chrome, so I had to reinstall it. In doing so, it seems to have changed from being installed in my profile directory (C:\Users\adrian\AppData\Local\Google\Chrome) to being in Program Files. My feeling is that the location of Chrome in the default browsers has not been updated correctly.

A: This became too annoying and I have fixed it myself after doing a bit of digging - the problem appears to be to do with Chrome, not Outlook.
The registry key at HKEY_CLASSES_ROOT\ChromeHTML.adrian\shell\open\command was still pointing to the location of Chrome within my profile instead of in Program Files. Altering this key to have the new path fixed the behaviour when clicking on links in Outlook.


text:
Q: Dual boot laptop boots straight to Ubuntu I have a Lenovo G580 which had Windows 8 (with UEFI) preinstalled. I got sick of the OS and tried installing Ubuntu alongside using this tutorial :
http://www.everydaylinuxuser.com/2014/05/install-ubuntu-1404-alongside-windows.html?m=1
My problem is that the laptop boots directly into Ubuntu. I tried using boot repair in Ubuntu, which asked me to disable secure boot.I ticked yes.Then it gave me the following screen :
https://drive.google.com/file/d/0B-5q64RDDKM9Zlpna1RnOUowam8/view?usp=docslist_api
And as shown in the image I opened the url (paste.ubuntu.com/12632198/), but I could not understand what was the page

A: The report generated by boot repair http://paste.ubuntu.com/12632198/ tells you the following information:
=================== /etc/default/grub :

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

See the line saying GRUB_HIDDEN_TIMEOUT_QUIET=true ? This tells the boot loader to not show OS selection menu. Open the terminal, type sudo nano /etc/default/grub to open that file with nano text editor, and change line GRUB_HIDDEN_TIMEOUT_QUIET=true to #GRUB_HIDDEN_TIMEOUT_QUIET=true. Save file with Ctrl +O and exit with kbd>Ctrl +X. Finally run sudo update-grub and restart the laptop. You now should be able to see OS selection window upon boot


text:
Q: How can I put the Image in the top-left corner, while still being responsive? I am new to Angular/Bootstrap and currently trying to put an image on top of the navigation bar in the top left corner. Using padding/margin could fix the problem with a normal resolution/static screen size, changing the size put the image elsewhere.
I have tried to use padding and margin, but as I said, it was not possible, to make it "sticky" in the top left corner, when changing the browser sice.
Also using the bootstrap classes, for example "pull-right" (just for test-cases) did not work.
My current code looks like:

                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive"
                    aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">

                </button>

                            Home
                                (current)

                            About

                            Profile

                            Impressum

TestSite

I expected an image in the top left corner that is responsively staying there while changing browsersizes/devices

A: Please check this code to see, whether this is the desired result. Fully working demo is available here
Main Changes made on your code is.

*

*added CSS class bg-dark and removed $green static-top on nav.

*fixed the width of brand image to 50%, using css. This can be changed to some other value.

*removed width and height attributes from img tag.

.navbar-brand img{
  width: 50%;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>

                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive"
                    aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">

                </button>

                            Home
                                (current)

                            About

                            Profile

                            Impressum


text:
Q: How to use the new manifest merger (of Android Studio and Gradle)? Background
In the past, when Eclipse&ADT were the official tools to develop for Android, you could simply use "manifestmerger.enabled=true" inside the "project.properties" of the app's project, and you got it merging all of the libraries' manifests automatically (and I've posted about it here).
This worked, sometimes. It had a lot of weird issues, and I always preferred to just avoid using it, and put what is needed into the main manifest file manually.
The problem
Somewhere on 2014, Google announced that the new Android-Studio (0.1 I think), together with Gradle, will allow you to choose exactly how to perform merging of libraries' components.
However, the new instructions (link here) are very complex and I really (really) tried to understand how to use them, and also didn't find samples of how to use them.
It's not that I didn't understand anything, but I'm not sure if I understood well.
What I've found
On the bright side, I've found out that merging is done completely automatically, so if you have a BroadcastReceiver on the library's manifest (and as a class, of course), it will be added to the app's project that uses it.
The question
I can't simply ask everything to be explained. I think it will be enough to ask those questions:

*

*How can I choose which app components (permissions, activities,...) to be ignored from being auto-merged?

*How can I point override app components (of the library) attributes (on the app's project) ? for example the theme of the activities?

*Is there a way to completely disable the auto-merger for the manifest files?

*What happens with manifests of dependencies that are inside repositories? Are they merged too?

*Are there any tutorials/samples/videos regarding this new (well new for me) feature?

*Are there any things I should be aware of when using the auto-merger?
I hope those questions are representative enough, informative enough, yet not too hard to answer for people who know.

A: 1. Disabling elements
You can always explicitly disable permissions and features in your app's manifest and override any library values. And i found that you can disable elements from library.
Example
Consider the following code from the above link:
<activity-alias android:name="foo.bar.alias">
    <meta-data
        android:name="zoo"
        tools:node="remove" />
</activity-alias>

By having this code inside your manifest you ensure that the merger finds any <activity-alias> elements with android:name="foo.bar.alias" attribute and removes a <meta-data> element if it has the android:name="zoo" attribute. It removes just the "zoo" meta data. Not the activity alias. If you specify this in your main manifest it will be effective on anything that has been merged so far (elements from libraries).
Example #2
Since you requested an example with activities, this is what I've come up with:
<activity android:name="com.example.ui.MyActivity" tools:node="remove" />

This line will make the merger remove any activities with android:name="com.example.ui.MyActivity" attribute that have been merged so far. So if you specify this in your main manifest it will effectively remove any com.example.ui.MyActivity entries that might have been merged from libraries.
2. Overriding attributes from library
The order in which the values are merged are described here. Basically, it goes like this: libraries, then main manifest, then flavors and build types manifests if you use those.
What are build types?
The default are "debug" and "release". You can define your own and override settings like signing or proguard. For your purposes you could say it's the equivalent of run configurations.
It works like this: you put your default and shared values inside the main manifest. Then in flavor manifests you override the values you need. Google "gradle flavors" for more info.
The following example is taken from a previous version of manifest merger documentation.

Override an attribute coming from a library
Using tools:replace="x, y, z" will override x,y,z attributes from the
imported library's activity XML declarations.
Higher Priority declaration
<activity
    android:name="com.foo.bar.ActivityOne"
    android:screenOrientation="portrait"
    android:theme="@theme1"
    tools:replace="theme"/>

with a lower priority declaration :
<activity
    android:name="com.foo.bar.ActivityOne"
    android:theme="@olddogtheme"
    android:windowSoftInputMode="stateUnchanged"
    android:exported="true">

will result in :
<activity
    android:name="com.foo.bar.ActivityOne"
    android:screenOrientation="portrait"
    android:theme="@theme1"
    android:windowSoftInputMode="stateUnchanged"
    android:exported="true"/>

3. Disabling manifest merger altogether
See Disable Manifest Merger in Android Gradle Build.
android.applicationVariants.all { variant ->
    variant.processResources.manifestFile = file('src/main/AndroidManifest.xml')
    variant.processManifest.enabled=false
}

In what file do you put this?
At the end of your module's (not root project) build.gradle.
4. Are manifests from dependencies merged?
Yes they are (they're libraries).
Is there a way to block merging certain library manifests?
Not that I know of, sorry.
5. Any tutorials?
Depends on what are you trying to achive. So far it always worked for me out-of-the-box.

*

*e.g. http://www.myandroidsolutions.com/2014/04/10/android-gradle-manifest-merge/

*The manifest merger documentation (link below).

I don't know about any videos.
6. Anything I should be aware of?
You can check the generated manifest if you get suspicious about extra permissions etc. It's located in project/module/build/intermediates/manifests/full/[flavor]/build-type/AndroidManifest.xml.
Source: https://developer.android.com/studio/build/manifest-merge

A: Some of the links in this thread are obsolete. Here's the main one that is updated related to auto merger of manifests, by gradle, for Android AARs.
https://developer.android.com/studio/build/manifest-merge


text:
Q: Something's consuming my laptop's resources I bought my laptop 6 months ago. It's a Lenovo G50-70. Last week, my laptop got slow down so much that the cursor was lagging behind the motion of my mouse. It was obvious. Task manager took about 5 minutes to show up. It showed something shocking. There were 3 processes that were consuming the disk usage and the memory.
Today, the same phenomena happened again. I snapped it quite soon because the memory consuming process was increasing at a larger rate. It went to consuming about 6.5GB of the available 8GB RAM (even my games don't consume any more than 3GB of RAM), that I finally had to force-restart my laptop to do my works. Once restarted, things go fine.
I don't see any viruses in the system. And, I don't think it's a normal thing. Has anyone got any idea about this problem?


text:
Q: Symfony 4 Doctrine not working from console [2002] No such file or directory I´m working with symfony 4 and this error ocurr when runnning doctrine console commands:
In AbstractMySQLDriver.php line 108:

An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory

I think this is because there´s something wrong with the connection but when I run the application it has access to the database without errors, so I can not imagine what is wrong with the connection.
I was able to continue working by creating manually the database and using
php bin/console doctrine:schema:create --dump-sql

But this is really unwanted because later when the schema needs to be updated all data would be lost because i would need to re-create the schema instead of updating it.
The app works normally after executing manually the SQL (easyadmin works fine).
Here are my configurations:
.ENV:
DATABASE_URL=mysql://root:root@127.0.0.1:3306/test

doctrine.yaml:
parameters:
     env(DATABASE_URL): ''

doctrine:
    dbal:
       driver: 'pdo_mysql'
       server_version: '5.7'
       charset: utf8mb4

I tried the drop command just to test and it throwed this:
In DropDatabaseDoctrineCommand.php line 93:

Connection does not contain a 'path' or 'dbname' parameter and cannot be dropped.

So I add dbname to doctrine.yaml and didn´t worked.
I also tried removing the cache, creating a new project, using a remote mysql, and using sqlite but the errors are the same in both cases !!
Thanks in advance for the help !

A: Please change DB_HOST=localhost to DB_HOST=127.0.0.1
> doctrine/doctrine-bundle
DATABASE_URL=mysql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}

A: So i suppose that you showed the whole content of your doctrine.yml.
If so, you might want to consider changing your doctrine.yml as follows:
add an additional line in the dbal: section
doctrine:
    dbal:
       driver: 'pdo_mysql'
       server_version: '5.7'
       charset: utf8mb4
       url: '%env(resolve:DATABASE_URL)%'

Watch the last line, beginning with url:, closely.
The 'resolve:" operator looks up DATABASE_URL in your env-Variables and if it is found, it then replaces the expression with its content.
This is a doctrine.yml, that gets auto-generated by symfony.
The 'resolve' operator migth not be needed though. This could potentially work too:
doctrine:
    dbal:
       driver: 'pdo_mysql'
       server_version: '5.7'
       charset: utf8mb4
       url: '%env(DATABASE_URL)%'

This method is proposed in the symfony docs, which might be interesting to read, to understand further configuration of symfony.

A: My fix is here:
export DATABASE_URL=<value from .env>

And generating SQLs works :)

A: config/packages/doctrine.yaml
I solved this error adding my database url in the "config/packages/doctrine.yaml" file the "parameters" > "env(DATABASE_URL)" field:
parameters:
     # Adds a fallback DATABASE_URL if the env var is not set.
     # This allows you to run cache:warmup even if your
     # environment variables are not available yet.
     # You should not need to change this value.
     env(DATABASE_URL): 'mysql://your_db_url'

A: I solved this change in .env file
DATABASE_URL=mysql://root:root@127.0.0.1:3306/test

to
DATABASE_URL="mysql://root:root@127.0.0.1:3306/test"

I added quotes. Maybe you are using windows? It works for me.
like in Symfony docs: Environment Variables

A: Hi On my side I add the exact same behaviour, on symfony 4,
I just changed this
DATABASE_URL=mysql://root:root@localhost:8889/

to this
DATABASE_URL=mysql://root:root@127.0.0.1:8889

on my .env or .env.dev file (depend on the env you are working on)
hope it helps.


text:
Q: JAX WS services wsdlLocation Could somebody explain to me why I need use wsdlLocation file in
javax.xml.ws.Service service =
    javax.xml.ws.Service.create(`wsdlLocation`, javax.xml.namespace.QName)

MCIDispositionRights port = service.getPort(MCIDispositionRights.class);

I dont want use the wsdlLocation file;  I need to use just URL.
Does somebody know which information is parsed from wsdl file for client.
Why do I need the wsdl in the client part?  I could not find any information about it.

A:
In Short:

If you don't give wsdl, how will client know which service to call, which operation to call and what is the structure of operation?
Once you provide the wsdl information, entire schema/structure is re-created for you including transport information, security information (e.g if invocation of service requires WS-Policy information.
And wsdl is for "client" only.If there was no use of it for client, why would anyone publish this interface document.
Thanks

In detail:

Go through wsdl document to understand the usage of different elements.
http://download.oracle.com/otn_hosted_doc/jdeveloper/1012/web_services/ws_wsdlstructure.html


text:
Q: Skimage ValueError: total size of new array must be unchanged I am trying to use skimage.color separate_stains in an HE deconvolution.
i_hdx = separate_stains(ihc, conv_matrix)

returning an error ValueError: total size of new array must be unchanged
Is there an issue with the version of skimage.color (0.10.0), something with np.reshape, or a separate issue?
EDIT: The size of the image seems to play a part in getting an error, which leads me to believe it could be a numpy issue.
  File "/usr/local/lib/python2.7/site-packages/skimage/color/colorconv.py", line 1131, in separate_stains
stains = np.dot(np.reshape(-np.log(rgb), (-1, 3)), conv_matrix)

File "/usr/local/lib/python2.7/site-packages/numpy/core/fromnumeric.py", line 221, in reshape
return reshape(newshape, order=order)


text:
Q: Find and Replace text (FART): Replaced 0 occurence(s) The great FART utility seems to be the norm when trying to replace text on the windows command line.
However I can't get it to work as shown in the examples. My test file test.txt:
Images Here Images
ImagesWhateverImages

I now try this:
fart -r -i -p "test.txt" "Images"

and get:
Images Here Images
ImagesWhateverImages
Found 4 occurence(s) in 1 file(s).

Great! But when now trying to replace Images with Foo it won't work:
fart -r -i -p "test.txt" "Images" "foo"
--> Replaced 0 occurence(s) in 1 file(s).

Everyone seems to just do a fart -r -i- p <filename> <string_to_replace> <replacement> command and work with it. What am I doing wrong?

A: Is this a trick question? FART's usage help clearly states that -p stands for "preview", so if you remove it the changes will actually be made.
(Also, -r isn't required if you're only dealing with a single file.)


text:
Q: Content outside of the block
Does anyone know what is that white space on the bottom of my page and how to solve that problem? The bckgr image should be 100vh, but as you can see it is not. Why?
.content {
    width:100%;
    background: url(../img/Background.png) no-repeat center;
    background-size:cover;
    height: 100vh;
}


text:
Q: How to SED with open boundaries? I was thinking too complicated the slicing in the How to express variables efficiently for SED?
I want to include (a,b), not [a,b] like this don_crissti's command:
sed '/begin{document}/,/end{document}/!d;/end{document}/q' data.tex

So I do not want to include \begin{document} and \end{document} in the output.
How can you having an open interval in the output?

A: There are many ways to do so. I suppose that is more undestandable (choice interval and remove which you don't like to include:
sed '/begin{document}/,/end{document}/!d;/begin{document}/d;/end{document}/d' data.tex

or with don-crissti's receipt:
sed '/begin{document}/,/end{document}/!d;//d' data.tex

Other way is start printing after begin in loop till the finish line:
sed -n '/begin{document}/{:;n;/end{document}/!{p;b;};}' data.tex


text:
Q: Is the amount of data sent from firebase limited only to the branch asked for? There is a very large number of numerical leaves (say 1,000,000) under a branch looking like this:

*

*car

*

*1

*2

There is no index on any part of this branch.  If we ask for car/2 in this way:
let ref = Database.database().reference()
ref.child("car").child("2").observeSingleEvent(of: .value, with: {
    (snapshot) in
})

will this cause any other part of the car branch to be read other than the child 2 we asked for?

A: Nope. When you load car/2 it only looks at and returns that specific branch. Other children of car are not touched in any way.
Accessing by a direct path like this does not require an index. Only if you query on car, will you need an index on that level for the values of child nodes that you query on.


text:
Q: Confidence interval of functional - R code Question 1 - Generate 200 data points from the random variable $X \sim exp(2)$, and construct a 95% CI for the functional $\theta=E[e^{X}]$.
My R code is as follows:
x <- rexp(200, rate=1/2)
theta.hat <- mean(exp(x))
sigma.hat <- sd(exp(x))
error <- qnorm(0.975)*sigma.hat/sqrt(200)
left <- theta.hat-error
right <- theta.hat+error

Then (left,right) is a 95% confidence interval for $\theta$. Is this confidence interval correct?
Question 2 - Make a simulation with N=1000 data samples to check what the confidence intervals covering probability is.
My R code is as follows:
N <- 1000
count <- 0
          for(i in (1:N)){
            x <- rexp(200,rate=1/2)
            theta.hat <- mean(exp(x))
            sigma.hat <- sd(exp(x))
            error <- qnorm(0.975)*sigma.hat/sqrt(200)
            left <- theta.hat-error
            right <- theta.hat+error
            count <- count+as.double(left<=2 & 2<=right)}
count/N

However after running the code a few times count/N returns values $\approx 0.76$. I was expecting values $\approx 0.95$? Have I made a mistake or am I missing something?

A: I don't know if this is exactly what you're looking for but it might help you understanding what is going on.
You could get a $95\%$ confidence interval in three different ways:
(1) Monte Carlo
(2) Calculate the distribution of $e^X$ and the distribution of the mean of $e^X$
(3) Central Limit Theorem
You used the third one in question 1. However, as Ian noted, the variance is not finite. In that case, you cannot use it because, well, the variance is infinite. Moreover, you estimated the variance with the sample variance but, in general, it is better if you could plug in the actual variance there if you know how to calculate that one. Furthermore, you found out in Question 2 that the covering probability is not close to $.95$ and this is thus due to the statistical error that is introduced when the Central Limit Theorem is used.
I haven't tried the second method here and I don't know whether it is possible to do it exactly (I don't think it is, to be honest). But in general this might be useful if, for example, when the mean is distributed according to a known distribution (such that you can calculate the parameters).
Last but definitely not least, you can always approximate the distribution of the mean of $e^X$ using Monte Carlo methods, which is the first option I gave and essentially your solution is Question 2.
I hope this is what you're looking for. If some details are unclear, feel free to comment!


text:
Q: Node Express MongoDB Native Driver — Where to open the DB connection? I want to open and initialise the DB via Node-Mongo-Native-Driver once in the app.js file and then leave it open and do reads in the routes. I put following code in the app.js and wrapping the app.gets in order to made them available when the DB is opened:
var mongoClient = new MongoClient(new Server('localhost', 27017));
mongoClient.open(function(err, mongoClient) {
  var db1 = mongoClient.db("dev-db")
    , products = db1.collection('products');
  app.get('/', routes.index);
  app.get('/users', user.list);
});

When I try now to read the DB in the index.js route I get
ReferenceError: products is not defined

I thought that index.js should be able to access products since it was defined in a outer function due to wrapping the app.gets in the initialisation.
Besides a 2nd question: what's the difference between MongoClient.open and MongoClient.connect

A: JavaScript uses lexical scoping - meaning, if you did this it would work:
var mongoClient = new MongoClient(new Server('localhost', 27017));
mongoClient.open(function(err, mongoClient) {
  var db1 = mongoClient.db("dev-db")
    , products = db1.collection('products');
  app.get('/', function closedOverIndexRoute(req, res, next) {
    console.log(products); // this will work
  });
  app.get('/users', user.list); // however, user.list will not be able to see `products`
});

A function doesn't become a closure (doesn't retain the values of its enclosing function) unless it's lexically (written) inside of the closure.
However, you probably don't want to write your whole app as one big closure. Instead, you can use exports and require to get access to your products collection. For example, in a file called mongoconnect.js:
var mongoClient = new MongoClient(new Server('localhost', 27017));
var products;

mongoClient.open(function(err, mongoClient) {
  var db1 = mongoClient.db("dev-db");
  products = db1.collection('products');
});

module.exports = {
  getProducts: function() { return products; }
};

Then in your index.js file:
var products = require('mongoconnect').getProducts();

Another option (if you want to keep just app and index) is to use a pair of closures:
index.js:
module.exports = function(products) {
  return function index(req, res, next) {
    console.log(products); // will have closed-over scope now
  };
};

app.js, inside of mongoClient.open(), where products is defined:
var index = require('./index')(products);


text:
Q: Long Text in TikZ Mindmap Nodes When using TikZ mindmap library on long texts, the text just get's a thin line while the node scales up (compare below).
When using the text width argument, the inscribed rectangle gets wider but still, the bubble is way to big for the inscribed text.
How can I properly use the space of a mindmap node?
\documentclass{scrartcl}

\usepackage{tikz}
\usetikzlibrary{mindmap, trees}

% laymans blindtext
\newcounter{int}
\newcommand{\blindtext}[1]{\setcounter{int}{0}\loop This is a long text. \addtocounter{int}{1}\ifnum\value{int}<#1\repeat}

\begin{document}

\begin{tikzpicture}[
    mindmap,
    concept color=gray!50,
    text=black,
    level 1 concept/.append style={
        level distance=9 cm,
        sibling angle=72}
    ]
    \node[concept] {} [clockwise from=0]
        child {node[concept] {\blindtext{10}}}
        child {node[concept, text width=4.5cm] {\blindtext{10}}};
\end{tikzpicture}

\end{document}

A: One can use the shapepar package to cast the text into a round shape.
Why doing so directly fails with "Runaway argument?" is above me but one can draw an empty node first and overlay the text afterwards:
\documentclass{scrartcl}

\usepackage{tikz, shapepar}
\usetikzlibrary{mindmap, trees}

% laymans blindtext
\newcounter{int}
\newcommand{\blindtext}[1]{\setcounter{int}{0}\loop This is a long text. \addtocounter{int}{1}\ifnum\value{int}<#1\repeat}

\begin{document}

\begin{tikzpicture}[
    mindmap,
    text centered,
    concept color=gray!50,
    text=black,
    level 1 concept/.append style={
        level distance=9 cm,
        sibling angle=72}
    ]
    \node[concept] {} [clockwise from=0]
        child {node[concept, text width=4.5cm] (node1) {}};

    \node[extra concept, fill=none, draw=none, text width=4.5cm] at (node1) {\Shapepar{\circleshape} \blindtext{10}\par};

\end{tikzpicture}

\end{document}


text:
Q: splitting dates in R The time coloumn of my dataframe looks like the following
# time
# %Y-%m-%d
# 2000-01-01
# 2000-01-02
# ...

I would like to split the date coloumn in one for the year and one for the month (I dont need the days)
So the output should look like the following:
# year  month
# %Y    %m
# 2000  01
# 2000  02
# ...

A: In the lubridate package, use the year() and month() functions to extract them, respectively, from a date object.
library(data.table)
library(lubridate)

DT <- as.data.table(yourDataFrame)

DT[, Date := ymd(time)]
DT[, year := year(Date)]
DT[, month := month(Date)]

A: Yo can try separate, e.g.,
library(dplyr)
library(tidyr)

df %>% separate(d,c("year","month"),extra = "drop")

which gives
> df %>% separate(d,c("year","month"),extra = "drop")
  year month
1 2020    01
2 2020    02

Data
df <- data.frame(d = c("2020-01-01","2020-02-01"))

A: Base R:
# data:
time<-seq.Date(from = as.Date("2000/1/1"),to=as.Date("2000/5/1"),by="days")
df<-data.frame(ID=1:length(time), time= time)

# months
df$month<-month(df$time)
# or:
df$month.name<-months(df$time)

df


text:
Q: Sending additional request parameter with Jquery Upload I'm trying to send to Spring Controller additional request parameter through Jquery Upload plugin. I have code as below:
$('#fileupload').fileupload({
        url : url,
        dataType : 'json',
        formData: {
              'projectName': $('#projectSelect :selected').val()
        },
        done : function(e, data) {
            console.info (data);
            //some more logic
        }
 });

What I'm trying to do is to sent the project name to which file corresponds. I tried this formData and used controller as below:
@RequestMapping(value = "upload", method = RequestMethod.POST, produces = "application/json")
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public List<KnownIssueUiModel> upload(@RequestParam("files[]") MultipartFile file, @RequestParam("projectName") String projectName) throws IOException {
    System.out.println("PROJECT NAME: " + projectName);
    // some logic
    return issues;
}

But when I use code as this I get "400 (Required String parameter 'projectName' is not present)". When I tried to use RequestBody and ProjectDto class with getter and setter for projectName and default constructor I got 415 (unsupported media type). I would really appreciate if someone could advice me how can Isend to Spring this project name with file upload.


text:
Q: Can't connect to internet anymore on Ubuntu 22.04 Everything worked well until yesterday; suddenly, my screen froze. After a couple of minutes, it unfroze, but I don't have a network connection (neither Ethernet nor WIFI) anymore. The problem does not occur using Windows 10 on the same machine, so it does not seem to be about the network cable or something like that. I've tried restarting NetworkManager, but that didn't resolve the issue. Running
sudo lshw -sanitize -c network

produced
*-network
       description: Ethernet interface
       product: NetLink BCM57781 Gigabit Ethernet PCIe
       vendor: Broadcom Inc. and subsidiaries
       physical id: 0
       bus info: pci@0000:04:00.0
       logical name: enp4s0
       version: 10
       serial: [REMOVED]
       size: 100Mbit/s
       capacity: 1Gbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi msix pciexpress bus_master cap_list rom ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=tg3 driverversion=5.15.0-37-generic duplex=full firmware=sb ip=[REMOVED] latency=0 link=yes multicast=yes port=twisted pair speed=100Mbit/s
       resources: irq:16 memory:f2110000-f211ffff memory:f2100000-f210ffff memory:f7a00000-f7a007ff
  *-network UNCLAIMED
       description: Network controller
       product: RT5592 PCIe Wireless Network Adapter
       vendor: Ralink corp.
       physical id: 0
       bus info: pci@0000:07:00.0
       version: 00
       width: 32 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list
       configuration: latency=0
       resources: memory:f7900000-f790ffff

I would be really grateful for suggestions as to how to solve this.