Skip to content

Instantly share code, notes, and snippets.

View jbailey's full-sized avatar

Jayson Bailey jbailey

View GitHub Profile
@jbailey
jbailey / 0_reuse_code.js
Last active August 29, 2015 14:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jbailey
jbailey / 20140512193907_create_cards.exs
Last active August 29, 2015 14:01
Ecto/Postrex migration query
defmodule Repo.Migrations.CreateCards do
use Ecto.Migration
def up do
"CREATE TABLE IF NOT EXISTS cards (
id SERIAL PRIMARY KEY,
name VARCHAR (255) UNIQUE NOT NULL,
class VARCHAR (255) NOT NULL,
stars INTEGER NOT NULL,
cost INTEGER NOT NULL,
@jbailey
jbailey / .irbrc
Created January 15, 2014 20:29
My .irbrc and .railsrc files.
#!/usr/bin/ruby
# Add all gems installed in the system to the $LOAD_PATH so they can be used in Rails console with Bundler
if defined?(::Bundler)
current_ruby_version = `rbenv version`.split(" ").first
gem_paths = Dir.glob("#{ENV["HOME"]}/.rbenv/versions/#{current_ruby_version}/lib/ruby/gems/**/gems/*/lib")
gem_paths.each do |path|
$LOAD_PATH << path
end
end
@jbailey
jbailey / .railsrc
Created August 30, 2012 17:54
Railsrc file
In your .irbrc file put:
load File.dirname(__FILE__) + '/.railsrc' if ($0 == 'irb' && ENV['RAILS_ENV']) || ($0 == 'script/rails' && Rails.env)
This is the .railsrc file
#!/usr/bin/ruby
begin
require 'hirb' # sudo gem install cldwalker-hirb --source http://gems.github.com
Hirb.enable
rescue LoadError
@jbailey
jbailey / .vimrc
Created July 2, 2012 20:47
Relative line numbers in normal mode for VIM
" Line number stuff
set rnu
au InsertEnter * :set nu
au InsertLeave * :set rnu
au FocusLost * :set nu
au FocusGained * :set rnu
@jbailey
jbailey / heroku_pg_backups
Created May 18, 2012 15:42
Heroku PG Backups
List Backups
heroku pgbackups --app {PRODUCTION_APP_NAME}
Get URL for a backup
heroku pgbackups:url {ID} --app {PRODUCTION_APP_NAME}
Restore to test
heroku pgbackups:restore DATABASE {BIG_LONG_URL} --app {TEST_APP_NAME}
@jbailey
jbailey / bulkinsert
Created April 25, 2011 16:50
Bulk Insert into couchdb using curl
curl -X POST http://127.0.0.1:5984/geopoll/_bulk_docs -data-binary @seeds.json -H "Content-Type:application/json" -v
# in application_helper.rb
def comment(&block)
#SWALLOW THE BLOCK
end
# in code
<% comment do %>
stuff to comment out here
<% end %>