Skip to content

Instantly share code, notes, and snippets.

View michealbenedict's full-sized avatar

Micheal michealbenedict

View GitHub Profile
#! /bin/sh
CUR_DIR=$PWD
PID_FILE="$CUR_DIR/node.pid"
if [ $1 = "start" ]; then
if [ -e $PID_FILE ]; then
echo "Node.js is already running."
else
echo "Starting Node Server"
@michealbenedict
michealbenedict / rake tasks in rails3.0.5.rb
Created March 11, 2011 11:27
How to write rake tasks and set in crontab (rails 3)
#via http://jasonseifer.com/2010/04/06/rake-tutorial
#via http://codequietly.com/2010/6/rake-tasks-101 - Basics
#via http://codequietly.com/2010/6/rake-tasks-102 - Advanced use of Rails ENV
#
# General Rake
#
namespace :twitter do
desc 'Search Twitter for the parameter you pass in'
task :search, :query do |cmd, args|
@michealbenedict
michealbenedict / js-closure
Created March 12, 2011 10:55
Javascript Related Blog Links + Basic Inheritance
// Best Practices
http://stackoverflow.com/questions/907225/object-oriented-javascript-best-practices
// Javascript + module Patter
http://www.adequatelygood.com/2010/3/JavaScript-Module-Pattern-In-Depth
// Wrapping Func in JS
http://peter.michaux.ca/articles/wrapping-functions-in-javascript
// JS for Extreme Performance
@michealbenedict
michealbenedict / .profile
Created May 3, 2011 07:41
my bash profile
alias cd..="cd .."
alias l="ls -al"
alias lp="ls -p"
alias h=history
@michealbenedict
michealbenedict / module-submodule-pattern.js
Created May 4, 2011 14:59
Javascript module-submodule pattern
var Module = (function() {
var ModuleBase = function(params) {
this.params = params || {};
}
var submodules = {
"module1" : "SubModule"
};
for(var key in submodules) {
Number.method('integer', function ( ) {
return Math[this < 0 ? 'ceil' : 'floor'](this);
});
String.method('trim', function ( ) {
return this.replace(/^\s+|\s+$/g, '');
});
Function.prototype.method = function (name, func) {
this.prototype[name] = func;
@michealbenedict
michealbenedict / vmd.nodester.com.js
Created May 14, 2011 09:01
vmd.nodester.com not running
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\nApp (r-test) is running..');
}).listen(9974);
/*
nodester info Gathering information about: vmd
nodester info vmd on port 9974 running: true (pid: 15464)
@michealbenedict
michealbenedict / git-cheat.txt
Created May 17, 2011 05:55
Git Checkout branch locally from remote
# fetch branch if not in local and not tracked
git fetch origin remote_branch_name:local_branch_name
# checkout branch locally if branch is tracked after
# git status
git checkout -b local-name origin/remote-name
@michealbenedict
michealbenedict / .gitignore
Created May 18, 2011 19:38 — forked from weaver/.gitignore
Express + Formidable, works with bodyParser and sets req.body correctly.
node_modules
@michealbenedict
michealbenedict / js-benchmark.js
Created May 19, 2011 12:52
JS Benchmarking (John Resig)
// T-Distribution
var tDistribution = 2.776;
// Run the tests in order
runTest("Max Runs, Simple Test", test1, function(){
});
// Run the V8-style Max test (but with error determination)
function runTest(name, test, next){