Skip to content

Instantly share code, notes, and snippets.

View cdmwebs's full-sized avatar
🦕

Chris Moore cdmwebs

🦕
View GitHub Profile
ps aux | grep -E -i "[j]ruby.*(rails s|rake)" | awk '{print $2}' | xargs kill -9
~/src/chef-repo $ knife cookbook site vendor mysql -d
WARNING: No knife configuration file found
Installing mysql to /var/chef/cookbooks
ERROR: The cookbook repo path /var/chef/cookbooks does not exist or is not a directory
@cdmwebs
cdmwebs / payment.rb
Created May 11, 2011 21:30
Square'd up.
class Payment
FEE_RATE = 0.029 # 2.9%
TRANSACTION_FEE = 0.15
attr_reader :amount
def initialize(amount)
@amount = amount
end
@cdmwebs
cdmwebs / mount.scpt
Created January 8, 2011 07:01
Mount and unmount a drive with AppleScripts. I use these to spin down my second internal HDD. Taken from: MacRumors (http://forums.macrumors.com/showpost.php?p=9596575&postcount=5)
do shell script "diskutil mountDisk `disktool -l | grep Backup | awk '{ print substr($0,20,7) }'`"
@cdmwebs
cdmwebs / database.rake
Created December 20, 2010 10:22
Pull a copy of the latest backup via ssh and restore to dev
require 'net/scp'
namespace :db do
desc 'pull the latest backup & restore locally'
task :restore do
Rake::Task['db:download'].invoke
Rake::Task['db:replace'].invoke
end
desc 'pull down the lastest backup from production'
@cdmwebs
cdmwebs / download.rake
Created December 18, 2010 03:47
Download with rake
require 'uri'
require 'net/http'
desc "Download some files"
task :download do
uri = URI.parse('http://www.google.com')
# shell to curl
system %Q{curl -o google.html #{uri}}
@cdmwebs
cdmwebs / template.rb
Created November 20, 2010 05:22
Rails 3 with options for devise, jquery, cucumber, capybara, rspec and mongoid
generators = []
puts 'Spinning up a new app, captain!'
devise = yes?('Use Devise? (yes/no)')
jquery = yes?('Use jQuery? (yes/no)')
jquery_ui = yes?('Use jQuery UI? (yes/no)') if jquery
mongoid = yes?('Use mongoid? (yes/no)')
haml = yes?('Use haml? (yes/no)')
rspec = yes?('Use Rspec? (yes/no)')
=gradient-bg($color, $top: 5, $bottom: $top)
@if $top < 0 and $bottom < 0
$color1: darken($color, abs($top))
$color2: lighten($color, abs($bottom))
+linear-gradient(color-stops($color1, $color2))
@else
$color1: lighten($color, abs($top))
$color2: darken($color, abs($bottom))
+linear-gradient(color-stops($color1, $color2))
background-color: $color
require 'httparty'
require 'grit'
require 'pathname'
module Wikipedia
class Revision
def initialize(article, revision)
@article = article
@revision = revision
/bin/echo '{"version": "1.1.0","host": "maps.google.com","request_address": true,"address_language": "en_US", "wifi_towers": [{"mac_address": "' $(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s | grep -o "\([0-9a-f]\{2\}:\)\{5\}[0-9a-f]\{2\}" | head -1 ) '","signal_strength": 8,"age": 0}]}' | sed -e 's/" /"/' -e 's/ "/"/g' > /tmp/post.$$ && curl -X POST -d @/tmp/post.$$ http://www.google.com/loc/json | sed -e 's/{/\n/g' -e 's/,/\n/g'