This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Request = Class.refactor(Request, { | |
Extends: Request, | |
initialize: function(options) { | |
this.parent(options) | |
this.addEvent('complete', function() { alert('foo') }) | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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 | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import("http"; "log"; "strings";) | |
/** | |
* A service running in an endpoint. | |
*/ | |
type Service struct { | |
responseBody string; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SymbolWithArgs | |
def args | |
@args || [] | |
end | |
def [](*args) | |
@args = args | |
self | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# on the remote server logged as 'deploy' | |
cd /var/apps | |
mkdir yourapp.git | |
cd yourapp.git | |
git init |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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">] |
OlderNewer