Skip to content

Instantly share code, notes, and snippets.

@chrisgaunt
chrisgaunt / routes.rb
Created July 31, 2011 03:55 — forked from pixeltrix/routes.rb
Examples of advanced Rails 3.0 routes
Rails.application.routes.draw do
get '/(:locale)/products/(:category)/(page/:page).:extension',
:to => 'products#index',
:as => :products,
:constraints => {
:locale => /[a-z]{2}/,
:category => /.+?/,
:page => /\d+/
},
@chrisgaunt
chrisgaunt / grid_bookmarklet.js
Created July 29, 2011 13:59
Bookmarklet to apply grids (requires jQuery on the site)
javascript:(function($){var width=990;var columns=25;var gutter=10;var column_width=(width-(gutter*(columns-1)))/columns;var grid_container=$('<div id="grid-container"></div>');grid_container.css('z-index','999999');grid_container.css('position','absolute');grid_container.css('top',0);grid_container.css('left',0);grid_container.css('width','100%');grid_container.css('height',$(document).height()+'px');var grid=$('<div id="grid"></div>');grid.css('width',width+'px');grid.css('margin','0 auto');var column=$('<div id="column"></div>');column.css('height',$(document).height()+'px');column.css('background-color','rgba(50,150,255,.2)');column.css('width',column_width+'px');column.css('float','left');column.css('margin-left',gutter+'px');grid.append(column.clone().css('clear','left').css('margin',0));for(var i=0;i<(columns-1);i++){column.clone().appendTo(grid);};grid_container.append(grid);$('body').append(grid_container);}(jQuery));
@chrisgaunt
chrisgaunt / git_changlog
Created July 26, 2011 01:41 — forked from le0pard/git_changlog
Automatic git changelog
#!/usr/bin/env ruby
SPECIAL_TOKEN = 'SpecialTokenForSearch'
WITHOUT_MERGES = "--no-merges"
GIT_COMMIT_LINK="https://github.com/some_projects/commit/:commit"
cmd = `git show-ref --tags`
tags = []
cmd.each do |l|
tag_commit, tag_name = l.chomp.split(" ")
@chrisgaunt
chrisgaunt / .gemrc
Created July 23, 2011 07:01
~/.gemrc to add "--no-ri --no-rdoc" by default when installing gems
gem: --no-ri --no-rdoc
@chrisgaunt
chrisgaunt / mixins.less
Created July 6, 2011 13:26
LESS CSS Mixins
.box-shadow(@x: 0, @y: 1px, @blur: 1px, @color: #000) {
box-shadow: @x @y @blur @color;
-moz-box-shadow: @x @y @blur @color;
-webkit-box-shadow: @x @y @blur @color;
}
.inset-box-shadow(@x: 0, @y: 1px, @blur: 1px, @color: #000) {
box-shadow: inset @x @y @blur @color;
-moz-box-shadow: inset @x @y @blur @color;
-webkit-box-shadow: inset @x @y @blur @color;
@chrisgaunt
chrisgaunt / environment.rb
Created June 30, 2011 23:55
Output SQL in the rails console (Rails 3.0.9)
if "script/rails" == $0
ActiveRecord::Base.logger = Logger.new(STDOUT)
end
@chrisgaunt
chrisgaunt / active_admin_heroku.rb
Created June 30, 2011 12:50 — forked from hoverlover/active_admin_heroku.rb
Rails initializer for using ActiveAdmin with Sass on Heroku
if Rails.env.production?
require 'fileutils'
FileUtils.mkdir_p(Rails.root.join("tmp", "stylesheets", "admin"))
template_path = "#{Gem.loaded_specs['activeadmin'].full_gem_path}/lib/active_admin/stylesheets"
old_compile_path = "#{Rails.root}/public/stylesheets/admin"
new_compile_path = "#{Rails.root}/tmp/stylesheets/admin"
Sass::Plugin::remove_template_location template_path, old_compile_path
Sass::Plugin::add_template_location template_path, new_compile_path