Undo a Git merge that hasn't been pushed yet
I accidentally ran `git merge some_other_branch` on my local master branch. I haven't pushed the changes to origin master. How do I undo the merge? --- After merging, `git status` says: ``` # On br...
How do I get a timestamp in JavaScript?
I want a single number that represents the current date and time, like a [Unix timestamp](https://en.wikipedia.org/wiki/Unix_time).
- Modified
- 7 Aug at 21:40
How do I clone all remote branches?
My `master` and `development` branches are tracked remotely on [GitHub](http://en.wikipedia.org/wiki/GitHub). How do I clone both these branches?
- Modified
- 9 Sep at 09:30
How do I update or sync a forked repository on GitHub?
I forked a project, made changes, and created a pull request which was accepted. New commits were later added to the repository. How do I get those commits into my fork?
- Modified
- 8 Jul at 05:19
Setting "checked" for a checkbox with jQuery
I'd like to do something like this to tick a `checkbox` using : ``` $(".myCheckBox").checked(true); ``` or ``` $(".myCheckBox").selected(true); ``` Does such a thing exist?
- Modified
- 8 Mar at 23:8
"Thinking in AngularJS" if I have a jQuery background?
Suppose I'm familiar with developing client-side applications in [jQuery](http://jquery.com/), but now I'd like to start using [AngularJS](http://angularjs.org/). Can you describe the paradigm shift t...
- Modified
- 2 Nov at 23:22
Why does Google prepend while(1); to their JSON responses?
Why does Google prepend `while(1);` to their (private) JSON responses? For example, here's a response while turning a calendar on and off in [Google Calendar](https://calendar.google.com/calendar/abo...
- Modified
- 3 Jan at 22:3
Which "href" value should I use for JavaScript links, "#" or "javascript:void(0)"?
The following are two methods of building a link that has the sole purpose of running JavaScript code. Which is better, in terms of functionality, page load speed, validation purposes, etc.? ``` func...
- Modified
- 19 Feb at 08:58
Avoiding NullPointerException in Java
I use `x != null` to avoid [NullPointerException](https://docs.oracle.com/javase/9/docs/api/java/lang/NullPointerException.html). Is there an alternative? ``` if (x != null) { // ... } ```
- Modified
- 10 Jul at 23:18
How to enumerate an enum?
How can you enumerate an `enum` in C#? E.g. the following code does not compile: ``` public enum Suit { Spades, Hearts, Clubs, Diamonds } public void EnumerateAllSuitsDemoMethod() {...
- Modified
- 24 Nov at 00:35
Finding the index of an item in a list
Given a list `["foo", "bar", "baz"]` and an item in the list `"bar"`, how do I get its index `1`?
The Definitive C++ Book Guide and List
This question attempts to collect the few pearls among the dozens of bad C++ books that are published every year. Unlike many other programming languages, which are often picked up on the go from tuto...
How do I UPDATE from a SELECT in SQL Server?
In , it is possible to insert rows into a table with an `INSERT.. SELECT` statement: ``` INSERT INTO Table (col1, col2, col3) SELECT col1, col2, col3 FROM other_table WHERE sql = 'cool' ``` Is it a...
- Modified
- 1 May at 16:21
What is RESTful programming?
What exactly is [RESTful programming](https://en.wikipedia.org/wiki/Representational_state_transfer)?
- Modified
- 10 Jul at 23:19
How can I pair socks from a pile efficiently?
Yesterday I was pairing the socks from the clean laundry and figured out the way I was doing it is not very efficient. I was doing a naive search — picking one sock and "iterating" the pile in order t...
- Modified
- 23 Apr at 19:19
Iterating over dictionaries using 'for' loops
``` d = {'x': 1, 'y': 2, 'z': 3} for key in d: print(key, 'corresponds to', d[key]) ``` How does Python recognize that it needs only to read the `key` from the dictionary? Is `key` a special key...
- Modified
- 1 Apr at 00:48
How do I delete a commit from a branch?
How do I delete a commit from my branch history? Should I use `git reset --hard HEAD`?
- Modified
- 8 Jul at 04:44
Undoing a git rebase
How do I easily undo a git rebase? A lengthy manual method is: 1. checkout the commit parent to both of the branches 2. create and checkout a temporary branch 3. cherry-pick all commits by hand 4. re...
- Modified
- 7 Aug at 20:15
How to insert an item into an array at a specific index (JavaScript)
I am looking for a JavaScript array insert method, in the style of: ``` arr.insert(index, item) ``` Preferably in jQuery, but any JavaScript implementation will do at this point.
- Modified
- 7 Mar at 12:49
Create ArrayList from array
Given an array of type `Element[]`: ``` Element[] array = {new Element(1), new Element(2), new Element(3)}; ``` How do I convert this array into an object of type [ArrayList<Element>](https://docs.or...
- Modified
- 17 Jul at 00:14
How do I generate random integers within a specific range in Java?
How do I generate a random `int` value in a specific range? The following methods have bugs related to integer overflow: ``` randomNum = minimum + (int)(Math.random() * maximum); // Bug: `randomNum` c...
What is the !! (not not) operator in JavaScript?
I saw some code that seems to use an operator I don't recognize, in the form of two exclamation points, like so: `!!`. Can someone please tell me what this operator does? The context in which I saw t...
- Modified
- 13 Aug at 21:20
Proper use cases for Android UserManager.isUserAGoat()?
I was looking at the new APIs introduced in [Android 4.2](http://en.wikipedia.org/wiki/Android_version_history#Android_4.1.2F4.2_Jelly_Bean). While looking at the [UserManager](http://developer.androi...
- Modified
- 7 Sep at 08:21
How to round to at most 2 decimal places, if necessary
I'd like to round at most two decimal places, but . Input: ``` 10 1.7777777 9.1 ``` Output: ``` 10 1.78 9.1 ``` How can I do this in JavaScript?
- Modified
- 5 May at 15:28