Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
=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') |
<?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. | |
*/ |
#!/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) |
Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
<?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)* |
----------------------------------------- | |
Boilerplate code (in rails_app_root/lib) | |
----------------------------------------- | |
module ContextAccessor | |
def context | |
Thread.current[:context] | |
end | |
end |
module ExternalValidator | |
def self.included(descendant) | |
descendant.class_eval do | |
InstanceMethods | |
end | |
end | |
module InstanceMethods | |
def initialize(object) | |
@object = object |
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| |