Skip to content

Instantly share code, notes, and snippets.


Brent Kirby brentkirby

View GitHub Profile
brentkirby / layout_helper.rb
Last active Apr 26, 2018
Various helpers for populating layout data.
View layout_helper.rb
module LayoutHelper
# Render flash messages
# @param [String] attrs Attributes to add to the surrounding <div>
def flash_messages(attrs = {})
return if flash.nil? or flash.empty?
closer = "<span class='close'>&times;</span>"
brentkirby / to_bool.rb
Created Aug 22, 2014
Boolean Coercion
View to_bool.rb
class Fixnum
def to_bool
self == 1
def Float
def to_bool
brentkirby / app.conf
Last active Dec 24, 2015
Master nginx confs.
View app.conf
# If using a proxy server
upstream app{
#server unix:///app_path/shared/sockets/app.sock fail_timeout=0;
server unix:///app_path/shared/sockets/app.sock;
brentkirby /
Created May 29, 2013
Responsive tables ( custom implementation of foundation example )
class RTable
orig: null
wrap: null
pinned: null
@orig = $(table)
.wrap("<div class='table-wrapper'></div>")
@wrap = @orig.parent('div.table-wrapper')
brentkirby / divs.html
Last active Dec 15, 2015
Susy Grid Helper
View divs.html
<div id='grid'><div id='baseline_grid'></div></div>
brentkirby / runner.js
Created Sep 8, 2012
Run raw coffeescript specs in browser with jasmine
View runner.js
* Make sure coffeescript.js, jasmine, and all other dependencies are loaded,
* then assign a global "specs" variable which is an array of file names in
* your spec/ folder.
* window.specs = ['index'];
(function() {
brentkirby / _grid.scss
Created Sep 6, 2012
Susy debug action
View _grid.scss
// optional, i like the light black better
$grid-background-column-color:rgba(black, 0.075);
@mixin debug-susy-grid($points){
#grid{ position:absolute; top:0px; right:$grid-padding; left:$grid-padding; bottom:0px; display:none;
@include susy-grid-background; z-index:10000;
@for $i from 1 to length($points){
@include at-breakpoint(nth($points, $i)){
@include susy-grid-background;
View .gemrc
:verbose: true
:bulk_threshold: 1000
install: --no-ri --no-rdoc --env-shebang
:benchmark: false
:backtrace: false
update: --no-ri --no-rdoc --env-shebang
View product_spec.rb
require 'spec_helper'
describe Product do
it{ should belong_to :designer }
it{ should have_many :taggings }
it{ should have_many(:tags).through(:taggings) }
it{ should have_many :images }
it{ should have_many :product_properties }
it{ should have_many(:available_properties).through(:product_properties) }
brentkirby / lame.rb
Created Mar 5, 2012
naming fix for active model
View lame.rb
def self.model_name
name = "Entry"
name.instance_eval do
def plural; pluralize; end
def singular; singularize; end
def i18n_key; singularize; end
def human(*args); singularize; end
return name