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
require 'rubygems' | |
require 'sinatra' | |
class Handler | |
attr_reader :context | |
def initialize(context) | |
@context = context | |
end | |
def render | |
unless context.params[:username].nil? |
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
<html> | |
<head> | |
<title>CanJS Firebase chat demo</title> | |
<script type='text/javascript' src='http://static.firebase.com/demo/firebase.js'></script> | |
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script> | |
<script type="text/javascript" src="http://retro.github.com/javascripts/can.jquery.js"></script> | |
<link rel='stylesheet' type='text/css' href='http://www.firebase.com/css/example.css'> | |
</head> | |
<body> | |
<div id='messagesDiv'></div> |
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
require 'rubygems' | |
require 'rmagick' | |
require 'color_namer' | |
img = Magick::ImageList.new('photo.jpg') | |
img.resize_to_fit!(500) # resize the image to have faster quantization | |
quantized = img.quantize(16) # quantize the photo to reduce number of colors | |
img.destroy! # prevent memory leaks |
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
require 'rubygems' | |
require 'mongo_mapper' | |
require 'active_support' | |
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!( | |
:default => "%m/%d/%Y" | |
) | |
class Time | |
def self.to_mongo(value) |
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
<?xml version='1.0' encoding='utf-8' ?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html" /> | |
<title>jQuery Column Tree Table</title> | |
<link rel="stylesheet" href="http://jqueryui.com/themeroller/css/parseTheme.css.php?ffDefault=Lucida+Grande,+Lucida+Sans,+Arial,+sans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=5px&bgColorHeader=5c9ccc&bgTextureHeader=12_gloss_wave.png&bgImgOpacityHeader=55&borderColorHeader=4297d7&fcHeader=ffffff&iconColorHeader=d8e7f3&bgColorContent=fcfdfd&bgTextureContent=06_inset_hard.png&bgImgOpacityContent=100&borderColorContent=a6c9e2&fcContent=222222&iconColorContent=469bdd&bgColorDefault=dfeffc&bgTextureDefault=02_glass.png&bgImgOpacityDefault=85&borderColorDefault=c5dbec&fcDefault=2e6e9e&iconColorDefault=6da8d5&bgColorHover=d0e5f5&bgTextureHover=02_glass.png&bgImgOpacityHover=75&borderColorHover=79b7e7&fcHover=1d5987&iconColo |
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 Foo < Sinatra::Base | |
@@server_instance = nil | |
def self.run!(options={}) | |
set options | |
handler = detect_rack_handler | |
handler_name = handler.name.gsub(/.*::/, '') | |
puts "== Sinatra/#{Sinatra::VERSION} has taken the stage " + | |
"on #{port} for #{environment} with backup from #{handler_name}" unless handler_name =~/cgi/i | |
handler.run self, :Host => host, :Port => port do |server| | |
@@server_instance = server |
NewerOlder