Skip to content

Instantly share code, notes, and snippets.

View jakehow's full-sized avatar

Jake Howerton jakehow

View GitHub Profile
@jakehow
jakehow / gist:6151726
Created August 4, 2013 20:06
Working No Doc example spec
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
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 April 20, 2012 20:40
Ember Conditional
{{#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 November 21, 2011 20:48
fixed graphite vhost example
# 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 January 31, 2011 07:47
nil weirdness
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
require 'rubygems'
require 'redis'
require 'toystore'
require 'adapter/redis'
class BrokenInitialize
include Toy::Store
store :redis, Redis.new
attribute :test, String
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
ENV["RAILS_ENV"] = "test"
require 'rubygems'
require 'integrity'
require 'notifier/campfire'
Integrity::Notifier.register(Integrity::Notifier::Campfire)
Integrity.new(File.dirname(__FILE__) + "/config.yml")
>> 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"
>> 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}