Skip to content

Instantly share code, notes, and snippets.

View clarkware's full-sized avatar

Mike Clark clarkware

View GitHub Profile
1.66 GHz Intel Core Duo
1GB DDR2 SDRAM
80GB hard drive
Intel GMA950 graphics processor w/ 64MB memory
SuperDrive
1 FireWire 400 port
4 USB 2.0 ports
Ethernet and Airport
Apple Remote
Clean Leopard install
class EventsController < ApplicationController
def create
@event = Event.new(params[:event])
if @event.save
flash[:notice] = 'Event was successfully created.'
redirect_to :action => :index
else
render :action => :new
end
#
# Quick hack to map an iOS app's Core Data managed SQLite database into ActiveRecord
#
class CoreDataBase < ActiveRecord::Base
self.abstract_class = true
set_primary_key "Z_PK"
# Map all ZXXX attributes to XXX
$ rvm ruby-1.9.2-p136@ingredients
$ gem list
animalcracker (0.0.2)
bacon (1.1.0)
beet (0.6.9)
berry (0.0.0)
breadcrumbs (0.1.5)
butternut (0.2.1)
<!-- layout file -->
<% if current_user %>
Welcome <%= current_user.username %>. Not you? <%= link_to "Log out", logout_path %>
<% else %>
<%= link_to "Sign up", signup_path %> or <%= link_to "log in", login_path %>.
<% end %>
@clarkware
clarkware / gist:1046693
Created June 25, 2011 17:37
View Source for Ruby
# Toss this in your ~/.irbrc file for a convenient way
# to peruse Ruby source code in TextMate. This
# only works in Ruby 1.9!
#
# Use it in irb like so:
#
# >> require 'active_record'
# >> ActiveRecord::Base.source_for_method(:create)
class Object
@clarkware
clarkware / gist:1333721
Created November 2, 2011 14:08
TextMate and Ruby 1.9.3
#
# Run this inside TextMate using Cmd-R
#
# puts x
#
# Basically any error will trigger it.
/Applications/TextMate.app/Contents/SharedSupport/Bundles/Ruby.tmbundle/Support/RubyMate/catch_exception.rb:15:[BUG] Segmentation fault
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]
class Course < ActiveRecord::Base
def self.prototype(overrides={})
attributes = {
:code => 'ruby',
:title => 'Ruby Programming',
:active => true,
:released_on => 15.days.ago
}
new(attributes.merge(overrides))
end
@clarkware
clarkware / lyrics.rb
Created September 10, 2012 20:05
Random Lyrics
#!/usr/bin/env ruby
# API Documentation at http://api.wikia.com/wiki/LyricWiki_API
require 'open-uri'
require 'json'
require 'tmpdir'
ARTIST = "Johnny Cash"
class ChangePerspective < ActiveRecord::Migration
def change
rename_table :users, :customers
end
end