Skip to content

Instantly share code, notes, and snippets.

View t7y's full-sized avatar
🏠
Working from home

Jerry Tian t7y

🏠
Working from home
View GitHub Profile
@t7y
t7y / Octopus gemfile
Created March 11, 2011 19:03
Octopus gemfile for octopus_sharding_example that doesn't work
source 'http://rubygems.org'
# gem 'rails', '3.0.0.beta4'
gem 'rails', '3.0.4'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem "warden", '0.10.7'
gem "devise", '1.1.rc2'
@t7y
t7y / Gemfile
Created March 11, 2011 22:25
postgres database.yml file for sample app
source :rubygems
gem 'rails', '3.0.4'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
gem 'ar-octopus', :git => 'git://github.com/tchandy/octopus.git', :require => "octopus"
payload:
{\"permalink\":null,\"title\":null,\"suite101_article_id\":null,\"cookie_id\":null,\"date\":\"2011-03-17T18:51:31Z\",\"referrer_url\":\"\",\"writer_id\":null}"
exception:
Validation failed: Title can't be blank, Title can't be blank, Title is too short (minimum is 3 characters), Suite101 article can't be blank, Suite101 article is not a number, Permalink can't be blank, Permalink is too short (minimum is 3 characters), Writer can't be blank, Writer is not a number, Cookie can't be blank, Cookie is too short (minimum is 3 characters)
/var/cache/engineyard/ruby/1.8/gems/activerecord-3.0.4/lib/active_record/validations.rb:49:in `save!'
/var/cache/engineyard/ruby/1.8/gems/activerecord-3.0.4/lib/active_record/attribute_methods/dirty.rb:30:in `save!'
/var/cache/engineyard/ruby/1.8/gems/activerecord-3.0.4/lib/active_record/transactions.rb:245:in `save!'
/var/cache/engineyard/ruby/1.8/gems/activerecord-3.0.4/lib/active_record/transactions.rb:292:in `with_transaction_returning_status'
/var/cache/engineyard/r
tm23-s00155:31555 on PAGE_VIEW at just now Retry
Arguments
"{\"permalink\":\"http://www.suite101.com/content/outdoor-living-local-garden-events-sponsored-by-proven-winners-a341537\",\"title\":\"Outdoor%20Living%20Local%20Garden%20Events%20Sponsored%20by%20Proven%20Winners\",\"suite101_article_id\":\"341537\",\"cookie_id\":\"B3C1FEF4-F263-8014-B61D523352991FF6\",\"date\":\"2011-03-17T19:03:40Z\",\"referrer_url\":\"http://www.suite101.com/content/outdoor-living-local-garden-events-sponsored-by-proven-winners-a341537\",\"writer_id\":\"612880\"}"
Exception
ActiveRecord::RecordInvalid
Error
Validation failed: Suite101 article has already been taken
/var/cache/engineyard/ruby/1.8/gems/activerecord-3.0.4/lib/active_record/validations.rb:49:in `save!'
/var/cache/engineyard/ruby/1.8/gems/activerecord-3.0.4/lib/active_record/attribute_methods/dirty.rb:30:in `save!'
ActiveRecord::RecordNotUnique Error
PGError: ERROR: duplicate key value violates unique constraint "unq_articles" DETAIL: Key (suite101_article_id)=(114849) already exists. : INSERT INTO "articles" ("title", "created_at", "writer_id", "updated_at", "permalink", "suite101_article_id") VALUES ('Earthquake%20Preparedness%20for%20Children', '2011-03-18 21:33:40.058928', 667582, '2011-03-18 21:33:40.058928', 'http://www.suite101.com/content/earthquake-preparedness-for-children-a114849', 114849) RETURNING "id"
@t7y
t7y / gist:967030
Created May 11, 2011 18:38
table partition
SET constraint_exclusion = on;
EXPLAIN (ANALYZE ON, BUFFERS ON) select * from daily_keyphrase_views_main WHERE writer_id = '585144' AND date BETWEEN '2011-01-01' AND '2011-01-31' AND partition_id = (585144 % 41);
Result (cost=0.00..16912.91 rows=220703 width=71) (actual time=857.574..4492.705 rows=218272 loops=1)
Buffers: shared read=3275
-> Append (cost=0.00..16912.91 rows=220703 width=71) (actual time=857.572..4405.989 rows=218272 loops=1)
Buffers: shared read=3275
-> Seq Scan on daily_keyphrase_views_main (cost=0.00..12.60 rows=1 width=556) (actual time=0.001..0.001 rows=0 loops=1)
Filter: ((date >= '2011-01-01'::date) AND (date <= '2011-01-31'::date) AND (writer_id = 585144) AND (partition_id = 33))
@t7y
t7y / postfromgooglereader.rb
Created September 12, 2011 18:52 — forked from danwoolley/postfromgooglereader.rb
Post from Google Reader to Wordpress blog
#!/usr/local/bin/ruby
# Get from your personal Google Reader public share.
# Post to your WordPress blog.
# Written by Dan Woolley on 9/8/07 for http://tzetzefly.com
# Command line: ruby postfromgooglereader.rb <post_type> <days_back>
# where <post_type> is 'draft', 'live', or 'test' (default is draft)
# and <days_back> is number of days back to get from Google Reader (default is 1)
@t7y
t7y / install-ruby-debug-ruby-1.9.3.sh
Created April 27, 2012 21:07 — forked from rmoriz/install-ruby-debug-ruby-1.9.3.sh
ruby-debug in ruby-1.9.3-p194 and rbenv
#!/bin/bash
cd /tmp
wget http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
wget http://rubyforge.org/frs/download.php/74596/ruby_core_source-0.1.5.gem
wget http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
wget http://rubyforge.org/frs/download.php/63094/ruby-debug19-0.11.6.gem
export RBENV_INCLUDE=$HOME/.rbenv/versions/1.9.3-p194/include/ruby-1.9.1/ruby-1.9.3-p194
gem install archive-tar-minitar
# config/initializers/redcarpet.rb
class ActionView::Template
class Redcarpet < Handler
include Handlers::Compilable
def compile template
::Redcarpet.new(template.source).to_html.inspect
end
end