Skip to content

Instantly share code, notes, and snippets.

Avatar

Jake Howerton jakehow

View GitHub Profile
@jakehow
jakehow / gist:6151726
Created Aug 4, 2013
Working No Doc example spec
View gist:6151726
require 'rspec_api_documentation'
require 'rspec_api_documentation/dsl'
require 'spec_helper'
resource 'No_Doc Test' do
get "/foo" do
example "should appear in docs" do
do_request
status.should == 200
end
View gist:4229384
rbx-head-18mode :003 > Base64.respond_to?(:strict_encode64)
=> false
rbx-head-18mode :004 > unless Base64.respond_to?(:strict_encode64)
rbx-head-18mode :005?> module Base64
rbx-head-18mode :006?> def strict_encode64(bin)
rbx-head-18mode :007?> [bin].pack("m0")
rbx-head-18mode :008?> end
rbx-head-18mode :009?> end
rbx-head-18mode :010?> end
=> #<Rubinius::CompiledCode strict_encode64 file=(irb)>
@jakehow
jakehow / gist:2431758
Created Apr 20, 2012
Ember Conditional
View gist:2431758
{{#if MyApp.currentUser}}
<ul>
<li>Welcome, {{ MyApp.currentUser.name}} | <a href="#" {{action "logout" on="click"}}>Log Out</a></li>
</ul>
{{else}}
<ul>
<li><a href="#" {{action "showLogin" on="click"}}>Log In</a></li>
</ul>
{{/if}}
@jakehow
jakehow / gist:1383881
Created Nov 21, 2011
fixed graphite vhost example
View gist:1383881
# This needs to be in your server's config somewhere, probably
# the main httpd.conf
# NameVirtualHost *:80
# This line also needs to be in your server's config.
# LoadModule wsgi_module modules/mod_wsgi.so
# You need to manually edit this file to fit your needs.
# This configuration assumes the default installation prefix
# of /opt/graphite/, if you installed graphite somewhere else
@jakehow
jakehow / wtf
Created Jan 31, 2011
nil weirdness
View wtf
ruby-1.8.7-p249 > x = p.to_account
=> nil
ruby-1.8.7-p249 > !x
=> false
ruby-1.8.7-p249 > !nil
=> true
ruby-1.8.7-p249 > x
=> nil
ruby-1.8.7-p249 > x === nil
=> true
View gist:801158
require 'rubygems'
require 'redis'
require 'toystore'
require 'adapter/redis'
class BrokenInitialize
include Toy::Store
store :redis, Redis.new
attribute :test, String
View modular-restriction
class Array
def sum
inject(0) {|total,n| total + n }
end
end
puts Array.new([1,2,3,4]).sum
puts [1,2,3,4].sum
module StickyFingaz
View integrity_build_check.rb
ENV["RAILS_ENV"] = "test"
require 'rubygems'
require 'integrity'
require 'notifier/campfire'
Integrity::Notifier.register(Integrity::Notifier::Campfire)
Integrity.new(File.dirname(__FILE__) + "/config.yml")
View gist:76525
>> s = Statement.new
=> {"updated_at"=>nil, "couchrest-type"=>"Statement", "created_at"=>nil}
>> s.create_attachment(:name => 'test.txt', :content_type => 'text/plain', :file => File.open('test.txt'))
=> {"content-type"=>"text/plain", "data"=>"dGVzdAo="}
>> s.save
=> nil
>> s['_attachments']['test.txt']
=> {"content-type"=>"text/plain", "data"=>"ZEdWemRBbz0="}
>> s['_attachments']['test.txt']['content-type']
=> "text/plain"
View gist:76417
>> class Blah < CouchRest::ExtendedDocument
>> property :myval
>> property :trueval
>> def myval=(val)
>> self.trueval = val
>> end
>> end
=> nil
>> b = Blah.new(:myval => 10)
=> {"couchrest-type"=>"Blah", "myval"=>10}