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
var fs = require('fs'); | |
var _ = require('lodash'); | |
var sys = require('sys'); | |
var exec = require('child_process').exec; | |
function puts(error, stdout, stderr) { | |
sys.puts(stdout) | |
} | |
_(fs.readdirSync('.')) |
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
// -------------------------------------------- | |
// You have a value that is either a scalar or an array. You want an array in either case. | |
function ensureArray(scalarOrArray) { | |
return [].concat(scalarOrArray); | |
} | |
// -------------------------------------------- | |
// You want a clone of an array. | |
function cloneArray(originalArray) { | |
return originalArray.slice(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
var gulp = require('gulp'); | |
var jasmine = require('gulp-jasmine'); | |
require('coffee-script/register'); | |
gulp.task('test', function () { | |
return gulp.src('*.spec.coffee') | |
.pipe(jasmine()); | |
}); |
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
// Execute shell command and retrieve output with 'execute' | |
"groovy -v".execute().text | |
//--------------------------------------- | |
// repeating something a fixed number of times with 'times' | |
// accessing the only value in a closure with 'it' | |
3.times { println "Hello! This is $it" } | |
//--------------------------------------- |
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
# ----------------- tar-zip a folder | |
tar -zcvf path/archive-name.tar.gz directory-path/ | |
# e.g. | |
tar -zcvf ~/nginx-all.tar.gz /etc/nginx/ | |
# ----------------- copy contents of a folder | |
cp -a /source/. /dest/ | |
# ----------------- download a file off a remote server | |
scp USERNAME@REMOTE_HOST:FILE_NAME_IN_HOME_DIR LOCAL_DIR |
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
# find a button by id, name or value; then click it | |
find_button('save').click | |
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
# Open ~/.bashrc and add the following lines | |
if [ -f /etc/bash_completion ]; then | |
. /etc/bash_completion | |
fi | |
export GIT_PS1_SHOWDIRTYSTATE=1 | |
export PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w\[\033[01;33m\]$(__git_ps1)\[\033[01;34m\] \$\[\033[00m\] ' |
NewerOlder