Skip to content

Instantly share code, notes, and snippets.

View stevedev's full-sized avatar

Steve Thompson stevedev

View GitHub Profile
@stevedev
stevedev / gist:9624630
Created March 18, 2014 17:13
double specs, how does it work!?!?
11:12:49 - INFO - Running: spec/models/news_spec.rb
Run options: exclude {:integration=>true, :pdf=>true}
.........
Finished in 0.1104 seconds
9 examples, 0 failures
Coverage report Rcov style generated for RSpec to /Users/sthompson/Sites/ag/coverage/rcov
Run options: exclude {:integration=>true, :pdf=>true}
.........
A total of 62 ROBOTS were logged
Mozilla/5.0 (compatible; Blekkobot; ScoutJet; +http://blekko.com/about/blekkobot) 1 Time(s)
Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) 169 Time(s)
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (FlipboardProxy/1.1; +http://flipboard.com/browserproxy) 1 Time(s)
Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:14.0; ips-agent) Gecko/20100101 Firefox/14.0.1 2 Time(s)
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1; 360Spider 4 Time(s)
Sogou web spider/4.0(+http://www.sogou.com/docs/help/webmasters.htm#07) 10 Time(s)
Twitterbot/1.0 4 Time(s)
Mozilla/5.0 (compatible; coccoc/1.0; +http://help.coccoc.com/) 9 Time(s)
Mozilla/5.0 (compatible; CareerBot/1.1; +http://www.career-x.de/bot.html) 3 Time(s)
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
@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);
}
}
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
$foos = array('foo', 'foo');
function bar(&$array) { // act the array. don't need to return it; }
$result = bar($foos);
<?php
class Curl {
const HEAD = 'POST';
const GET = 'GET';
const POST = 'POST';
const PUT = 'PUT';
const DELETE = 'DELETE';
const LOCK = 'LOCK';
const UNLOCK = 'UNLOCK';

Braces

Don't use newline braces.

<?php

// Good:

if ( $foo ) { 
u = User.find_by_username 'issuer'
u.notifications.limit(1).size
# => 1
u.notifications.group(:record_class).limit(1).size
# => {"Posting"=>2}
<?php
// Interface Option 1:
$this->addRowClass( 'active', function($row) {
if ($row->status == 'active') {
return true;
} else {
return false;
}
} );