Skip to content

Instantly share code, notes, and snippets.

View stevedev's full-sized avatar

Steve Thompson stevedev

View GitHub Profile
@stevedev
stevedev / gist:6643892
Created September 20, 2013 21:05
How to Klass
class User < ActiveRecord::Base;end
klass = 'User'
Kernel.const_get(klass)
# => User(id: integer)
gem install less -v 2.3.3 --no-ri --no-rdoc
<?php
// Interface Option 1:
$this->addRowClass( 'active', function($row) {
if ($row->status == 'active') {
return true;
} else {
return false;
}
} );
u = User.find_by_username 'issuer'
u.notifications.limit(1).size
# => 1
u.notifications.group(:record_class).limit(1).size
# => {"Posting"=>2}

Braces

Don't use newline braces.

<?php

// Good:

if ( $foo ) { 
<?php
class Curl {
const HEAD = 'POST';
const GET = 'GET';
const POST = 'POST';
const PUT = 'PUT';
const DELETE = 'DELETE';
const LOCK = 'LOCK';
const UNLOCK = 'UNLOCK';
$foos = array('foo', 'foo');
function bar(&$array) { // act the array. don't need to return it; }
$result = bar($foos);
first_name last_name company_name address city province postal phone1 phone2 email web latitude longitude
Queenie Kramarczyk Goeman Wood Products Inc 47 Garfield Ave Swift Current SK S9H 4V2 306-421-5793 306-302-7591 [email protected] http://www.goemanwoodproductsinc.com 50.2832298 -107.7843475
Lea Steinhaus James, Christopher Esq 80 Maplewood Dr #34 Bradford ON L3Z 2S4 905-618-8258 905-651-3298 [email protected] http://www.jameschristopheresq.com 43.1741066 -80.248848
Paola Vielma Congress Title 58 Hancock St Aurora ON L4G 2J7 905-456-1117 905-263-7711 [email protected] http://www.congresstitle.com 43.9731255 -79.4274063
Danilo Pride Harry L Adams Incorporated 6857 Wall St Red Deer AB T4R 2H5 403-212-4945 403-888-9985 [email protected] http://www.harryladamsincorporated.com 52.2699814 -113.7584381
Apolonia Warne Kitchen People 3 E 31st St #77 Fredericton NB E3G 0A3 506-978-1488 506-221-1874 [email protected] http://www.kitchenpeople.com 45.9478607 -66.6
@stevedev
stevedev / gist:8426807
Created January 14, 2014 22:07
Unsetting array elements safely in PHP.
<?php
$my_array = array( 'foo', 'bar', 'baz' );
// $key is index
foreach( $array as $key => $val ) {
if ($val == 'foo') {
unset( $key);
}
}
describe "testing mah scopes" do
before do
People.destroy_all
end
let!(:senior) { create(:person, age: 77) }
let!(:teen) { create(:person, age: 16) }
describe ".seniors" do
it "should return all seniors" do