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 ruby | |
# A couple of Searchlogic searches. Both are identical from a code | |
# perspective. With one, the user supplies a '.' (period) as part of the | |
# search query. This search blows up because it's generating an invalid SQL | |
# statement. I say it shouldn't. The error in question is: | |
# | |
# Mysql::Error: Not unique table/alias: 'users': | |
# | |
# SELECT `companies`.`id` AS t0_r0, |
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
ActiveRecord::Base.send(:attr_accessible, nil) |
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
module ActionView::Helpers::FormTagHelper | |
def date_field(object_name, method, options = {}) | |
ActionView::Helpers::InstanceTag.new(object_name, method, self, options.delete(:object)).to_input_field_tag("date", options.merge(:size => nil)) | |
end | |
end | |
class ActionView::Helpers::FormBuilder | |
def date_field(method, options = {}) | |
@template.send( | |
"date_field", |
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 Example < ActiveRecord::Base | |
composed_of :input_voltage, | |
:class_name => 'VoltageRange', | |
:mapping => [%w(input_voltage_min min), %w(input_voltage_max max)], | |
:allow_nil => true, | |
:converter => :new | |
composed_of :output_voltage, | |
:class_name => 'VoltageRange', |
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
iOS 4.2.1 detects shows the announced DNS settings in Settings, Wi-Fi Networks within a second of starting `radvd`. The search domain does not appear to be supported. |
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 ruby -w | |
require 'shellwords' | |
require 'fileutils' | |
# generate plain text versions | |
Dir['*.html'].each do |html_filename| | |
open("|elinks -dump -dump-width 9000 -no-numbering -no-references #{Shellwords.escape(html_filename)}") do |io| |
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
// ==UserScript== | |
// @name Pivotal Tracker: Fight Wrinkles | |
// @description Fixes a few small UI annoyances with Pivotal Tracker. | |
// @author Jason Weathered | |
// @namespace http://jasoncodes.com/ | |
// @match https://www.pivotaltracker.com/* | |
// @include https://www.pivotaltracker.com/* | |
// @version 1.0.0 | |
// ==/UserScript== |
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
Enumerable.class_eval do | |
def group_by_many | |
{}.tap do |groups| | |
each do |value| | |
keys = yield value | |
keys.each do |key| | |
group = groups[key] ||= [] | |
group << value | |
end | |
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
function __database_yml { | |
if [[ -f config/database.yml ]]; then | |
ruby -ryaml -rerb -e "puts YAML::load(ERB.new(IO.read('config/database.yml')).result)['${RAILS_ENV:-development}']['$1']" | |
fi | |
} | |
function psql | |
{ | |
if [[ "$(__database_yml adapter)" == 'postgresql' ]]; then | |
PGDATABASE="$(__database_yml database)" "$(/usr/bin/which psql)" "$@" |
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
path = '/products/42/edit' | |
params = Rails.application.routes.recognize_path path | |
route = nil; Rails.application.routes.formatter.send(:match_route, nil, params) { |r| route ||= r } | |
p route.name # returns "edit_product" |