Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
$: << File.join(File.dirname(__FILE__), "..", "lib", "project")
$: << File.join(File.dirname(__FILE__), "..", "lib", "project", "web")
%w( rack sinatra haml sass ).each { |f| require(f) }
get '/' do
@listings = Listing.all
haml :index
end
get '/style' do
header 'Content-Type' => 'text/css; charset=utf-8'
sass :style
## development
== Sinatra has taken the stage on port 4567 for development with backup by Rack::Handler::Mongrel
127.0.0.1 - - [22/Jul/2008 16:49:56] "GET / HTTP/1.1" 404 660 0.0031
127.0.0.1 - - [22/Jul/2008 16:49:56] "GET /sinatra_custom_images/404.png HTTP/1.1" 200 23305 0.0008
## production
== Sinatra has taken the stage on port 4567 for production with backup by Rack::Handler::Mongrel
127.0.0.1 - - [22/Jul/2008 16:50:35] "GET / HTTP/1.1" 200 2 0.0038
127.0.0.1 - - [22/Jul/2008 16:50:35] "GET /favicon.ico HTTP/1.1" 404 18 0.0002
class DateTimeSelector
include TagHelper
POSITIONS = { :year => 1, :month => 2, :day => 3, :hour => 4, :minute => 5, :second => 6 }
def initialize(date, options={})
@date = date
@options = options
@object = @options.delete(:object)
@object_name = @options.delete(:object_name)
def foo
'hi'
end
10.print "HELLO WORLD"
20.goto 10
@gabriel
gabriel / README
Created July 22, 2008 21:11
Ruby script to find iphones
Looks like the JSON feed now only works after 9pm. Thanks Daring Fireball! ;)
# filter flags
ff <- function(f, flags){
## if !all(dim(mat) == dim(flags)) break say "data and flags must have identical dimensions"
for(k in 1:ncol(f)){
idx.flags <- which( flags[,k] < 0 )
f[idx.flags,k] <- NA
cat("Number features filtered on slide ", k, ": ", length(idx.flags), "\n", sep="")
}
f
}
config.action_mailer.smtp_settings = {
:address => "mail.authsmtp.com",
:domain => "famspam.com",
:port => 2525,
:user_name => "user",
:password => "pass",
:authentication => :cram_md5
}
for (int i = 1; i <= 2; i++) {
Category c = new Category();
c.ID = i;
c.IsDefault = i == 1;
c.Name = "Parent" + i.ToString();
c.ParentID = 0;
c.Image = new CategoryImage("thumb", "full");
int subCategoryID = 10 * i;