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
| <%= form_for(@foo) do |f| %> | |
| <%= f.fields_for :bars do |b| %> | |
| <%= b.text_field :name %> | |
| <% end %> | |
| <%= f.submit "+", :name => "actions[add_bar]" %> | |
| <div class="actions"> | |
| <%= f.submit %> | |
| </div> |
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
| defaults write com.macromates.textmate OakShellVariables -array-add "{ enabled = 1; variable = TM_RUBY; value = '$(which rvm-auto-ruby)'; }" |
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
| constraints :protocol => "https" do | |
| resources :gizmos | |
| end | |
| constraints :protocol => "http" do | |
| match "/(*path)" => redirect { |p, r| URI(r.url).tap { |u| u.scheme = "https" }.to_s } | |
| 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 "digest/md5" | |
| require "thread" | |
| files = Dir["**/*"] | |
| files_mutex = Mutex.new | |
| hashes = Hash.new { |h, k| h[k] = [] } | |
| hashes_mutex = Mutex.new | |
| processors = `sysctl -n hw.logicalcpu`.to_i | |
| processors.times.map do |i| |
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 "socket" | |
| a, b = Socket.pair(:INET, :STREAM) | |
| a << "abc\n" | |
| b.gets # => "abc\n" | |
| b << "abc\n" | |
| a.gets # => "abc\n" |
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
| resources :things, :glob_id => true |
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
| var fs = require("fs"); | |
| var http = require("http"); | |
| var https = require("https"); | |
| var express = require("express"); | |
| var app = express.createServer(); | |
| var httpsOptions = { | |
| key: fs.readFileSync(process.env.HOME + "/localhost-key.pem"), | |
| cert: fs.readFileSync(process.env.HOME + "/localhost-cert.pem") |
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 InlineFormsController < ApplicationController | |
| def self.cancan_enabled? | |
| return @cancan_enabled if defined?(@cancan_enabled) | |
| @cancan_enabled = begin | |
| ::Ability && true | |
| rescue NameError | |
| false | |
| end | |
| 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 "cgi" | |
| require "net/http" | |
| require "uri" | |
| def error(msg, code = -1) | |
| puts(msg) | |
| exit(code) | |
| end | |
| def add_gist_file(gist, number, name, content, ext = File.extname(name)) |
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 ApplicationModel < ActiveRecord::Base | |
| self.abstract_class = true | |
| class_attribute :formatted_attributes_options | |
| self.formatted_attributes_options = {} | |
| def self.formatted_attributes(*attributes) | |
| options = attributes.extract_options! | |
| attributes.each do |attribute| | |
| formatted_attributes_options[attribute] = options |