Sort array of objects by string property value

I have an array of JavaScript objects: ``` var objs = [ { first_nom: 'Lazslo', last_nom: 'Jamf' }, { first_nom: 'Pig', last_nom: 'Bodine' }, { first_nom: 'Pirate', last_nom: 'Pr...

Message 'src refspec master does not match any' when pushing commits in Git

I clone my repository with: ``` git clone ssh://xxxxx/xx.git ``` But after I change some files and `add` and `commit` them, I want to push them to the server: ``` git add xxx.php git commit -m "TE...

How do I test for an empty JavaScript object?

After an AJAX request, sometimes my application may return an empty object, like: ``` var a = {}; ``` How can I check whether that's the case?

17 Jan at 13:22

How do I efficiently iterate over each entry in a Java Map?

If I have an object implementing the `Map` interface in Java and I wish to iterate over every pair contained within it, what is the most efficient way of going through the map? Will the ordering of ...

How do I tell if a file does not exist in Bash?

This checks if a file exists: ``` #!/bin/bash FILE=$1 if [ -f $FILE ]; then echo "File $FILE exists." else echo "File $FILE does not exist." fi ``` How do I only check if the file does e...

17 Jul at 00:23

Using global variables in a function

How do I create or use a global variable inside a function? How do I use a global variable that was defined in one function inside other functions? --- `global``UnboundLocalError`[UnboundLocalError...

9 Sep at 14:53

What are the differences between a pointer variable and a reference variable?

What is the difference between a pointer variable and a reference variable?

4 Jul at 20:58

How do I cast int to enum in C#?

How do I cast an `int` to an `enum` in C#?

10 Jul at 23:22

Why is char[] preferred over String for passwords?

In Swing, the password field has a `getPassword()` (returns `char[]`) method instead of the usual `getText()` (returns `String`) method. Similarly, I have come across a suggestion not to use `String` ...

13 Jan at 11:48

How to iterate over rows in a DataFrame in Pandas

I have a pandas dataframe, `df`: ``` c1 c2 0 10 100 1 11 110 2 12 120 ``` How do I iterate over the rows of this dataframe? For every row, I want to be able to access its elements (values in ...

24 Oct at 18:50

Move existing, uncommitted work to a new branch in Git

I started some work on a new feature and after coding for a bit, I decided this feature should be on its own branch. How do I move the existing uncommitted changes to a new branch and reset my curre...

9 Oct at 05:1

How do I get the current branch name in Git?

How do I get the name of the current branch in Git?

8 Jul at 06:38

How do I get the current time?

How do I get the current time?

1 Apr at 11:27

View the change history of a file using Git versioning

How do I view the history of an individual file with complete details of what has changed? `git log -- [filename]` shows me the commit history of a file, but how do I see the file content that changed...

10 Jul at 21:49

Remove a file from a Git repository without deleting it from the local filesystem

I want to remove a file from my repository. ``` git rm file_to_remove.txt ``` will remove the file from the repository, but it will also remove the file from the local file system. How do I remove th...

How do I correctly clone a JavaScript object?

I have an object `x`. I'd like to copy it as object `y`, such that changes to `y` do not modify `x`. I realized that copying objects derived from built-in JavaScript objects will result in extra, unwa...

30 Apr at 19:52

Set cellpadding and cellspacing in CSS?

In an HTML table, the `cellpadding` and `cellspacing` can be set like this: ``` <table cellspacing="1" cellpadding="1"> ``` How can the same be accomplished using CSS?

6 Jun at 19:40

How do I POST JSON data with cURL?

I use Ubuntu and installed [cURL](https://en.wikipedia.org/wiki/CURL) on it. I want to test my Spring REST application with cURL. I wrote my POST code at the Java side. However, I want to test it with...

What is the difference between public, protected, package-private and private in Java?

In Java, are there clear rules on when to use each of access modifiers, namely the default (package private), `public`, `protected` and `private`, while making `class` and `interface` and dealing with...

How to copy files

How do I copy a file in Python?

What does the explicit keyword mean?

What does the `explicit` keyword mean in C++?

When to use LinkedList over ArrayList in Java?

I've always been one to simply use: ``` List<String> names = new ArrayList<>(); ``` I use the interface as the type name for , so that when I ask questions such as this, I can rework my code. When sh...

How do I loop through or enumerate a JavaScript object?

I have a JavaScript object like the following: ``` var p = { "p1": "value1", "p2": "value2", "p3": "value3" }; ``` How do I loop through all of `p`'s elements (`p1`, `p2`, `p3`...) and ge...

8 May at 17:29

What is __init__.py for?

What is [__init__.py](https://docs.python.org/3/tutorial/modules.html#packages) for in a Python source directory?

How do I convert a String to an int in Java?

How can I convert a `String` to an `int`? ``` "1234" → 1234 ```

25 Jan at 13:11