Skip to content

Instantly share code, notes, and snippets.

@cwoodcox
cwoodcox / config-routes.rb
Created June 14, 2012 19:51
Issue while testing a Rails Engine
Shim::Engine.routes.draw do
match "*id" => 'pages#show', :as => :page, :format => false
root :to => 'pages#show', :id => "index"
end
$ ->
$("#nav-main li").click ->
toExpand = $ $(this).data("expand")
$(".nav-sub").hide()
toExpand.show()
if $(this).hasClass("open")
$("#nav-sub-group").height(0) unless $(this).siblings().hasClass("open")
$("#nav-main li").removeClass("open")
@cwoodcox
cwoodcox / gist:2494074
Created April 25, 2012 22:44
TIL this works in Ruby
module Stuff
def some_method
# stuff...
end
rescue Exception => ex
# Deal with ex here...
end
require 'json'
require 'csv'
require 'pry'
data = JSON.parse(DATA.read)
CSV.open 'data.csv', 'wb' do |csv|
mapping = {
"name" => "custom_field_1",
"email" => "custom_field_4",
"phone" => "custom_field_3",
if params[:q]
attrs = {
id: 0,
business_partner_id: 1,
street_number: params[:q]['near_filter(1)'],
city: params[:q]['near_filter(2)'],
state: params[:q]['near_filter(3)'],
zip_code: params[:q]['near_filter(4)'],
icon_name: "home"
}
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.
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
# 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
return $('table#product_stats a').live('ajax:success', function(xhr, response, status) {
var row;
return row = $(this);
});
@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