Skip to content

Instantly share code, notes, and snippets.

View dwradcliffe's full-sized avatar

David Radcliffe dwradcliffe

View GitHub Profile
@dwradcliffe
dwradcliffe / generate_anonymous_users.rb
Created February 9, 2011 15:40
spree migration fix
class GenerateAnonymousUsers < ActiveRecord::Migration
def self.up
User.reset_column_information
puts Order.where(:user_id => nil).where(:state != "balance_due").count.to_s + " remaining..."
Order.where(:user_id => nil).where(:state != "balance_due").each do |order|
user = User.anonymous!
user.email ||= order.email
puts user.login
user.save!
order.update_attribute_without_callbacks("user_id", user.id)
require File.dirname(__FILE__) + '/config/environment'
run ActionController::Dispatcher.new
@dwradcliffe
dwradcliffe / index.html
Created June 20, 2011 12:50
Google Maps Quckstart
<!DOCTYPE html>
<html>
<head>
<title>Google Maps Quickstart</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0px; padding: 0px }
#map_canvas { height: 100% }
</style>
@dwradcliffe
dwradcliffe / bootstrap.sh
Created July 27, 2011 17:20
Chef bootstrap
#!/bin/bash
apt-get install ssh build-essential
wget http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise_1.8.7-2011.03_i386_ubuntu10.04.deb
dpkg -i ruby-enterprise_1.8.7-2011.03_i386_ubuntu10.04.deb
gem install chef --no-ri --no-rdoc
@dwradcliffe
dwradcliffe / _instructions.txt
Created January 18, 2012 15:17
Using quitgodaddy.com with 1&1
Noah Coffey (@noahwesley) built a great little tool (http://quitgodaddy.com) to help people
move their domains off GoDaddy by reminding them before the expiration dates.
I have a whole bunch of domains on 1&1 (another horrible company) and wanted to use Noah's tool.
He was kind enough to provide the proper format and I wrote a quick script to pull all my domains
off the 1&1 admin page.
How to use:
Navigate to your domains page. Select 100 domains on a page. You'll have to do the following
@dwradcliffe
dwradcliffe / apcurl.sh
Created February 17, 2012 20:54
Quick shell script to print json nicely from curl
#!/bin/bash
curl -# $* | ruby -e "require 'rubygems';require 'json';require 'awesome_print'; ap JSON.parse(STDIN.gets)"
@dwradcliffe
dwradcliffe / myview.js.coffee
Created March 13, 2012 17:04 — forked from NickJosevski/myview.js.coffee
backbone example - serialize form + update on change
window.MyView = Backbone.View.extend({
initialize: ->
_.bindAll(this,'render')
this.template = window.JST["MyView"]
this.model.bind('change', this.render)
render: ->
$(this.el).html(this.template(this.model.toJSON()))
events: {
class Player < ActiveRecord::Base
def salary_valid_for_year? year
send("s#{year}") != 0 && send("status#{year}") != 0 && !send("status#{year}").nil?
end
def salary_for_year year
send("s#{year}")
end
{
"id": "rubygems",
"application": {
"production": {
"rails_postgresql_host" : "",
"rails_postgresql_db": "",
"rails_postgresql_user": "",
"rails_postgresql_password": "",
"s3_key": "",
"s3_secret": "",
➜ bundle update --verbose
Updating git://github.com/engageis/activerecord-postgres-hstore.git
Updating https://github.com/gregbell/active_admin.git
Updating https://github.com/jeffp/enumerated_attribute.git
Fetching gem metadata from https://rubygems.org/
Query List: ["rails", "pg", "activerecord-postgres-hstore", "sass-rails", "coffee-rails", "uglifier", "asset_sync", "formtastic", "underscore-rails", "simple_form", "activeadmin", "meta_search", "devise", "haml", "haml-rails", "jquery-rails", "bootstrap-sass", "inherited_resources", "icalendar", "airbrake", "event-calendar", "holidays", "redis", "enumerated_attribute", "paperclip", "aws-sdk", "cancan", "mail_view", "newrelic_rpm", "vpim", "unread", "setler", "dotenv", "twilio-ruby", "rack-rewrite", "resque", "sinatra", "rails_autolink", "gibbon", "mixpanel", "dalli", "pry-rails", "rspec-rails", "faker", "heroku", "rails-erd", "guard", "guard-rspec", "sextant", "brakeman", "mailcatcher", "better_errors", "binding_of_caller", "timecop", "factory_girl_rails", "