Skip to content

Instantly share code, notes, and snippets.

View divoxx's full-sized avatar

Rodrigo Kochenburger divoxx

  • Doximity
  • San Francisco, CA
View GitHub Profile
Request = Class.refactor(Request, {
Extends: Request,
initialize: function(options) {
this.parent(options)
this.addEvent('complete', function() { alert('foo') })
}
})
$each([Request, Request.HTML, Request.JSON], function(klass) {
klass.prototype = Class.refactor(klass, {
Extends: klass,
initialize: function(options) {
this.parent(options)
this.addEvent('complete', function() { alert('foo') })
}
}).prototype
})
var reapplyTimeoutId = null
$each(['insertBefore', 'replaceChild', 'removeChild', 'appendChild'], function(methodName) {
Node.prototype["_" + methodName] = Node.prototype[methodName]
Node.prototype[methodName] = function() {
var ret = this["_" + methodName](arguments[0], arguments[1])
if (reapplyTimeoutId) { clearTimeout(reapplyTimeoutId) }
reapplyTimeoutId = setTimeout(Attitude.applyDefinitions.bind(Attitude), 100)
return ret
}
var InputTitleAsValue = new Attitude.Behavior({
initialize: function() {
if (this.element.get('value') == '') {
this.element.set('value', this.element.get('title'))
} else if (this.element.get('value') != this.element.get('title')) {
this.element.removeClass('title-as-value')
}
},
onFocus: function() {
#!/bin/bash
# Utility script that manage binary versioned symlinks.
#
# Supposing in /usr/local/bin, there is two executables: ruby1.8 and ruby1.9
# and /usr/local/bin/ruby is a symlink to ruby1.8.
#
# Running the scripts would do the following:
#
# $ choose ruby list
# Available ruby versions:
key = PKey::RSA.new(@certificate, passphrase)
data = "foobar"
signed = key.sign(OpenSSL::Digest::SHA1.new, data)
key.verify(OpenSSL::Digest::SHA1.new, signed, data) # => true
package main
import("http"; "log"; "strings";)
/**
* A service running in an endpoint.
*/
type Service struct {
responseBody string;
}
module SymbolWithArgs
def args
@args || []
end
def [](*args)
@args = args
self
end
end
# on the remote server logged as 'deploy'
cd /var/apps
mkdir yourapp.git
cd yourapp.git
git init
geo = GoogleGeocoding::Geocoder.new(:app_key => YOUR_API_KEY, :user_agent => YOUR_USER_AGENT)
res = geo.query("Union Square, San Francisco, CA")
res.placemarks # => [#<GoogleGeocoding::Placemark:0x100629598 @country_code="US", @country_name=["USA", "US"], @city="San Francisco", @accurracy=4, @coordinates=[-122.4074374, 37.7879938], @region="CA">]