%a - The abbreviated weekday name (``Sun'') %A - The full weekday name (``Sunday'') %b - The abbreviated month name (``Jan'') %B - The full month name (``January'') %c - The preferred local date and time representation %d - Day of the month (01..31) %H - Hour of the day, 24-hour clock (00..23) %I - Hour of the day, 12-hour clock (01..12)
This file contains hidden or 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
# Hex digest a file, without loading the whole file into memory: | |
require 'digest/md5' | |
def md5sum_file(path) | |
digest = Digest::MD5.new | |
File.open(path, 'r') do |file| | |
while buffer = file.read(1024*8) | |
digest << buffer | |
end |
This file contains hidden or 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
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: god | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: God | |
### END INIT INFO |
This file contains hidden or 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
onAdd : function () { | |
this.getPanes().floatPane.appendChild(this.element.get(0)); | |
}, |
This file contains hidden or 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
" Change leader key from \ to , | |
let mapleader = "," | |
map <leader>s :TlistToggle<CR> | |
map <leader>f :FuzzyFinderTextMate<CR> | |
map <leader>l :BufExplorer<CR> | |
map <leader>t :NERDTreeToggle<CR> | |
map <leader>w :b#<CR> |
This file contains hidden or 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
# Rebase | |
$ git commit -a -m "Commit message" | |
$ git fetch | |
$ git rebase [branch] # origin/master | |
$ git push | |
# Stash | |
$ git stash | |
$ git pull | |
$ git stash apply |
This file contains hidden or 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
# Replace text in files using regular expressions | |
# test your search | |
find . | xargs grep ':precision => 2, :scale => 14' -l | |
# replace text | |
find db/migrate -type f -name "*" -exec sed -i -e "s/:precision => 2, :scale => 14/:precision => 14, :scale => 2/g" "{}" \; | |
# test your results | |
grep ":precision => 2, :scale => 14" db/migrate/. -R |
This file contains hidden or 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
# Replace text in files using regular expressions: | |
find db/migrate -type f -name "*" -exec sed -i -e "s/:precision => 2, :scale => 14/:precision => 14, :scale => 2/g" "{}" \; | |
# Find replacements made: | |
grep ":precision => 2, :scale => 14" db/migrate/. -R |
This file contains hidden or 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
// Defining constructor function | |
function SingletonObject() { | |
// TODO: Add your own initialization code here | |
this._message = 'Hello Prototype World!'; | |
}; | |
// Current instance property | |
SingletonObject._instance = null; | |
SingletonObject.getInstance = function() { |
This file contains hidden or 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
// Defining constructor function | |
function ObjectConstructor(message) { | |
// TODO: Add your own initialization code here | |
this.message = message || 'Hello Prototype World!'; | |
}; | |
// Defining an instance function | |
ObjectConstructor.prototype.sayHello = function() { | |
alert(this.message); | |
}; |