Skip to content

Instantly share code, notes, and snippets.

@cwoodcox
cwoodcox / arr_hash_total.rb
Created August 11, 2011 19:40
Array of Hashes Totaling
array = [{:stat1 => 34, :stat2 => 37}, {:stat1 => 45, :stat2 => 78}]
total = {}
array.each do |element|
element.each do |key, val|
total[key] ||= 0
total[key] += val
end
end
@cwoodcox
cwoodcox / download_all.rb
Created August 19, 2011 08:44
Download'em
#! /usr/bin/ruby
# This little guy will download and save all the URLs it can find from the file it retrieves from a
# given URL. Works awesomely for Apache index pages of lots of image files. Like http://bukk.it
SELECT
T.DateOpenedUTC
,C.DataContent
,T.subject
FROM st_Tickets T
LEFT JOIN st_CustomDataFieldsInTickets C
ON (T.TicketID = C.TicketID)
LEFT JOIN (
SELECT <fourth column here>, Tin.TicketID
chuck@chuck:~/Sites/fastfill → ruby-1.9.2-p290@fastfill → master $ brew install memcached
==> Installing memcached dependency: libevent
==> Downloading http://monkey.org/~provos/libevent-2.0.12-stable.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/libevent/2.0.12
==> make install
/usr/local/Cellar/libevent/2.0.12: 47 files, 1.9M, built in 37 seconds
==> Installing memcached
==> Downloading http://memcached.googlecode.com/files/memcached-1.4.6.tar.gz
######################################################################## 100.0%
@cwoodcox
cwoodcox / uninstall_homebrew.sh
Created September 15, 2011 05:26 — forked from mxcl/uninstall_homebrew.sh
Uninstall Homebrew
#!/bin/sh
# Just copy and paste the lines below
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
cd `brew --prefix`
git ls-files -z | pbcopy
rm -rf Cellar
bin/brew prune
pbpaste | xargs -0 rm
rm -r Library/Homebrew Library/Aliases Library/Formula Library/Contributions
@cwoodcox
cwoodcox / gist:1243669
Created September 26, 2011 22:52
Enumerable#map vs Enumerable#collect
# Using #collect in this example makes more sense in my head, because it's kinda like Array#join
twitter.user_timeline('cwoodcox').tweets.collect do |tweet|
"#{tweet.username}: \" #{tweet.text}\""
end
# Using #map in this context makes more sense in my head, since we're operating on every element
my_stats_array.map do |stat|
stat * 2
end
return $('table#product_stats a').live('ajax:success', function(xhr, response, status) {
var row;
return row = $(this);
});
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="half-life"
# Set to this to use case-sensitive completion
Make a keyboard shortcut to run a shell script with Alfred or Quicksilver, and point it at
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
http://nodejs.org
http://search.npmjs.org/
https://github.com/dannycoates/node-inspector
Terminal:
brew install node
brew install npm
Those little guys will make for a beefy compile process, make sure you're plugged in. building the V8 engine from source can take some time.