Skip to content

Instantly share code, notes, and snippets.

Avatar

Brent Kirby brentkirby

View GitHub Profile
@brentkirby
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
brentkirby / to_bool.rb
Created Aug 22, 2014
Boolean Coercion
View to_bool.rb
class Fixnum
def to_bool
self == 1
end
end
def Float
def to_bool
self.to_i.to_bool
end
@brentkirby
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
brentkirby / tables.coffee
Created May 29, 2013
Responsive tables ( custom implementation of foundation example )
View tables.coffee
class RTable
orig: null
wrap: null
pinned: null
constructor:(table)->
@orig = $(table)
@orig.addClass('modified')
.wrap("<div class='table-wrapper'></div>")
@wrap = @orig.parent('div.table-wrapper')
@split()
@brentkirby
brentkirby / divs.html
Last active Dec 15, 2015
Susy Grid Helper
View divs.html
<div id='grid'><div id='baseline_grid'></div></div>
@brentkirby
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
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
:sources:
- http://gems.rubyforge.org/
- http://gemcutter.org
: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
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
end
return name
end