Skip to content

Instantly share code, notes, and snippets.

View brett-richardson's full-sized avatar

Brett Richardson brett-richardson

View GitHub Profile
@brett-richardson
brett-richardson / form.scss
Created November 6, 2011 14:05
BrewFans form SASS
form{
fieldset{
padding:$baseline*2 0 0 0; margin:$baseline*2 $baseline*2 $baseline*3 0;
border:0; border-top:1px solid rgba( 140, 140, 140, 0.35 );
legend{
position:relative; top:-2px; padding-right:$gutter;
color:$light_grey; font-weight:bold; font-size:$fsize_large; line-height:$lsize_large;
}
}
@import '_variables';
.node-type-resume{
h1{
margin-top:$baseline !important;
.picture{ display:inline-block; margin-right:$gutter; }
a.edit_my_resume, a.back_to_profile{
@brett-richardson
brett-richardson / gist:1406212
Created November 29, 2011 20:01
vc_resumes_ajax_submit
function vc_resumes_ajax_submit(){
module_load_include( 'inc', 'vc_resumes', 'vc_resumes.fetch' );
module_load_include( 'inc', 'node', 'node.pages' );
global $user;
// dpm( $_REQUEST );
$form_id = $_REQUEST['form_id'];
$type = explode( '_', $form_id );
$type = $type[0]; /* This will not work with node types with a _ in their name */
ApplicationController < ActionController::Base
# Fetch the best location available to the app at the time
def fetch_location
if params[:location].present? # Geocode the manual location input
session[:manual_location] = Geokit::Geocoders::MultiGeocoder.geocode( params[:location] )
end
if session[:manual_location].present?
session[:manual_location]
@brett-richardson
brett-richardson / combined_enumerator.rb
Last active January 3, 2016 05:49
Combined Lazy Enumerator in Ruby 1.9
# The aim of this class is to take a number of ordered enumerators and then
# emit their values in ascending order.
#
# Some assumptions:
# * The enumerators passed in emit their values in ascending order.
# * The enumerators emit values which are Comparable[1] with each other.
# * The enumerators can be finite *or* infinite.
#
# This requires Ruby 1.9. The Enumerator[2] documentation might be useful.
#
class One
test: -> console.log 'test'
class @Two
test: -> console.log 'test'
require 'phony'
Phone = Struct.new(:value) do
alias_method :value, :to_s
def initialize(value)
@value = value.to_s
end
class User
active_ingredients do
phone Phone, validate: true, unique: true
address Address, validate: true
website Url, validate: true
end
end
require 'phony'
def create
card_saver = Billing::SaveCreditCard.new(user: current_user, card: card_params)
responder = respond do |r|
r.success { render :success }
r.failure { render :failure }
end
card_saver.call(responder)
end
class CreditCardController < ApplicationController
def create
respond_with CreditCardCreator.new(params)
end
end
class Grouper::Responder
delegate :errors, to: :resource
def resource