Skip to content

Instantly share code, notes, and snippets.

View coryschires's full-sized avatar
💭
Code King

Cory Schires coryschires

💭
Code King
View GitHub Profile
@coryschires
coryschires / heroku_push_error.log
Created November 2, 2011 02:03
Heroku push error
ruby-1.9.2-head@scholastica[master*]$ heroku db:pull --confirm scholastica
Loaded Taps v0.3.23
Auto-detected local database: postgres://127.0.0.1/eruditee_development?encoding=utf8
Warning: Data in the database 'postgres://127.0.0.1/eruditee_development?encoding=utf8' will be overwritten and will not be recoverable.
Receiving schema
Schema: 0% | | ETA: --:--:--
Schema: 3% |= | ETA: 00:00:44
Schema: 7% |== | ETA: 00:00:37
Schema: 11% |==== | ETA: 00:00:33
Schema: 15% |====== | ETA: 00:00:30
@coryschires
coryschires / ruby_193.log
Created November 10, 2011 03:13
Heroku Ruby 1.9.3 log
ruby-1.9.3-p0@scholastica[master]$ rake staging heroku:deploy
/Users/coryschires/.rvm/gems/ruby-1.9.3-p0@scholastica/gems/heroku-rails-0.3.2/lib/heroku/rails/tasks.rb:3: warning: already initialized constant HEROKU_CONFIG_FILE
/Users/coryschires/.rvm/gems/ruby-1.9.3-p0@scholastica/gems/heroku-rails-0.3.2/lib/heroku/rails/tasks.rb:4: warning: already initialized constant HEROKU_CONFIG
/Users/coryschires/.rvm/gems/ruby-1.9.3-p0@scholastica/gems/heroku-rails-0.3.2/lib/heroku/rails/tasks.rb:5: warning: already initialized constant HEROKU_RUNNER
Deploying to scholastica-staging...
git push [email protected]:scholastica-staging.git master:master && heroku rake --app scholastica-staging db:migrate && heroku restart --app scholastica-staging
Everything up-to-date
/Users/coryschires/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:799: [BUG] Segmentation fault
@coryschires
coryschires / calendar.php
Created December 1, 2011 18:02
calendar
/**
* Event Title
*
* Return an event's title with pseudo-breadcrumb if on a category
*
* @param bool $depth include linked title
* @return string title
* @since 2.0
*/
@coryschires
coryschires / hasherize.rb
Created January 1, 2012 22:18
Cucumber helper method which makes it easier to work with tabular data
# Starts with cucumber's built-in hashes method and adds a bit more magic:
#
# * Converts hash keys from stings to symbols
# * Converts numeric values into integers
# * Converts true/false strings into actual booleans
#
def hasherize(table)
table.hashes.map do |object|
object.each do |attribute, value|
object[attribute] = to_boolean?(value)
ruby-1.9.2-p180@ignition[master]$ bundle exec rake spec:all
(in /Users/cory.schires/Desktop/work/ignition)
/Users/cory.schires/.rvm/gems/ruby-1.9.2-p180@ignition/gems/cucumber-rails-1.0.2/lib/cucumber/rails.rb:4:in `dirname': can't convert nil into String (TypeError)
from /Users/cory.schires/.rvm/gems/ruby-1.9.2-p180@ignition/gems/cucumber-rails-1.0.2/lib/cucumber/rails.rb:4:in `<top (required)>'
from /Users/cory.schires/.rvm/gems/ruby-1.9.2-p180@ignition/gems/bundler-1.1.3/lib/bundler/runtime.rb:74:in `require'
from /Users/cory.schires/.rvm/gems/ruby-1.9.2-p180@ignition/gems/bundler-1.1.3/lib/bundler/runtime.rb:74:in `rescue in block in require'
from /Users/cory.schires/.rvm/gems/ruby-1.9.2-p180@ignition/gems/bundler-1.1.3/lib/bundler/runtime.rb:62:in `block in require'
from /Users/cory.schires/.rvm/gems/ruby-1.9.2-p180@ignition/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `each'
from /Users/cory.schires/.rvm/gems/ruby-1.9.2-p180@ignition/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `require'
fr
@coryschires
coryschires / leo.rb
Created April 13, 2012 01:33
99 bottles
# Iterative solution
#
bottles = (0..99).to_a
bottles.reverse.each do |bottle|
if bottle.zero?
puts "#{bottle} bottles of beer on the wall. No more beer"
else
puts "#{bottle} bottles of beer on the wall.."
end
@coryschires
coryschires / html-email-styles.html
Created May 2, 2012 20:49
html-email-styles.html
<h1>A better way to manage HTML emails with Ruby on Rails</h1>
<p>With Transis Planner nearly completed, we're starting to focus on the finer details, making sure everything's nicely polished and ready for launch. Among other things, this means creating great looking HTML emails. After all, Planner is a collaboration tool. Our users will be working together to hammer out effective media plans, and that means we'll be sending lots of media briefs, insertion orders, and so on.</p>
<p>Sending multipart emails (i.e. HTML and plain text) with Rails is very straight forward. Just write a mailer action and create two corresponding view templates &mdash; one with an `.html` extension and one with a `.text` extension. But this method has a few shortcomings:</p>
<ul>
<li>You end up duplicating text (and probably logic) since you need to create both a `.text` and `.html` template.</li>
<li>Emails are a total pain to style. In the process, you'll lay waste to all sorts of web standards &mdash; using table-based la
@coryschires
coryschires / beer.rb
Created May 7, 2012 20:16
Bottle of beer examples
bottle_num = 100
# You can clean up the the puts statement using interpolation (i.e. "Some words #{a_variable} and more words")
#
while bottle_num > 0
puts "#{bottle_num -= 1} bottles of beer on the wall"
end
# Or you could even one line it.
#
print "What is your start year? "
start = gets.chomp.to_i
print "What is your finish year? "
finish = gets.chomp.to_i
while finish > start
puts finish -= 1
end
first = 0
last = 1000
total = 0
multipules = []
# build the array of multipules
(first..last).each do |list|
if (list % 5 == 0) or (list % 3 == 0)
multipules.push(list)
end