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
/* Funky JavaScript patterns from Resig's talk @ VanJS in Vancouver today. */ | |
/* url: http://ejohn.org/apps/learn/bind.html */ | |
/* loop => callback construct utilizing .call() for each member of the input array */ | |
function loop(array, fn){ | |
for ( var i = 0; i < array.length; i++ ) { | |
fn.call(array, array[i], i); | |
} |
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
<?php | |
interface dRF_Cache_Interface { | |
public function get($id); | |
public function getList($ids); | |
public function set($id, $value); | |
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
desc "get Master" | |
task :get_master_info, :roles => :new do | |
run 'echo "SHOW MASTER STATUS" | mysql -u root --password=root_pass' do |ch, stream, data| | |
set :master_info, data.split("\n").pop().split("\t") | |
end | |
set_master | |
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
/** | |
* user-space unless, some syntactic sugar from ruby implemented in JS | |
* @var {bool} statement - any statement in JS that evaulates to a boolean. Watch for truthiness here. | |
* @var {function} callback - adds the shiny sheen of async programming to this. | |
*/ | |
window.unless = function(statement, callback) { | |
var returnValue = false; | |
args = [].slice.call(arguments); | |
if (args.length > 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
# from here: http://stackoverflow.com/questions/948354/git-push-current-branch/948364#948364 | |
get_git_branch() { | |
echo `git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` | |
} | |
alias gpull='git pull origin `get_git_branch`' | |
alias gpush='git push origin `get_git_branch`' |
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
// Note: more here: http://www.mongodb.org/display/DOCS/dbshell+Reference | |
// also, scripting note: db = db.getSisterDB( "users" ) is a script equiv of use users in the shell | |
// get rs status | |
rs.status() | |
// re-configure replicaset | |
config = rs.conf() | |
//manipulate the config data here | |
rs.reconfigure(config); |
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
#!/bin/bash | |
IS_VM="No" | |
WATCHFILE="$HOME/.isVm" | |
if [ -f $WATCHFILE ]; then | |
exit; | |
fi | |
DMI_OUTPUT=`sudo dmidecode | awk '/Manufacturer: (Bochs|VMware)/ {print $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
# Resources: | |
# 1. http://amerine.net/2010/02/24/rvm-rails3-ruby-1-9-2-setup.html | |
# 2. http://rvm.beginrescueend.com/ | |
# Dependencies: MacPorts, with readline and mysql5 installed | |
# Side note, under no circumstances should you run any of this using sudo. | |
# install rvm | |
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head ) |
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
sudo port install php52 +apache2 +mysql5 +pear |
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
/* Choosing the right MongoDB oplog size can be difficult, especially if your usage is growing. So here’s quick way to see what the last item in the oplog is. If your down slave or backup is older that this, it won’t be able to resync: */ | |
use local | |
new Date(db.oplog.rs.find().sort({$natural:1}).limit(1).next()["ts"]["t"]) |
OlderNewer