This file contains hidden or 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/base" | |
require "padrino" | |
class Foo < Sinatra::Base | |
get("/bar") { | |
"Hello world!" | |
} | |
end |
This file contains hidden or 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 "mounter" | |
module FooApp | |
extend Mounter | |
controllers do | |
get "/foo" do | |
"Foo..." | |
end |
This file contains hidden or 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
MyApp.controllers :product do | |
parent :shop, :optional => true | |
parent :category, :optional => true | |
get :show, :with => :id do | |
# generated url: "/(shop/#{params[:shop_id]}/)(category/#{params[:category_id]}/)product/show/#{params[:id]}" | |
# url_for(:product, :show, :id => 10) => "/product/show/10" | |
# url_for(:product, :show, :shop_id => 5, :id => 10) => "/shop/5/product/show/10" | |
# url_for(:product, :show, :shop_id => 5, :category_id => 1, :id => 10) => "/shop/5/category/1/product/show/10" | |
end |
This file contains hidden or 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 Myapp | |
controller :libaries do | |
# ... | |
end | |
controller :book, :parent => :library do | |
before do | |
@lib = Library.find(params[:library_id] rescue nil | |
end |
This file contains hidden or 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> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script> | |
<link href="rotate.css" rel="stylesheet" type="text/css" /> | |
<script type="text/javascript" src="rotate.js"></script> | |
<script type="text/javascript"> | |
$(window).load(function() { | |
startRotator("#rotator"); | |
}) | |
</script> |
This file contains hidden or 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
- if flash.keys.size > 0 | |
.flash-messages | |
- flash.each do |type, message| | |
%div(class="flash-message flash-#{type}")= message |
This file contains hidden or 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
#!/bin/bash | |
# usage: git-setup-home PATH | |
# | |
# It creates 'git' user and group, and prepares given home directory. | |
# By default git home dir is '/var/git'. | |
if [ $1 ] ; then | |
export GIT_HOME=$1 | |
else |
This file contains hidden or 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 'telegraph' | |
before do | |
say "foo" | |
end | |
after(:foo) do | |
say "bar" | |
end |
This file contains hidden or 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
$(':input', '#form_id') | |
.not(':button, :submit, :reset, :hidden') | |
.val('') | |
.removeAttr('checked') | |
.removeAttr('selected'); |
This file contains hidden or 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 Notifier < ActionMailer::Base | |
def self.perform(method, *args) | |
#self.send(method, *args).deliver | |
self.send("deliver_#{method}", *args) | |
end | |
def some_notification(user) | |
# ... | |
end | |