Skip to content

Instantly share code, notes, and snippets.

View benzittlau's full-sized avatar

Ben Zittlau benzittlau

View GitHub Profile
@benzittlau
benzittlau / .gitignore
Created April 7, 2011 20:38
My default .gitignore
.bundle
db/*.sqlite3*
log/*.log
*.log
/tmp/
doc/
*.swp
*~
.DS_Store
.rvmrc*
@benzittlau
benzittlau / gist:909162
Created April 8, 2011 02:22
Create a new rails project with Jquery/Mongoid
rails new APP_NAME -m http://railswizard.org/48c15b50eff428bc421f.rb
rails generate mongoid:config
rails generate jquery:install
@benzittlau
benzittlau / application.html.erb
Created April 8, 2011 03:02
Sample application layout file from a typical rails projecst
<!DOCTYPE html>
<html>
<head>
<title>Spike</title>
<%= csrf_meta_tag %>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<%= stylesheet_link_tag 'blueprint/screen', :media => 'screen' %>
<%= stylesheet_link_tag 'blueprint/print', :media => 'print' %>
@benzittlau
benzittlau / Mongoid Hierarchy Excerpt
Created May 4, 2011 21:45
Why you have to be careful using versions in Mongoid
Mongoid/Hierarchy
# Get all child +Documents+ to this +Document+, going n levels deep if
# necessary. This is used when calling update persistence operations from
# the root document, where changes in the entire tree need to be
# determined. Note that persistence from the embedded documents will
# always be preferred, since they are optimized calls... This operation
# can get expensive in domains with large hierarchies.
#
# @example Get all the document's children.
@benzittlau
benzittlau / Remove From Git By Extension
Created May 4, 2011 21:59
Remove all *.swp files from a git repository
git ls-files | grep '\.swp$' | xargs git rm
@benzittlau
benzittlau / ORM Option Generate Migration
Created May 11, 2011 18:21
Explicitly specify which ORM to use when generating a migration in Rails
macbook:bs_portal Ben$ rails g migration add_translations_table --orm=active_record
@benzittlau
benzittlau / layout.haml
Created May 16, 2011 03:15
Application layout file for a haml based sinatra app
!!! 5
%html
%head
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
%title Bens Scraps
%link(rel="stylesheet" href="css/blueprint/screen.css" media="screen")
%link(rel="stylesheet" href="css/blueprint/print.css" media="print")
%link(rel="stylesheet" href="css/custom.css")
@benzittlau
benzittlau / Button.css
Created May 16, 2011 04:13
Good button css
/*http://www.zurb.com/playground/google-buttons*/
button.g-button, a.g-button, input[type=submit].g-button {
padding: 6px 10px;
-webkit-border-radius: 2px 2px;
border: solid 1px rgb(153, 153, 153);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgb(255, 255, 255)), to(rgb(221, 221, 221)));
color: #333;
text-decoration: none;
cursor: pointer;
display: inline-block;
@benzittlau
benzittlau / generate_june_data.rake
Created May 26, 2011 02:35
A quick rake task to manually create the garbage pickups for Edmonton in June 2011.
namespace :alertzy do
desc "Populate June 2011 data"
task :populate_june => :environment do
generate_june_data
end
end
def generate_june_data
mondays = [6,13,20,27]
tuesdays = [7,14,21,28]
mongoid.attributes.user.email