Skip to content

Instantly share code, notes, and snippets.

View pzaich's full-sized avatar

Paul Zaich pzaich

View GitHub Profile
@pzaich
pzaich / gist:3292886
Created August 8, 2012 06:49
one-to-one-relationship
create_table "locations", :force => true do |t|
t.integer "shelf_life_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "name"
end
create_table "shelf_lives", :force => true do |t|
t.integer "item_kind_id"
t.integer "duration"
@pzaich
pzaich / gist:3292888
Created August 8, 2012 06:49
one-to-one-relationship
create_table "main", :force => true do |t|
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "dependent", :force => true do |t|
t.integer "main_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "name"
@pzaich
pzaich / gist:3293023
Created August 8, 2012 07:12
Create a relationship expected syntax
Main.create
dependent = Main.dependent.new
dependent.save
@pzaich
pzaich / gist:3293095
Created August 8, 2012 07:20
one-to-one w/ ActiveRecord
Main.create
dependent = Main.build_dependent
dependent.save
#OR
Main.create
dependent = Main.create_dependent
@pzaich
pzaich / gist:3896976
Created October 16, 2012 02:44
initial method
def find_and_generate_overview
start_location = @raw_data =~ /starttext|/i
end_location = @raw_data =~ /endtext/i
self.overview = @raw_data[start_location, end_location]
end
@pzaich
pzaich / gist:3896985
Created October 16, 2012 02:47
actual extraction
self.overview = @raw_data[start_location, end_location]
@pzaich
pzaich / gist:3897009
Created October 16, 2012 02:56
correct slice usage
self.overview = @raw_data[start_location..end_location]
@pzaich
pzaich / gist:3949902
Created October 25, 2012 01:07
Use RubyZip to open zip file and iterate through its contents
require 'zip/zipfilesystem'
z = "somepath"
Zip::ZipFile.open(z) do |zipfile|
zipfile.glob("**/*.*").each do |entry|
{block}
end
end
@pzaich
pzaich / gist:3997914
Created November 2, 2012 00:48
install graphicsmagick to EC2
wget ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/1.3/GraphicsMagick-1.3.15.tar.gz
tar -xvf GraphicsMagick-1.3.15.tar.gz
cd GraphicsMagick-1.3.15
./configure
make
@pzaich
pzaich / pagination_overrides.scss
Created November 9, 2012 07:48
bootstrap overrides for kaminari pagination
.pagination a, .pagination span.current, .pagination span.gap {
float: left;
padding: 0 14px;
line-height: 38px;
text-decoration: none;
background-color: white;
border: 1px solid #DDD;
border-left-width: 0;
}