Skip to content

Instantly share code, notes, and snippets.

View jess's full-sized avatar

Jess Brown jess

View GitHub Profile
def column_grades(program_assignment, answer_sets)
CSV.generate(col_sep: "\t") do |csv|
problem_set_headings = program_assignment.problem_sets.published.order(:due).map(&:name)
csv << ["name", "student id", "student email"] + problem_set_headings
answer_sets.each_pair do |user, ans_sets|
grades = {}
ans_sets.map{|as| grades[as.problem_set_id] = as.grade }
user = ans_sets.first.user
row = [user.name, user.studentid, user.email]
program_assignment.problem_sets.published.order(:due).each do |ps|
jessmbp.local ruby 2.0.0p247 ~/projects/blog $ rails generate postmarkdown:post test-post --date=2011-01-01
/Users/jess/.gem/ruby/2.0.0/bundler/gems/postmarkdown-98612d393767/app/models/post.rb:4:in `<class:Post>': uninitialized constant Post::ActiveModel (NameError)
from /Users/jess/.gem/ruby/2.0.0/bundler/gems/postmarkdown-98612d393767/app/models/post.rb:3:in `<top (required)>'
from /Users/jess/.gem/ruby/2.0.0/bundler/gems/postmarkdown-98612d393767/lib/generators/postmarkdown/post_generator.rb:9:in `check_slug'
from /Users/jess/.gem/ruby/2.0.0/gems/thor-0.18.1/lib/thor/command.rb:27:in `run'
from /Users/jess/.gem/ruby/2.0.0/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command'
from /Users/jess/.gem/ruby/2.0.0/gems/thor-0.18.1/lib/thor/invocation.rb:127:in `block in invoke_all'
from /Users/jess/.gem/ruby/2.0.0/gems/thor-0.18.1/lib/thor/invocation.rb:127:in `each'
from /Users/jess/.gem/ruby/2.0.0/gems/thor-0.18.1/lib/thor/invocation.rb:127:in `
jessmbp.local ruby 2.0.0p247 ~/projects/blog $ rails s
=> Booting WEBrick
=> Rails 4.0.0 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/Users/jess/.gem/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/stack.rb:125:in `assert_index': No such middleware to insert before: "Rack::Sendfile" (RuntimeError)
from /Users/jess/.gem/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/stack.rb:88:in `insert'
from /Users/jess/.gem/ruby/2.0.0/gems/railties-4.0.0/lib/rails/configuration.rb:65:in `block in merge_into'
from /Users/jess/.gem/ruby/2.0.0/gems/railties-4.0.0/lib/rails/configuration.rb:64:in `each'
# /app/decorators/controllers/refinery/pages/pages_controller_decorator.rb
Refinery::PagesController.class_eval do
def show
if current_user_can_view_page?
if should_skip_to_first_child?
redirect_to refinery.url_for(first_live_child.url)
elsif page.link_url.present? && redirect_url?
redirect_to page.link_url
else
@jess
jess / gist:3169779
Created July 24, 2012 12:52
carrier_wave_error
activerecord (3.2.6) lib/active_record/session_store.rb:54:in `dump'
activerecord (3.2.6) lib/active_record/session_store.rb:54:in `marshal'
activerecord (3.2.6) lib/active_record/session_store.rb:148:in `marshal_data!'
activesupport (3.2.6) lib/active_support/callbacks.rb:407:in `_run__630011569004691652__save__3723696214187507607__callbacks'
activesupport (3.2.6) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.6) lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
activesupport (3.2.6) lib/active_support/callbacks.rb:81:in `run_callbacks'
activerecord (3.2.6) lib/active_record/callbacks.rb:264:in `create_or_update'
activerecord (3.2.6) lib/active_record/persistence.rb:84:in `save'
activerecord (3.2.6) lib/active_record/validations.rb:50:in `save'
ypeError (can't dump anonymous class #<Class:0x007fb634cca9d8>):
activerecord (3.2.6) lib/active_record/session_store.rb:54:in `dump'
activerecord (3.2.6) lib/active_record/session_store.rb:54:in `marshal'
activerecord (3.2.6) lib/active_record/session_store.rb:148:in `marshal_data!'
activesupport (3.2.6) lib/active_support/callbacks.rb:407:in `_run__2188096526212490646__save__2611071384826267393__callbacks'
activesupport (3.2.6) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.6) lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
activesupport (3.2.6) lib/active_support/callbacks.rb:81:in `run_callbacks'
activerecord (3.2.6) lib/active_record/callbacks.rb:264:in `create_or_update'
activerecord (3.2.6) lib/active_record/persistence.rb:84:in `save'
@jess
jess / gist:3150621
Created July 20, 2012 13:03
spree_error
activerecord (3.2.6) lib/active_record/connection_adapters/postgresql_adapter.rb:1151:in `async_exec'
activerecord (3.2.6) lib/active_record/connection_adapters/postgresql_adapter.rb:1151:in `exec_no_cache'
activerecord (3.2.6) lib/active_record/connection_adapters/postgresql_adapter.rb:664:in `block in exec_query'
activerecord (3.2.6) lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
activesupport (3.2.6) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activerecord (3.2.6) lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
activerecord (3.2.6) lib/active_record/connection_adapters/postgresql_adapter.rb:663:in `exec_query'
activerecord (3.2.6) lib/active_record/connection_adapters/postgresql_adapter.rb:1276:in `column_definitions'
activerecord (3.2.6) lib/active_record/connection_adapters/postgresql_adapter.rb:859:in `columns'
activerecord (3.2.6) lib/active_record/connection_adapters/schema_cache.rb:12:in `block in initialize'
@jess
jess / gist:2422579
Created April 19, 2012 17:50
text links ads, rails
# text links ads stuff
# ---------------------------------------------------------------------------------------------------------------
#controller action
def some_action
text_link_ads "your_id_here"
....
end
#carrierwave, get image width and height of image (using the MiniMagick gem)
#stick this in your uploader (ex: uploaders/file_uploader.rb)
def width
@image ||= get_minimagick_image
@image[:width]
end
def height
@image ||= get_minimagick_image
# crawl a site and build a sitemap for montlick.com
require 'rubygems'
require 'anemone'
require 'builder'
sitemap = ""
xml = Builder::XmlMarkup.new(:target => sitemap, :indent=>2)
sitemap_txt = ""
xml.instruct!