Skip to content

Instantly share code, notes, and snippets.

View cfeduke's full-sized avatar

Charles Feduke cfeduke

View GitHub Profile
@cfeduke
cfeduke / Build.scala
Created November 22, 2013 14:29
org.scala-stm
/* get around scala-stm 2.10.0 vs. 2.10 in play vs. reactive mongo */
someDependency exclude("org.scala-stm", "scala-stm_2.10.0")
@cfeduke
cfeduke / sed-replace-in-pom
Created June 12, 2013 12:15
sed replace maven variable in pom
find . -name pom.xml -print0 | xargs -0 sed -i "" "s/{artifactId}/{project.artifactId}/g"
@cfeduke
cfeduke / bash-script-home-dir
Created June 11, 2013 13:44
bash script home directory
# the directory where the shell script physically resides
SCRIPT_HOME_DIR="$( cd "$( dirname "$0" )" && pwd )"
@cfeduke
cfeduke / bash-default-variable-value
Created June 11, 2013 13:41
bash default argument
# var is set to CLI parameter 1 or "value" if not passed
VAR=${1-value}
@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
@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
def to_bool
return false unless !self.nil?
self !~ /^(false|no|n|0)$/i
end
class Hash
def to_key_value
"blah:123"
end
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