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
function parse_git_branch () { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
RED="\[\033[0;31m\]" | |
YELLOW="\[\033[0;33m\]" | |
GREEN="\[\033[0;32m\]" | |
NO_COLOUR="\[\033[0m\]" | |
PS1="$GREEN\u@machine$NO_COLOUR:\w$YELLOW\$(parse_git_branch)$NO_COLOUR\$ " |
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
group :assets do | |
gem 'sass-rails', '~> 3.1.0' | |
gem 'coffee-rails', '~> 3.1.0' | |
gem 'uglifier' | |
gem 'compass' | |
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
$ npm install -g ws | |
$ wscat -c ws://echo.websocket.org -p 8 | |
connected (press CTRL+C to quit) | |
> hi there | |
< hi there | |
> are you a happy parrot? | |
< are you a happy parrot? |
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
Dir['**/*.rb', '**/*.rake'].each { |f| | |
s = open(f).read | |
awesome_rx = /(?<!return)(?<!:)(?<!\w)(\s+):(\w+)\s*=>/ | |
count = s.scan(awesome_rx).length | |
next if count.zero? | |
s.gsub!(awesome_rx, '\1\2:') | |
puts "#{count} replacements @ #{f}" | |
open(f, 'w') { |b| b << s } | |
} |
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
namespace :deploy do | |
task :setup_solr_data_dir do | |
run "mkdir -p #{shared_path}/solr/data" | |
end | |
end | |
namespace :solr do | |
desc "start solr" | |
task :start, :roles => :app, :except => { :no_release => true } do | |
run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec sunspot-solr start --port=8983 --data-directory=#{shared_path}/solr/data --pid-dir=#{shared_path}/pids" |
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
# Create a deep copy of an object. - CoffeeScript conversion of @cederberg's deepClone implementation https://github.com/documentcloud/underscore/pull/595 | |
deepClone = (obj) -> | |
if !_.isObject(obj) or _.isFunction(obj) then return obj | |
if _.isDate obj then return new Date do obj.getTime | |
if _.isRegExp obj then return new RegExp obj.source, obj.toString().replace(/.*\//, "") | |
isArr = _.isArray obj or _.isArguments obj | |
func = (memo, value, key) -> | |
if isArr then memo.push deepClone 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
sudo kill `ps -ax | grep 'coreaudiod' | grep 'sbin' |awk '{print $1}'` | |
# or... | |
sudo killall coreaudiod |
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
Function::property = (prop, desc) -> | |
Object.defineProperty @prototype, prop, desc | |
class Person | |
constructor: (@firstName, @lastName) -> | |
@property 'fullName', | |
get: -> "#{@firstName} #{@lastName}" | |
set: (name) -> [@firstName, @lastName] = name.split ' ' | |
p = new Person 'Leroy', 'Jenkins' |
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 | |
# | |
# git-mv-with-history -- move/rename file or folder, with history. | |
# | |
# Moving a file in git doesn't track history, so the purpose of this | |
# utility is best explained from the kernel wiki: | |
# | |
# Git has a rename command git mv, but that is just for convenience. | |
# The effect is indistinguishable from removing the file and adding another | |
# with different name and the same content. |
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
To set up iTerm 2 so you can open files referenced in a Node stack trace directly in Sublime: | |
1. Go to Preferences->Advanced | |
2. Under "Smart Selection", click the "EDIT" button | |
3. Click the + to add a new rule | |
4. For the Regular expression, user ^\s*at.*\((.+)\) | |
5. For priority, choose Very High | |
6. Click "Edit Actions" | |
7. Click the + to add a new action | |
8. Title "Open in Sublime" |
OlderNewer