Skip to content

Instantly share code, notes, and snippets.

Cody Caughlan ruckus

Block or report user

Report or block ruckus

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ruckus
ruckus / gist:3989311
Created Oct 31, 2012
tumblr theme with fixed footer
View gist:3989311
<!DOCTYPE html>
<!--
High Res Theme 1.1.9 -- 26 September 2012
(c) 2011-2012 Justin Ouellette, all rights reserved
http://highrestheme.tumblr.com/
-->
<html>
<head>
<title>{Title}{block:PostSummary} - {PostSummary}{/block:PostSummary}</title>
<meta name="tumblr-theme" content="30257" />
@ruckus
ruckus / AppController.php
Created Oct 25, 2012
CakePHP Request logging ala Rails
View AppController.php
class AppController extends Controller {
function beforeFilter() {
$this->capture_request_head_for_log();
}
/*
Log some basic basic details of the HTTP Request:
Started GET "/users/lost" for 127.0.0.1 at 2012-10-24 19:18:25 -0700
View 20120925150949_create_foo_table
// Generate the timestamp for the filename from the command line like:
// php -r "echo date('YmdHis', time());"
UP
--
CREATE TABLE foo (
id int(11) PRIMARY KEY AUTO_INCREMENT,
first_name varchar(64)
);
@ruckus
ruckus / gist:3124445
Created Jul 16, 2012
Rails Single Table Inheritance example
View gist:3124445
create_table :media_items do |t|
t.string :type, :null => false, :limit => 32
t.string :name
t.timestamps
end
class MediaItem < ActiveRecord::Base
validates_presence_of :kind
end
View Account.m
#import "Account.h"
#import "JSONKit.h"
@implementation Account
@synthesize name = _name;
@synthesize accountId = _accountId;
@synthesize initial = _initial;
@synthesize code = _code;
View gist:2561258
SELECT varietals.*, ts_rank_cd(varietals.search_content, plainto_tsquery('vinosmith', 'gruner')) as rank
FROM varietals WHERE varietals.search_content @@ plainto_tsquery('vinosmith', 'gruner')
ORDER BY rank DESC limit 25
=> [#<Varietal id: 657, name: "Grüner Veltliner" .. ]
View gist:2561158
CREATE EXTENSION unaccent;
CREATE TEXT SEARCH CONFIGURATION vinosmith ( COPY = english );
ALTER TEXT SEARCH CONFIGURATION vinosmith ALTER MAPPING FOR hword, hword_part, word WITH unaccent, english_stem;
CREATE TRIGGER contacts_search_content_trigger BEFORE INSERT OR UPDATE
ON contacts FOR EACH ROW EXECUTE PROCEDURE
tsvector_update_trigger(search_content, 'public.vinosmith', title, name, phone, fax, email, mobile_phone);
View gist:2513242
2012-04-27T21:10:44Z 530 TID-owb1ckq7w INFO: Booting sidekiq 1.1.4 with Redis at redis://localhost:6379/6
2012-04-27T21:10:44Z 530 TID-owb1ckq7w INFO: Running in ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0]
2012-04-27T21:10:44Z 530 TID-owb1ckq7w DEBUG: {:queues=>["default"], :concurrency=>25, :require=>".", :environment=>"development", :timeout=>8, :enable_rails_extensions=>true}
2012-04-27T21:10:44Z 530 TID-owb099rks INFO: Starting processing, hit Ctrl-C to stop
2012-04-27T21:10:59Z 530 TID-owb14h9wk INFO: IntuitSyncRequest MSG-owb14ha9w start
/Users/codyc/.rvm/gems/ruby-1.9.3-p194@vino/gems/activerecord-3.2.2/lib/active_record/result.rb:30: [BUG] Segmentation fault
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0]
-- Control frame information -----------------------------------------------
View gist:2483945
SELECT contacts.*, ts_rank_cd(contacts.search_content, to_tsquery('purple & drank')) as rank
FROM contacts
WHERE contacts.search_content @@ to_tsquery('purple & drank')
ORDER BY rank DESC
View gist:2483910
CREATE FUNCTION wine_books_search_content_trigger() RETURNS trigger AS $$
begin
new.search_content := (
-- MUST use COALLESCE here if any of these columns can be NULL
SELECT to_tsvector(COALESCE(wine_books.code, '') || ' ' || COALESCE(wine_books.name, '') || ' ' || COALESCE(producers.name, '') || ' ' || COALESCE(varietals.name, '') || COALESCE(wine_books.year::varchar, ''))
FROM wine_books
LEFT OUTER JOIN producers ON producers.id = wine_books.producer_id
LEFT OUTER JOIN varietals ON varietals.id = wine_books.varietal_id
WHERE wine_books.id = new.id);
return new;
You can’t perform that action at this time.