Skip to content

Instantly share code, notes, and snippets.

View cbandy's full-sized avatar

Chris Bandy cbandy

View GitHub Profile
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@johnwards
johnwards / MessageLogger.php
Created August 1, 2011 11:14
Testing Swiftmailer in a Silex app
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@cbandy
cbandy / gist:1360674
Last active September 28, 2015 01:07
git pre-commit hook
#!/bin/sh
# Run tools on files in the index
git diff --cached --name-status \
| awk '$1 != "D" && $1 != "R" { $1 = ""; print }' \
| git checkout-index --stdin --temp \
| while read tmp orig
do
case $orig in
*.php)
require "money"
class Decorator < BasicObject
undef_method :==
def initialize(component)
@component = component
end
def method_missing(name, *args, &block)
@ziadoz
ziadoz / awesome-php.md
Last active May 10, 2024 15:06
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
@pbabik
pbabik / getfeature.php
Created March 21, 2012 10:22 — forked from bmcbride/postgis_geojson.php
PHP PostGIS to GeoJSON - with BBOX query
<?php
/**
* PostGIS to GeoJSON
* Query a PostGIS table or view and return the results in GeoJSON format, suitable for use in OpenLayers, Leaflet, etc.
*
* @param string $bbox Bounding box of request *REQUIRED*
* @param string $geotable The PostGIS layer name *REQUIRED*
* @param string $geomfield The PostGIS geometry field *REQUIRED*
* @param string $srid The SRID of the returned GeoJSON *OPTIONAL (If omitted, EPSG: 4326 will be used)*
@alanq
alanq / mt.rb
Created May 16, 2012 15:18
DCI in ruby without injection - MoneyTransfer example
-----------------------------------------
Boilerplate code (in rails_app_root/lib)
-----------------------------------------
module ContextAccessor
def context
Thread.current[:context]
end
end
@mbj
mbj / external_aequitas_validator.rb
Created July 20, 2012 10:34
Use aequitas as external validator
module ExternalValidator
def self.included(descendant)
descendant.class_eval do
InstanceMethods
end
end
module InstanceMethods
def initialize(object)
@object = object
# Git Navigation
#
# By Hannes Tydén <hannes@tyden.name> @pht
#
# Navigate backwards and forwards in your Git history.
#
# Inspired by https://twitter.com/avdi/status/292057753088827392
#
# Tested on
# zsh 5.0.2 (x86_64-apple-darwin12.2.1)
@igor-alexandrov
igor-alexandrov / gist:6942754
Created October 11, 2013 22:05
Complete example of how to map association from Sequel::Model to AR. Eager loading works like a charm!
class Tour < Sequel::Model
many_to_one :vendor_pansion,
:dataset => proc{ Vendor::Pansion.where(:id => self.vendor_pansion_id) },
:reciprocal => nil, :class => 'Vendor::Pansion',
:eager_loader => (proc do |opts|
opts[:rows].each{ |object| object.associations[:vendor_pansion] = nil }
Vendor::Pansion.where(:id => opts[:id_map].keys).each do |vendor_pansion|
if tours = opts[:id_map][vendor_pansion.id]
tours.each do |tour|