Public Gists by bensie

Gravatar
Tue Jun 16 12:13:28 -0700 2009
1
2
3
U.S. states must be sent as their full capitalized name, those from the following list are valid:
  'Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'District Of Columbia',
  'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland',
gist: 130426 For when you want to return...
Gravatar
Mon Jun 15 16:27:03 -0700 2009
1
2
3
# Three things to add:
# * before_filter call
# * action_has_layout? method (if you have one, combine them)
Gravatar
Sun Jun 14 15:54:48 -0700 2009
1
2
3
#workspace1 {
margin: 0;
padding: 0;
gist: 128160 jQuery script for focusing ...
Gravatar
Thu Jun 11 12:12:57 -0700 2009
1
2
3
// Focus the first text field on a page if it's blank
$('input[type=text]:first').each(function() {
  if (this.value.length == 0) {
gist: 121605 Allow admin editing of prot...
Gravatar
Mon Jun 01 10:08:00 -0700 2009
1
2
3
# Allow admin editing of protected attributes
if admin?
  %w(field1 field2 field3).each do |field|
Gravatar
Fri May 29 13:25:23 -0700 2009
1
2
3
<?xml version="1.0" encoding="UTF-8"?>
<job>
  <additional-info>We will be accepting applications for this job until May 1, 2009.</additional-info>
Gravatar
Fri May 29 12:49:22 -0700 2009
1
2
3
<?xml version="1.0" encoding="UTF-8"?>
<job>
<!-- Required Fields -->
Gravatar
Fri May 29 12:41:51 -0700 2009
1
2
3
# Sample Ruby script for batch XML job posts
 
api_key = "fe1db44cab667104866b74f0fd5da9eb80297590"
Gravatar
Fri May 29 12:39:50 -0700 2009
1
2
3
#!/usr/bin/perl
 
# Sample Perl script for batch XML job posts
Gravatar
Fri May 29 12:35:54 -0700 2009
1
2
3
#!/usr/bin/php
 
<?
Gravatar
Tue May 26 11:52:24 -0700 2009
1
2
3
# for a setup script see http://gist.github.com/32917
PASSENGER=2.2.2
REE="ruby-enterprise-1.8.6-20090520"
Gravatar
Fri May 15 08:27:36 -0700 2009
1
2
3
class User < ActiveRecord::Base
 
  private
Gravatar
Fri May 08 10:04:14 -0700 2009
1
2
3
Textmate Find and Replace Whitespace:
 
find \s+$ and replace with nothing.
Gravatar
Wed May 06 13:12:49 -0700 2009
1
2
3
# first you'll want to create a gist then `git clone` the private url
# second you'll want to run this script in the gist's directory
loop do
Gravatar
Sat May 02 21:07:33 -0700 2009
1
2
3
# Back up your iTunes library to S3
git clone git://github.com/sstephenson/mackerel.git
ruby -rubygems mackerel/examples/itunes_backup.rb amazon-s3://YOUR_ACCESS_KEY_ID:YOUR_SECRET_ACCESS_KEY@s3.amazonaws.com/YOUR_BUCKET_NAME/itunes.mackerel
Gravatar
Sat May 02 08:49:45 -0700 2009
1
2
3
jk2:dicom2jpeg jkmiller$ g++ dicom2jpeg.cpp
Undefined symbols:
  "puntoexe::basePtr::addRef()", referenced from:
Gravatar
Thu Apr 30 13:17:53 -0700 2009
1
2
3
# Find duplicates
select id, count(*) from player_history_changes group by user_id, old_kc, old_combined, old_crib, new_kc, new_combined, new_crib, result, score HAVING count(*) > 1;
 
Gravatar
Wed Apr 22 15:53:14 -0700 2009
1
2
3
# Painless method for rendering a 404 (not found) whenever it might be useful
def render_404
  respond_to do |format|
gist: 99465 MySQL Database Backup => Am...
Gravatar
Tue Apr 21 16:21:21 -0700 2009
1
2
3
mysql_username = "backup"
mysql_password = ""
databases = [ 'db1', 'sb2' ]
Gravatar
Mon Apr 20 14:24:26 -0700 2009
1
2
3
# Get all players and their head-to-head rank in KC
SET @row := 0;
SELECT id, username, kc_head_to_head_rating, @row := @row+1 AS rank