Skip to content

Instantly share code, notes, and snippets.

View perezd's full-sized avatar

Derek Perez perezd

View GitHub Profile
@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
.form-element
input, textarea
:border 1px solid gray
:padding 5px
input.example-field
:color #e0e0e0
:font-style italic
:padding 5px
textarea
// 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
<%= f.time_zone_select :time_zone, ActiveSupport::TimeZone.all, {}, {:disabled => true} %>
@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;
}
/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
<!doctype html>
<html>
<body>
<div class="ribbon">
<a href="#" rel="me">Fork me on GitHub</a>
</div>
</body>
</html>
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) }
@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
// ^
@perezd
perezd / curl.diff
Created April 10, 2011 17:54
attempting to talk to cloudant via http/https using curl w/ diff
@@ -1,9 +1,26 @@
-Octave:~ derek$ curl -vX PUT http://nodebug:omgnodebug@nodebug.cloudant.com/test/myDoc4/photo?rev=43-e5e93a0702db48fec34d0cd77e43dec1 --data-binary @cherryTree.JPG -H "Content-Type: image/jpg"
-* About to connect() to nodebug.cloudant.com port 80 (#0)
+Octave:~ derek$ curl -vX PUT https://nodebug:omgnodebug@nodebug.cloudant.com/test/myDoc4/photo?rev=45-096d89a0f8d6d0bd6b7be608c687b532 --data-binary @cherryTree.JPG -H "Content-Type: image/jpg"
+* About to connect() to nodebug.cloudant.com port 443 (#0)
* Trying 184.72.47.54... connected
-* Connected to nodebug.cloudant.com (184.72.47.54) port 80 (#0)
+* Connected to nodebug.cloudant.com (184.72.47.54) port 443 (#0)
+* SSLv3, TLS handshake, Client hello (1):
+* SSLv3, TLS handshake, Server hello (2):