Skip to content

Instantly share code, notes, and snippets.

@zzlalani
zzlalani / Edit Pushed Commit
Last active August 29, 2015 13:58
Edit the pushed commit message
1. git rebase -i <hash-of-commit-preceding-the-incorrect-one>
2. In the editor that opens, change pick to reword on the line for the incorrect commit.
3. Save the file and close the editor.
4. The editor will open again with the incorrect commit message. Fix it.
5. Save the file and close the editor.
6. git push --force to update GitHub.
Originally taken from http://stackoverflow.com/a/5032614/829533
@zzlalani
zzlalani / Singleton.java
Last active March 12, 2016 08:41
Singleton example
class Singleton {
private static Singleton instance;
private Singleton() {
}
/**
* Reference: http://stackoverflow.com/tags/singleton/info
@zzlalani
zzlalani / Software Engineering (8th Edition) by Ian Sommerville, ISBN-13: 978-0321313799, Ch.14 (Object Oriented Design), Exercise 14.5
Created November 13, 2016 12:51
Develop the design of the weather station in detail by proposing interface descriptions of the objects shown in Figure 14.11. These may be expressed in Java, in C++ or in the UMl
class WeatherStation {
private int identifier;
public void reportWeather();
public void calibrate (Instrument instrument);
public void test();
public void startUp(Instrument instrument);
public void shutDown(Instrument instrument);
}
@zzlalani
zzlalani / BinSearch.java
Last active December 18, 2016 09:49
Binary Search in Typescript
import java.util.*;
import java.lang.*;
import java.io.*;
class BinSearch {
int key;
int[] elem;
public BinSearch( int key, int[] elem ) {
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
import java.util.Arrays;
class Solution {
public int solution(int[] A) {
const P = [
Promise.resolve(1),
Promise.reject(0),
Promise.resolve(2),
];
Promise.all(P).then(res => {
console.log(res);
}).catch(rej => {
console.log(rej);