This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module InterruptibleSleep | |
def interruptible_sleep(seconds) | |
@_sleep_check, @_sleep_interrupt = IO.pipe | |
IO.select([@_sleep_check], nil, nil, seconds) | |
end | |
def interrupt_sleep | |
@_sleep_interrupt.close if @_sleep_interrupt | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//set up pods::find parameters to limit to 5 items | |
$param = array( | |
'limit' => 5, | |
); | |
//create pods object | |
$pods = pods('pod_name', $params ); | |
//check that total values (given limit) returned is greater than zero | |
if ( $pods->total() > 0 ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
/* | |
* Script that scrapes google front page | |
* Usage: ./google [<query>] | |
* e.g. ./google hacker news | |
*/ | |
import ( | |
"fmt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :generate do | |
desc 'Generate a timestamped, empty Sequel migration.' | |
task :migration, :name do |_, args| | |
if args[:name].nil? | |
puts 'You must specify a migration name (e.g. rake generate:migration[create_events])!' | |
exit false | |
end | |
content = "Sequel.migration do\n up do\n \n end\n\n down do\n \n end\nend\n" | |
timestamp = Time.now.to_i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Add the new tsvector column | |
ALTER TABLE articles ADD COLUMN tsv tsvector; | |
-- Create a function that will generate a tsvector from text data found in both the | |
-- title and body columns, but give a higher relevancy rating 'A' to the title data | |
CREATE FUNCTION articles_generate_tsvector() RETURNS trigger AS $$ | |
begin | |
new.tsv := | |
setweight(to_tsvector('pg_catalog.english', coalesce(new.title,'')), 'A') || | |
setweight(to_tsvector('pg_catalog.english', coalesce(new.body,'')), 'B'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Media Queries in Sass 3.2 | |
// | |
// These mixins make media queries a breeze with Sass. | |
// The media queries from mobile up until desktop all | |
// trigger at different points along the way | |
// | |
// And important point to remember is that and width | |
// over the portrait width is considered to be part of the | |
// landscape width. This allows us to capture widths of devices | |
// that might not fit the dimensions exactly. This means the break |
NewerOlder