- http://stackoverflow.com/questions/804115 (
rebase
vsmerge
). - https://www.atlassian.com/git/tutorials/merging-vs-rebasing (
rebase
vsmerge
) - https://www.atlassian.com/git/tutorials/undoing-changes/ (
reset
vscheckout
vsrevert
) - http://stackoverflow.com/questions/2221658 (HEAD^ vs HEAD~) (See
git rev-parse
) - http://stackoverflow.com/questions/292357 (
pull
vsfetch
) - http://stackoverflow.com/questions/39651 (
stash
vsbranch
) - http://stackoverflow.com/questions/8358035 (
reset
vscheckout
vsrevert
)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// str byteToHex(uint8 byte) | |
// converts a single byte to a hex string | |
function byteToHex(byte) { | |
return ('0' + byte.toString(16)).slice(-2); | |
} | |
// str generateId(int len); | |
// len - must be an even number (default: 40) | |
function generateId(len) { | |
var arr = new Uint8Array((len || 40) / 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calc_wday(year, month, day) | |
a = (14 - month) / 12 | |
y = year + 4800 - a | |
m = month + 12 * a - 3 | |
wday = day + (153 * m + 2) / 5 + 365 * y + y / 4 - y / 100 + y / 400 + 2 | |
wday = wday % 7 | |
return wday | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
After automatically updating Postgres to 9.6.1 via Homebrew, the pg_ctl start command didn't work. | |
The error was something like "database files are incompatible with server". | |
Database files have to be updated before starting the server, here are the steps that had to be followed: | |
# need to have both 9.6.1 and latest 9.5.x installed, and keep 9.6.1 as default | |
brew unlink postgresql | |
brew install postgresql95 | |
brew unlink postgresql95 | |
brew link postgresql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shuffle = function(v) { | |
for (var j, x, i = v.length; i; j = Math.floor(Math.random() * i), x = v[--i], v[i] = v[j], v[j] = x); | |
return v; | |
}; | |
isSorted = function(v) { | |
for (var i = 1; i < v.length; i++) { | |
if (v[i - 1] > v[i]) { | |
return false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From docx to markdown | |
pandoc -s 'word-file.docx' --wrap=none --reference-links -t markdown -o 'markdown-file.md' | |
# From markdown to docx | |
pandoc 'markdown-file.md' -o 'word-file.docx' | |
# From web page to markdown: | |
pandoc -s -r html http://www.gnu.org/software/make/ -o 'example.md' | |
# From markdown to PDF: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Access "hello" in: | |
var state = { prop1: { prop2: "hello" } }; | |
// Simple solution creating temporary variables: | |
var a = state && state.prop1 && state.prop1.prop2 | |
// a = "hello" | |
// Elegant solution: | |
var a = ((state || {}).prop1 || {}).prop2 | |
// a = "hello" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\+?\d+(?:\-|\.)?\(?\d+(?:\)|\.)?(?:(?:\-|\.)?\d{3,})+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -u 'USER' https://api.github.com/user/repos -d '{"name":"REPO"}' | |
# Remember replace USER with your username and REPO with your repository/application name! | |
git remote add origin git@github.com:USER/REPO.git | |
git push origin master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user.email = "UsERname@DOMain.com" | |
User.where("LOWER(email) = LOWER(?)", user.email).first |