Discover gists
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
#!/usr/bin/env ruby | |
$: << File.join(File.dirname(__FILE__), "..", "lib", "project") | |
$: << File.join(File.dirname(__FILE__), "..", "lib", "project", "web") |
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
%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 |
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
## 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 | |
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
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) |
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
def foo | |
'hi' | |
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
10.print "HELLO WORLD" | |
20.goto 10 |
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
Looks like the JSON feed now only works after 9pm. Thanks Daring Fireball! ;) |
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
# 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 | |
} |
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
config.action_mailer.smtp_settings = { | |
:address => "mail.authsmtp.com", | |
:domain => "famspam.com", | |
:port => 2525, | |
:user_name => "user", | |
:password => "pass", | |
:authentication => :cram_md5 | |
} |
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
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; |