Skip to content

Instantly share code, notes, and snippets.

View cfeduke's full-sized avatar

Charles Feduke cfeduke

View GitHub Profile
@cfeduke
cfeduke / git-rm-after.sh
Created November 23, 2010 23:04
Execute git rm for each file removed from the file system after you've done it
#!/bin/bash
# chmod +x git-rm-after.sh
# add alias git-rm-after ~/git-rm-after.sh to ~/.bashrc
for i in `git status | grep deleted | awk '{print $3}'`; do git rm $i; done
@cfeduke
cfeduke / irb load lib
Created February 10, 2011 18:33
Launch `irb` from your Ruby project's current directory and run...
$LOAD_PATH.unshift("#{`pwd`.chomp("\n")}/lib")
@cfeduke
cfeduke / terminitor for node_smasher
Created February 28, 2011 22:05
sample terminitor project
before { run "cd ~/Projects/node_smasher" }
window :bounds => [0, 22, 865, 916], :settings => "Homebrew" do
run "mate ."
end
window :bounds => [866, 469, 1682, 915], :settings => "Homebrew" do
run "shotgun"
end
# this handles package, node, asset, asset_binary, all recursively
get '/:klass/:id.:format' do |klass, id, format|
klass = klass.classify
options = eval("#{klass}::SERIALIZATION_OPTIONS")
DataFormatter::resolve(-> { eval("#{klass}.where(:id => #{id})")}, format, options)
end
@cfeduke
cfeduke / weather_service_request_message.rb
Created March 23, 2011 16:49
Internal weather message for sponsorship stuff
module Protocol
class WeatherServiceRequestMessage
include ActiveModel::Serialization
attr_accessor :client, :version, :format, :payload, :instructions
REQUIRED_PHONE_PROFILE_IDS = ["0", "9", "13"].freeze
def initialize
@client = Client::NODE_SMASHER
class Hash
def to_key_value
"blah:123"
end
end
def to_bool
return false unless !self.nil?
self !~ /^(false|no|n|0)$/i
end
@cfeduke
cfeduke / enable_trim.sh
Created September 30, 2011 15:14
Enable TRIM on OS X
#!/bin/bash
# derived from http://www.mactrast.com/2011/07/how-to-enable-trim-support-for-all-ssds-in-os-x-lion/
# requires that you run with sudo
cp /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage /IOAHCIBlockStorage.original
perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00).{9}(\x00\x51)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' \
/System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage
sudo kextcache -system-prelinked-kernel
sudo kextcache -system-caches
@cfeduke
cfeduke / ssh_remote_host_completion.zsh
Created January 4, 2012 14:43
ssh remote host name completion
# place in ~/.oh-my-zsh/custom
[ -f ~/.ssh/config ] && : ${(A)ssh_config_hosts:=${${${${(@M)${(f)"$(<~/.ssh/config)"}:#Host *}#Host }:#*\**}:#*\?*}}
[ -f ~/.ssh/known_hosts ] && : ${(A)ssh_known_hosts:=${${${(f)"$(<$HOME/.ssh/known_hosts)"}%%\ *}%%,*}}
zstyle ':completion:*:hosts' hosts $ssh_config_hosts $ssh_known_hosts