Skip to content

Instantly share code, notes, and snippets.

View perezd's full-sized avatar
🦾
More Perfect Protobuf

Derek Perez perezd

🦾
More Perfect Protobuf
View GitHub Profile
@perezd
perezd / nodehttpsfail.js
Created April 9, 2011 18:46
This is a repeatable example of a Node HTTPS bug found in v0.4.5. The test relies on cradle.js (which is basically just wrapping HTTP requests, npm install cradle). I describe the bug scenario in the comment below. comment out the different "conn" variabl
// NodeJS BUG:
//
// HTTP mode always calls log message on L30.
// HTTP has not yet failed.
//
// HTTPS mode never calls the log message on L30.
// HTTPS mode randomly throws the following exception:
// node.js:134
// throw e; // process.nextTick error, or 'error' event on first tick
// ^
module Extensions
module Models
module Serialization
def as_json(options={})
return super(options) if options.nil? # do not compromise CouchDB's version of the doc.
with_serialization_defaults(options) do |options|
jzon = super(options)
if options && options[:methods]
options[:methods].each { |method| jzon[method] = send(method) if respond_to?(method) }
<!doctype html>
<html>
<body>
<div class="ribbon">
<a href="#" rel="me">Fork me on GitHub</a>
</div>
</body>
</html>
/Users/derek/.rvm/gems/ree-1.8.7-2010.02@nitro/gems/activesupport-3.0.0.beta4/lib/active_support/whiny_nil.rb:48:in `method_missing': undefined method `name_for_action' for nil:NilClass (NoMethodError)
from /Users/derek/.rvm/gems/ree-1.8.7-2010.02@nitro/gems/actionpack-3.0.0.beta4/lib/action_dispatch/routing/mapper.rb:710:in `match'
from /Users/derek/.rvm/gems/ree-1.8.7-2010.02@nitro/gems/actionpack-3.0.0.beta4/lib/action_dispatch/routing/mapper.rb:287:in `map_method'
from /Users/derek/.rvm/gems/ree-1.8.7-2010.02@nitro/gems/actionpack-3.0.0.beta4/lib/action_dispatch/routing/mapper.rb:243:in `post'
from /Users/derek/.rvm/gems/ree-1.8.7-2010.02@nitro/bundler/gems/devise-8504d58f0336e724a0c4731303a4b03858b68c88-master/lib/devise/rails/routes.rb:188:in `devise_session'
from /Users/derek/.rvm/gems/ree-1.8.7-2010.02@nitro/gems/actionpack-3.0.0.beta4/lib/action_dispatch/routing/mapper.rb:329:in `scope'
from /Users/derek/.rvm/gems/ree-1.8.7-2010.02@nitro/bundler/gems/devise-8504d58f0336e724a0c4731303a4b03858b68
@perezd
perezd / box_shadow_default.css
Created June 19, 2010 20:01
code examples for my compass blog posts
#my-div {
-moz-box-shadow: white 0px 1px 0px 5px;
-webkit-box-shadow: white 0px 1px 0px 5px;
-o-box-shadow: white 0px 1px 0px 5px;
box-shadow: white 0px 1px 0px 5px;
}
<%= f.time_zone_select :time_zone, ActiveSupport::TimeZone.all, {}, {:disabled => true} %>
// adapted from the good folks at www.particletree.com
// Rediscovering the Button Element by Kevin Hale
// http://particletree.com/features/rediscovering-the-button-element/
// Converted to SASS by Derek Perez (derek@derekperez.com)
=base-button
margin: 0px
background-color: #f5f5f5
border: 1px solid #dedede
border-top: 1px solid #eee
.form-element
input, textarea
:border 1px solid gray
:padding 5px
input.example-field
:color #e0e0e0
:font-style italic
:padding 5px
textarea
@perezd
perezd / gist:98980
Created April 21, 2009 06:24
another edition of the prototype, this allows for passing in arbitrary arguments, defined in the function.
class Hash
def method_missing(meth,*args)
self[meth].is_a?(Proc) ? self[meth].call(args) : self[meth]
end
end
class Object
def function(*args, &block)
lambda { |meth_args| yield(Hash[*args.zip(meth_args).flatten]) }
end
@perezd
perezd / gist:98892
Created April 21, 2009 02:17
Hackish Prototype of a JavaScript-esque Class/Object
class Hash
def method_missing(meth,*args)
self[meth].is_a?(Proc) ? self[meth].call(*args) : self[meth]
end
end
MyClass = {
:some_method => lambda { |arg|
puts "#{arg} was recieved"