Skip to content

Instantly share code, notes, and snippets.

View cheald's full-sized avatar

Chris Heald cheald

View GitHub Profile
require 'mongo_mapper'
module CarrierWave
module MongoMapper
include CarrierWave::Mount
##
# See +CarrierWave::Mount#mount_uploader+ for documentation
#
def mount_uploader(column, uploader, options={}, &block)
# We need to set the mount_on column (or key in MongoMapper's case)
module Validatable
def errors
@errors ||= Validatable::Errors.new(self)
end
class ValidationBase #:nodoc:
def try_translation(key)
begin
::I18n.translate!(key, :scope => "activerecord")
rescue ::I18n::ArgumentError
@@ -337,7 +337,7 @@ MESSAGE
# @yield [args] A block of Haml code that will be converted to a string
# @yieldparam args [Array] `args`
def capture_haml(*args, &block)
- buffer = eval('_hamlout', block.binding) rescue haml_buffer
+ buffer = eval('if defined? _hamlout then _hamlout else nil end', block.binding) || haml_buffer
with_haml_buffer(buffer) do
position = haml_buffer.buffer.length
... ...
[chris@luna repos]$ ll *.json
-rwxr--r--. 1 chris chris 4792 Jan 20 17:00 compact.json
-rwxr--r--. 1 chris chris 5206 Jan 20 17:00 orig.json
[chris@luna repos]$ gzip *.json
[chris@luna repos]$ ll *.json.gz
-rwxr--r--. 1 chris chris 1450 Jan 20 17:00 compact.json.gz
-rwxr--r--. 1 chris chris 1499 Jan 20 17:00 orig.json.gz
def handlebars_js(name, opts = {}, &block)
inner = capture(&block).gsub(/\s*\n\s*/, " ")
concat raw "window._templates['#{name}'] = #{inner.to_json};\n"
nil
end
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.11 (GNU/Linux)
mQENBE82tLwBCACn00/ml+//9csLvgrE7aQtSdF7+bCnqDdjkLvGpyEe7CFUtQ2K
WzcH3fh2gs8mKTpfgUNIkK1KplrBZHmFMOAnDMgfcQ2mDWtYDuThUPbaFtIAsTtb
iD9zCSrKL8oDx8RfwbJR4hsseE4npkAV/PhpD6oKZT/d2lfTNS1+pgqJFpwQwnGJ
l/1FRbzkk77Z+LYXVlOZCEBYRcwaKTr2tzcsUwACJumB3IEoUHho1OzuXosuDQOX
tfwMiE3gyq2Tp9aaQXSz/z/TWNptXUxAbaIUxeyFpUlgYm21V+35vmZn/IgStjin
8rI1dvO+SEKGH1HH4gh0ZVmLnRbqxJDSz6ghABEBAAG0HkNocmlzIEhlYWxkIDxj
aGVhbGRAZ21haWwuY29tPokBOAQTAQIAIgUCTza0vAIbAwYLCQgHAwIGFQgCCQoL
#content
#menu
#content
padding-left: 200px
position: relative
#menu
position: absolute
top: 0
source "http://rubygems.org"
gem "mechanize"
gem "unf"
var src = [
{"created_at":"Sun Jun 10 05:56:54 +0000 2012","id":211698435269722112,"id_str":"211698435269722112","text":"Timothy Bradley wins by split decision to claim Manny Pacquiao\u2019s WBO welterweight title http:\/\/t.co\/4SvRaLmb","source":"web","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":759251,"id_str":"759251","name":"CNN","screen_name":"CNN","location":"","description":"Connecting you to breaking news, the biggest moments and interviews from CNN TV, and the stories and videos garnering attention on CNN.com and social media.","url":"http:\/\/www.cnn.com","protected":false,"followers_count":4797672,"friends_count":649,"listed_count":68036,"created_at":"Fri Feb 09 00:35:02 +0000 2007","favourites_count":2,"utc_offset":-18000,"time_zone":"Eastern Time (US & Canada)","geo_enabled":false,"verified":true,"statuses_count":25664,"lang":"en","contributors_enabled":true,
require 'sinatra'
require 'redis'
require 'json'
set :redis, Redis.new(:db => 3)
before { content_type :json }
get "/foos" do
keys = options.redis.keys("foo:*")