Skip to content

Instantly share code, notes, and snippets.

View seouri's full-sized avatar

Joon Lee seouri

  • Activate Care
  • Boston, MA
View GitHub Profile
@seouri
seouri / gist:71852
Created February 28, 2009 03:16 — forked from ryanb/gist:71618
class Tag
has_many :taggings
named_scope :important, :include => { :taggings => :important }
end
class Tagging
belongs_to :tag
belongs_to :posts
# uses a string 'flag' column but could be changed to a boolean important
sub read_savedrecs {
my $dir = shift;
my (@rec, @head);
foreach my $f (<$dir/savedrecs*.txt>) {
my @file = read_file($f);
my $head = shift @file;
@head = @$head unless $#head > 0;
push @rec, @file;
}
my %head_idx;
sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
<link rel="stylesheet" type="text/css" media="print" href="print.css"/>
a[href]:after { content: " (" attr(href) ") "; }
SELECT *,(((acos(sin((".$latitude."*pi()/180)) * sin((`lat`*pi()/180))+cos((".$latitude."*pi()/180)) * cos((`lat`*pi()/180)) * cos(((".$longitude."- `lng`)*pi()/180))))*180/pi())*60*1.1515*1.609344) as distance FROM `items` ORDER BY distance;
@seouri
seouri / url_dsl.rb
Created December 14, 2009 19:18 — forked from defunkt/url_dsl.rb
require 'open-uri'
# url dsl -- the ultimate url dsl!
#
# You just can't beat this:
#
# $ irb -r url_dsl
# >> include URLDSL
# => Object
# >> http://github.com/defunkt.json
@seouri
seouri / Gemfile .rb
Created December 14, 2009 19:32 — forked from woodie/Gemfile .rb
# Critical default settings:
disable_system_gems
disable_rubygems
bundle_path ".gems/bundler_gems"
# List gems to bundle here:
gem "rails", "3.0.pre", :git => "git://github.com/rails/rails.git"
gem "arel", :git => "git://github.com/rails/arel.git"
gem "i18n"
gem "dm-appengine"
@seouri
seouri / gist:257297
Created December 15, 2009 21:01
Calculate database size
SELECT table_schema "DB Name", round(sum( data_length + index_length) / 1024 / 1024, 0) "DB Size in MB" FROM information_schema.TABLES where table_schema = "YOUR_DB_NAME";
development: &global_settings
database: textual_development
host: 127.0.0.1
port: 27017
test:
database: textual_test
<<: *global_settings
production:

Rails 2.3.5 on App Engine

We assumed Rails 2 would never work without rubygems, and we committed to gem bunlder for JRuby on App Engine, so we were waiting for Rails 3. Fortunately, Takeru Sasaki was able to patch the Rails 2.3.5 calls to rubygems, and now we have it working. Rails 2.3.5 currently spins up several seconds faster than Rails 3, and just a few seconds behind Sinatra.

Install the Development Environment

The gems for the development environment include a pre-release appengine-tools gem that provides a pre-release version of jruby-rack.

sudo gem install google-appengine
sudo gem install appengine-tools --pre