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
motorcycle = ({ brand, year } = { brand: 'Unknown', year: "1999" }) -> | |
alert "brand: #{brand}, year: #{year}" | |
motorcycle() | |
#brand: 'Unknown', year: "1999" | |
motorcycle year:"2005", brand:"YAMAHA" | |
#brand: 'YAMAHA', year: 2005 |
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 RunningNumber | |
attr_accessor :prefix, :current | |
def initialize(prefix = 'RUN', current = '000000') | |
@prefix = prefix | |
@current = current | |
end | |
def current | |
@prefix + @current |
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
<body> | |
<div class="container"> | |
<% flash.each do |name, msg| %> | |
<div class="alert alert-<%= name == :notice ? "success" : "error" %>"> | |
<a class="close" data-dismiss="alert">x</a> | |
<%= msg %> | |
</div> | |
<% end %> | |
</div> | |
<!-- Rest of content --> |
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
<%= simple_form_for @record, :html => { :class => 'form-horizontal' } do |f| %> | |
<fieldset> | |
<legend><%= controller.action_name.capitalize %></legend> | |
<%= f.input :title %> | |
<%= f.input :amount %> | |
<%= f.association :category %> | |
<%= f.input :date %> | |
<div class="form-actions"> | |
<%= f.submit nil, :class => 'btn btn-primary' %> |
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
/* | |
... | |
*/ | |
@import "twitter/bootstrap/bootstrap"; | |
body{ padding-top: 60px; } | |
@import "twitter/bootstrap/responsive"; |
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
namespace :db do | |
desc "Erase and fill database" | |
task :populate => :environment do | |
require 'populator' | |
#require 'faker' | |
[Category, Record].each(&:delete_all) | |
Category.populate 10 do |category| | |
category.title = Populator.words(2) |
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
gem 'raphael-rails' | |
gem 'morrisjs-rails' | |
gem 'gon' | |
#... |
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
jQuery -> | |
Morris.Line | |
element: 'chart' | |
data: [ | |
{y: '2012', a: 100} | |
{y: '2011', a: 75} | |
{y: '2010', a: 50} | |
{y: '2009', a: 75} | |
{y: '2008', a: 50} | |
{y: '2007', a: 75} |
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 bash | |
sudo apt-get -y update | |
sudo apt-get --no-install-recommends -y install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev libgdbm-dev ncurses-dev automake libtool bison pkg-config libffi-dev vim | |
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv | |
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build | |
cd |
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 DynamicHash < Hash | |
def []=(key, val) | |
super | |
self.class.class_eval do | |
define_method(key) do | |
self[key] | |
end | |
define_method("#{key}=") do |value| | |
self[key] = value | |
end |