Skip to content

Instantly share code, notes, and snippets.

View joshnabbott's full-sized avatar

Josh N. Abbott joshnabbott

  • Cloudflare Past:Area 1 Security, Big Cartel, Kajabi, Factory Design Labs, Oakley
  • Albuquerque, NM
View GitHub Profile
task :export do
require 'sequel'
require 'fastercsv'
db = Sequel.connect(ENV['DATABASE_URL'])
table_name = ENV['table'].to_sym
table = db[table_name]
fields = table.first.keys
module ActiveRecord
module Searchable
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def searchable_on(*args)
args.flatten!
@args = args.compact
{
:a => 2,
# NOTE for partials, you need to include the format
# otherwise, it'll fail to find byows/_byow.erb even if byows/_byow.html.erb exists
:b => render(:partial => 'example.html')
}.to_json
#!/usr/bin/env ruby
require 'yaml'
if ARGV.size < 1
puts "Usage: github-test.rb my-project.gemspec"
exit
end
require 'rubygems/specification'
data = File.read(ARGV[0])
user_controller.rb
def show
respond_to do |format|
format.json { render :json => @user.to_json(:methods => [:avatar_url])}
end
end
user.rb
def avatar_url
POST /book/:id/notes
note[content]
selection[spine_item_play_order]
selection[chunk_offset]
selection[character_offset]
selection[character_length]

New Machine

What I do after I do a fresh install. Things are sorta grouped by type.

General Config

  1. Start downloading Xcode
  2. Disable auto-bright and turn brightness all the way up
  3. Turn up trackpad tracking
  4. Disable trackpad pinch open & close
class Parent
belongs_to :child, :autosave => true, :polymorphic => true
end
class SomethingController
def create
@parent = Parent.new(params[:parent])
@parent.child = child
if @parent.save
@joshnabbott
joshnabbott / gist:1514978
Created December 23, 2011 18:16 — forked from bemurphy/gist:1424311
run ctags in a post-checkout hook
#!/usr/bin/env ruby
require "shellwords"
def run_tags
`ctags -R . 2>/dev/null`
end
def project_dir
File.basename Dir.pwd
@joshnabbott
joshnabbott / gist:1936170
Created February 28, 2012 23:33 — forked from stephenmckinney/gist:1932021
Installing Ruby 1.8.7 on Lion with only Command Line Tools for Xcode non-llvm gcc 4.2

Installing older Rubies (e.g. Ruby 1.8.7) on a clean install of Lion and Xcode

The latest Xcode and Command Line Tools for Xcode changes the default compiler from gcc to the llvm compiler. Only ruby-1.9.3-p125+ is LLVM ready. So, you will have to install gcc-4.2 to compile older versions of Ruby. More detail here https://github.com/mxcl/homebrew/wiki/Custom-GCC-and-cross-compilers.

This worked for me. I hope it saves some people time:

brew install https://raw.github.com/adamv/homebrew-alt/master/duplicates/apple-gcc42.rb
CC=/usr/local/bin/gcc-4.2 rvm install 1.8.7