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{rubygems sinatra haml}.each {|r| require r} | |
configure do | |
set :views, "#{File.dirname(__FILE__)}/views" | |
end | |
get '/' do | |
haml "Hello World!" | |
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
require 'rubygems' | |
require 'sinatra' | |
get '/' do | |
@files = Dir['public/*'].map {|f| File.basename(f) } | |
erb :index | |
end | |
post '/upload' do | |
filename = params[:file][:filename] |
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 'index' | |
run Sinatra::Application |
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 'index' | |
run Sinatra::Application |
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
$ clarity --username=admin --password=secret --port=8080 logs/ | |
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- clarity/parsers/time_parser (LoadError) | |
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' | |
from /usr/local/lib/ruby/gems/1.8/gems/clarity-0.9.5/lib/clarity.rb:10 | |
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' | |
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' | |
from /usr/local/lib/ruby/gems/1.8/gems/clarity-0.9.5/bin/clarity:7 | |
from /usr/local/bin/clarity:19:in `load' | |
from /usr/local/bin/clarity:19 |
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
%a{:href => 'http://github.com/rodrigo3n'}< | |
%img{:style => 'position: absolute; top: 0; right: 0; border: 0;', :src => 'http://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png', :alt => 'Fork me on GitHub'} |
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
text = 'I like cats' | |
['cat', 'dog', 'mouse'].any? { |word| text =~ /#{Regexp.escape(word)}/ } # => true |
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
# provides a slick way to add classes inside haml attribute collections | |
# | |
# examples: | |
# %div{add_class("current")} | |
# #=> adds the "current" class to the div | |
# | |
# %div{add_class("current", :if => current?)} | |
# #=> adds the "current" class to the div if current? method | |
# | |
# %div{add_class("highlight", :unless => logged_in?)} |
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
sudo apt-get install build-essential zlib1g zlib1g-dev zlibc libruby1.9 libxml2 libxml2-dev libxslt-dev | |
sudo apt-get build-dep ruby1.9 | |
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p376.tar.gz | |
untar it, open ext/Setup and uncomment zlib | |
./configure | |
make | |
sudo make install |
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
@contact = Contact.find params[:id] | |
@contact.attributes = params[:contact] | |
if params[:is_supplier] == '1' | |
@contact.type = 'supplier' | |
elsif params[:is_supplier] == '0' | |
@contact.type = 'customer' | |
end | |
if @contact.save |
OlderNewer