Skip to content

Instantly share code, notes, and snippets.

Array.prototype.unique = function() {
var uniqueKeys = {},
uniqueArray = [],
items = this.length
while( items )
uniqueKeys[this[--items]] = true
for( var key in uniqueKeys )
if (uniqueKeys.hasOwnProperty(key)) uniqueArray.push(key)
#!/usr/bin/env ruby -wKU
def ∑ *args
args.inject do |sum, x|
sum + x
end
end
puts ∑ 1, 2, 3
#!/usr/bin/env ruby -wKU
module Kernel
alias λ proc
def ∑ *terms
terms.inject { |sum, term| sum + term }
end
var DatabaseFactory = {
getInstanceById: function(id, type) {
if(!this.instances) this.instances = {};
var theId = id + "" + typeof type;
if(this.instances[theId]) {
return this.instances[theId];
} else {
this.instances[theId] = new type(id);
return this.instances[theId];
// Record Object
function Record(id) {
this.id = id;
}
Record.prototype.save = function() {
console.log("saving record " + this.id);
}
Record.prototype.delete = function() {
// Record Object
function Record(id) {
this.id = id;
}
Record.prototype.save = function() {
console.log("saving record " + this.id);
}
Record.prototype.delete = function() {
<!DOCTYPE html>
<script type="text/javascript">
var http = (function () {
var PublicInterface = {}
function request (verb, uri, payload) {
var uri = uri || "/",
payload = payload || ""
post_url failed to generate from {:controller=>"posts", :action=>"show", :locale=>#<Post id: 1, name: "abc", text: "test", created_at: "2010-06-07 14:30:17", updated_at: "2010-06-07 14:30:17">}, expected: {:controller=>"posts", :action=>"show"}, diff: {:locale=>#<Post id: 1, name: "abc", text: "test", created_at: "2010-06-07 14:30:17", updated_at: "2010-06-07 14:30:17">}
format.xml { render :xml => @post }
format.plist {
send_data(
@post.to_plist,
:type => "application/plist",
:filename => "post-#{@post.id}.plist",
:disposition => 'inline'
)
}
class Jeena
def Jeena::tuwas
puts "klassenmethode"
end
def tuwas
puts "instanzmethode"
end
end