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
| def render_partial(template,locals=nil) | |
| if template.is_a?(String) || template.is_a?(Symbol) # check if the template argument is a string or symbol | |
| template=('_' + template.to_s).to_sym # make sure the template is a symbol | |
| else # otherwise is must be an object | |
| locals=template # set the object as the local variable | |
| template=template.is_a?(Array) ? ('_' + template.first.class.to_s.downcase).to_sym : ('_' + template.class.to_s.downcase).to_sym #extract the template name from the object name | |
| end | |
| if locals.is_a?(Hash) # this means that the locals have been set manually, so just render the template using those variables | |
| erb(template,{:layout => false},locals) | |
| elsif locals # otherwise, the locals will be the same name as the partial |
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' | |
| get '/' do | |
| "I did it my way!" | |
| 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 'sinatra' | |
| require 'aws/s3' | |
| get '/' do | |
| haml :upload | |
| end | |
| post '/' do | |
| unless params[:file] && (tmpfile = params[:file][:tempfile]) && (name = params[:file][:filename]) | |
| return haml(:upload) |
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
| set :uid => "123" | |
| set :token => "kljkl26adFGGHHklfha77676sdHHTYklfj" | |
| use OmniAuth::Builder do | |
| provider :twitter, 'XXX', 'XXXX' | |
| end | |
| helpers do | |
| def admin? | |
| session[ settings.uid ] == settings.token |
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
| %w[sinatra dm-core dm-migrations slim sass].each{ |lib| require lib } | |
| DataMapper.setup(:default, ENV['DATABASE_URL'] || File.join("sqlite3://",settings.root, "development.db")) | |
| class Robot | |
| include DataMapper::Resource | |
| property :id, Serial | |
| property :top, Integer, :default => proc { 1+rand(6) } | |
| property :middle, Integer, :default => proc { 1+rand(4) } | |
| property :bottom, Integer, :default => proc { 1+rand(5) } |
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 'sinatra' | |
| require 'slim' | |
| require 'sass' | |
| require 'data_mapper' | |
| DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/development.db") | |
| class Task | |
| include DataMapper::Resource | |
| property :id, Serial | |
| property :name, String, :required => true | |
| property :completed_at, DateTime |
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
| %w[sinatra dm-core dm-migrations slim sass].each{ |lib| require lib } | |
| DataMapper.setup(:default, ENV['DATABASE_URL'] || File.join("sqlite3://",settings.root, "development.db")) | |
| class Robot | |
| include DataMapper::Resource | |
| property :id, Serial | |
| property :top, Integer, :default => proc { |m,p| 1+rand(6) } | |
| property :middle, Integer, :default => proc { |m,p| 1+rand(4) } | |
| property :bottom, Integer, :default => proc { |m,p| 1+rand(5) } |
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 'sinatra' | |
| require 'data_mapper' | |
| require 'slim' | |
| require 'digest/sha1' | |
| DataMapper.setup(:default, ENV['DATABASE_URL'] || File.join("sqlite3://",settings.root, "development.db")) | |
| class Note | |
| include DataMapper::Resource | |
| property :id, Serial |
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
| $orange:#D78123; | |
| $blue:#1E1641; | |
| $green:#02d330; | |
| $grey: #999; | |
| $background:$blue; | |
| $logo-color:white; | |
| $logo-font:"Anton",sans-serif; | |
| $heading-color:$orange; | |
| $heading-font:"Anton",sans-serif; |
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
| def play(i) | |
| m=%w(Rock Paper Scissors);m[c=rand(3)]+?,+%w(Draw Win Lose)[((m.index(i)||c-1)-c)%3] | |
| end |
OlderNewer