Skip to content

Instantly share code, notes, and snippets.

@jasoncodes
jasoncodes / Apple Terminal.itermcolors
Created May 11, 2011 23:18
iTerm colours that resemble Apple's Terminal.app defaults
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.0</real>
<key>Green Component</key>
<real>0.0</real>
@jasoncodes
jasoncodes / go.rb
Created March 12, 2011 03:16
API Terms of Service
#!/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|
@jasoncodes
jasoncodes / README
Created February 10, 2011 00:02
IPv6 router announcement with DNS
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.
@jasoncodes
jasoncodes / example.rb
Created January 19, 2011 02:39
Example usage of `composed_of`.
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',
@jasoncodes
jasoncodes / README.markdown
Created October 6, 2010 11:16
Run VMware Fusion headless at Mac OS system startup

Run VMware Fusion headless at Mac OS system startup.

I heard you like headless VMs on your Mac so I wrote this script for your launchds.

Assumptions

  • Tested on Mac OS X 10.6.4 with VMware Fusion 2.0.5 and 3.1.1.
  • A interactive user automatically logs into the system at startup. I had some issues trying to get this running without an interactive user logged in. I automatically log in for Airfoil Speakers anyway.
  • Your virtual machines live in /Virtual Machines
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",
@jasoncodes
jasoncodes / disable_mass_assignment.rb
Created August 17, 2010 09:52
Noisy protected attributes (mass-assignment security)
ActiveRecord::Base.send(:attr_accessible, nil)
#!/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,
@jasoncodes
jasoncodes / github_clone_all_public.rb
Created June 11, 2010 20:30
A quick script to clone all your public repos on GitHub
#!/usr/bin/env ruby
require 'net/http'
require 'yaml'
username = `git config github.user`.strip
if username.empty?
$stderr.puts "Please set github.user in your git config: https://github.com/account"
exit 1
@jasoncodes
jasoncodes / config.ru
Created May 18, 2010 11:29 — forked from toolmantim/config.ru
Serving simple static sites using Rack
# Rackup file for serving up a static site from a "public" directory
#
# Useful for chucking a static site on Heroku
class IndexRewriter
def initialize(app) @app = app end
def call(env)
env["PATH_INFO"].gsub! /\/$/, '/index.html'
@app.call(env)
end