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
| module FormHelper | |
| class CustomFormBuilder < ActionView::Helpers::FormBuilder | |
| def autocomplete_field(method, url, options = {}) | |
| text_field(method, options.reverse_merge(:'data-autocomplete' => url) | |
| end | |
| end | |
| %w(form_for fields_for).each do |method| | |
| class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 | |
| def omega_#{method}(record_or_name_or_array, *args, &proc) |
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 |
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 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
| 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
| 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
| 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
| 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
| 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
| defaults write com.macromates.textmate OakShellVariables -array-add "{ enabled = 1; variable = TM_RUBY; value = '$(which rvm-auto-ruby)'; }" |
OlderNewer