Yeah, Ruby is awesome:
# Without underscore
[1, 2, 3].map { |i| i + 1 }
[{ name: "Sasha" }, { name: "Tori" }].map { |actress| actress[:name] }
# With underscore
# Ruby way fail | |
# Implementation of a simple method to convert seconds to time format (03:44:23) | |
require "benchmark" | |
seconds = 45020 | |
hours = seconds / 3600 | |
minutes = seconds / 60 % 60 |
Sass::Plugin.options[:template_location] = "#{Rails.root}/app/styles" => "#{Rails.root}/tmp/stylesheets" | |
Rails.configuration.middleware.insert_after "Sass::Plugin::Rack", "Rack::Static", :urls => ["/stylesheets"], :root => "#{Rails.root}/tmp" |
#!/usr/bin/env ruby | |
require "rubygems" | |
require "codeplane" | |
require "optparse" | |
Codeplane.configure do |config| | |
ARGV.options do |opts| | |
opts.on("-u", "--user=username", String) { |val| config.username = val } | |
opts.on("-p", "--api-key=key", String) { |val| config.api_key = val } |
Run with while true; do clear; ruby a.rb | tee b.rb; sleep 1; mv -f b.rb a.rb; done
gem 'devise', '~> 1.1.2' | |
gem 'cancan' | |
generate 'devise:install' |
apply 'http://gist.github.com/raw/562316/1c45aa71f17491c36d74123abf7886b9a08daddf/basic_stack.rb' | |
apply 'http://gist.github.com/raw/562316/ed62987b05de614c9b37062f410a3a48e4e776f2/brazilian_app.rb' | |
apply 'http://gist.github.com/raw/562316/56326e84aa23d9ac1cc227f8aa8ae178f2d4d6b5/cleanup.rb' | |
apply 'http://gist.github.com/raw/562316/7406f13bf9d9b9d467f3d00a26b56a960685beeb/rspec.rb' | |
apply 'http://gist.github.com/raw/562316/ad35700fa4f3cf9163b0149b19beeba0407ea325/cucumber.rb' | |
apply 'http://gist.github.com/raw/562316/4cc84eb5ea709c2f0ea76783157548a660a374a2/w3.rb' |
(function(angular) { | |
function underlineToCamelCase(string) { | |
return string.replace(/(\_[a-z])/g, function(match) { | |
return match.toUpperCase().replace("_", ""); | |
}); | |
} | |
function convertToCamelCaseObject(object) { | |
if (typeof object != "object") return object; | |
require "ostruct" | |
module FormsHelper | |
def search_form_for(object_name, options={}, &block) | |
options[:html] = {:method => :get}.update(options[:html] || {}) | |
object = OpenStruct.new(params[object_name]) | |
form_for(object_name, object, options, &block) | |
end | |
end |
class CQM < ActiveRecord::Base | |
self.abstract_class = true | |
establish_connection( | |
:adapter => "mysql2", | |
:host => "localhost", | |
:username => "root", | |
:password => "root", | |
:database => "cqm_development" | |
) |