Skip to content

Instantly share code, notes, and snippets.

View chadoh's full-sized avatar
🌲

Chad Ostrowski chadoh

🌲
View GitHub Profile
@chadoh
chadoh / partials.rb
Created May 6, 2010 03:29 — forked from lenary/partials.rb
An implementation of partials for Sinatra, with support for a :spacer_string parameter (like rail's :spacer_template, but less robust and more tailored to my needs). See how it's used here: http://github.com/chadoh/lisli/blob/master/views/_post.haml
# stolen from http://gist.github.com/119874 and made a tiny bit more robust by me
# this implementation uses haml by default. if you want to use any other template mechanism
# then replace `erb` on line 23 and line 31 with `erb` or whatever
#This implementation varies from lenary's because it allows a :spacer_string to be specified
# a spacer_string works the same way as a :spacer_template in rails,
# except instead of rendering a page it plops in a string,
# but only in between elements of the collection, not at the end.
# This is useful if you have, say, a collection of blog tags,
# rendered as a collection of links with commas between them.
@chadoh
chadoh / better_config_(doesnt_work).rb
Created August 5, 2010 02:47
caprese config files for troubleshooting
BlockDomains(
'youtube.com' => %w[
72.14.213.100
72.14.213.101
72.14.213.102
72.14.213.113
72.14.213.138
72.14.213.139
74.125.127.100
74.125.127.101
@chadoh
chadoh / Rails 3 i18n deperecation warning
Created November 1, 2010 12:25
This isn't very helpful. Which file is to blame? It's not my work that's causing it.
The {{key}} interpolation syntax in I18n messages is deprecated. Please use %{key} instead.
/Library/Ruby/Gems/1.8/gems/i18n-0.4.1/lib/i18n/backend/base.rb:162:in `interpolate'
/Library/Ruby/Gems/1.8/gems/i18n-0.4.1/lib/i18n/backend/base.rb:157:in `gsub'
/Library/Ruby/Gems/1.8/gems/i18n-0.4.1/lib/i18n/backend/base.rb:157:in `interpolate'
/Library/Ruby/Gems/1.8/gems/i18n-0.4.1/lib/i18n/backend/base.rb:197:in `preserve_encoding'
/Library/Ruby/Gems/1.8/gems/i18n-0.4.1/lib/i18n/backend/base.rb:156:in `interpolate'
/Library/Ruby/Gems/1.8/gems/i18n-0.4.1/lib/i18n/backend/base.rb:49:in `translate'
/Library/Ruby/Gems/1.8/gems/i18n-0.4.1/lib/i18n.rb:152:in `translate'
/Library/Ruby/Gems/1.8/gems/i18n-0.4.1/lib/i18n/backend/base.rb:120:in `resolve'
/Library/Ruby/Gems/1.8/gems/i18n-0.4.1/lib/i18n/backend/base.rb:105:in `default'
@chadoh
chadoh / mongo.cloudfoundry.com typo.txt
Created April 13, 2011 15:51
mongo.cloudfoundry.com has some typos
MongoDB browser shell version: 0.1.3
connecting to random database
type "contest" to learn how to enter to win a MongoDB mug or backpack!
type "tutorial" to start the MongoDB tutorial
> contest
10gen is giving away MongoDB mugs and backpacks.
To enter the giveaway, simply save your contact information to the
'info' collection. For example, to save your name and email address, you'd enter:
db.info.save({name: "Meghan", email: "[email protected]"})
@chadoh
chadoh / Guardfile
Created June 6, 2011 14:34
A poor Guardfile for use with MiniTest and Rails
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'minitest' do
# with Minitest::Unit
watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
watch(%r{^test/.+_test\.rb$})
watch('test/test_helper.rb') { "test" }
# Rails example
@chadoh
chadoh / Guardfile
Created June 6, 2011 15:52
This isn't working. Or something isn't working, anyhow.
# More info at https://github.com/guard/guard#readme
guard 'minitest' do
# with Minitest::Unit
watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
watch(%r{^test/.+_test\.rb$})
watch('test/test_helper.rb') { "test" }
# Rails example
watch(%r{^app/models/(.+)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
$("*[contenteditable]").live({
blur: function(){
var model = $(this).attr("data-model"),
attribute = $(this).attr("data-attribute") || $(this).attr("class"),
value = $(this).text(),
path = $(this).attr("data-path"),
updateData = {};
updateData[model] = {};
updateData[model][attribute] = value;
$.ajax({
TITLEBAR="\[\e]0;\u@\h \w\007\]"
export PS1='\[\e]0;\u@\h \w\007\]\
\[\e[0;32m\]\u@\h\[\e[0m\] \
\[\e[1;34m\]\w\[\e[0m\]\
\[\e[1;35m\]$(__git_ps1)\[\e[0m\] \
\[\e[1;37m\]$\[\e[0m\] '
require 'spec_helper'
require 'carrierwave/test/matchers'
describe CoverArtUploader do
include CarrierWave::Test::Matchers
before do
CoverArtUploader.enable_processing = true
@uploader = CoverArtUploader.new(CoverArt.create, :image)
@uploader.store!(File.open("#{Rails.root}/spec/uploaders/fruit.jpg", "r"))
# encoding: utf-8
class CoverArtUploader < CarrierWave::Uploader::Base
# Include RMagick or ImageScience support:
# include CarrierWave::RMagick
# include CarrierWave::ImageScience
# Choose what kind of storage to use for this uploader:
# storage :file