This file contains hidden or 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
Object.prototype.foo = 4; | |
var bar = {}; | |
bar.baz = 5; | |
for(var prop in bar) { | |
console.log(prop); | |
} | |
/* | |
logs: |
This file contains hidden or 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
function fitness(chromosome){ | |
// higher fitness is better | |
var f = 0; // start at 0 - the best fitness | |
for(var i=0, c=target.length ; i<c ; i++) { | |
// subtract the ascii difference between the target char and the chromosome char | |
// Thus 'c' is fitter than 'd' when compared to 'a'. | |
f -= Math.abs(target.charCodeAt(i)-chromosome[i]); | |
} | |
return f; | |
} |
This file contains hidden or 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
<?php | |
class Foo { | |
public function __call($func, $args) { | |
if(method_exists($this,$func)) { | |
return call_user_func_array(array($this,$func),$args); | |
} | |
} | |
} |
This file contains hidden or 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
<?php | |
class Foo { | |
public function __call($func, $args) { | |
if(method_exists($this,$func)) { | |
return call_user_func_array(array($this,$func),$args); | |
} | |
} | |
private function bar() { | |
echo 'BAR'; | |
} |
This file contains hidden or 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
<?php | |
class Foo { | |
public function __call($func, $args) { | |
if(method_exists($this,$func)) { | |
return call_user_func_array(array($this,$func),$args); | |
} | |
} | |
} | |
class SomeChild extends Foo { |
This file contains hidden or 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
<?php | |
class Foo extends AnotherClass { | |
public function __call($func, $args) { | |
if(method_exists($this,$func)) { | |
return call_user_func_array(array($this,$func),$args); | |
} | |
} | |
} |
This file contains hidden or 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
// declare shorthand vars | |
var o=document.body,c=o.children[0],w=4096,n=256,t=c.getContext("2d"),s=x=y=0; | |
// set canvas dimensions and background | |
c.width=c.height=w;c.style.background='#DDD'; | |
// add a pretty description | |
h=document.createElement('p'); | |
h.innerHTML='<p style="font-family:verdana;font-size:10pt;">All<b style="color:red;">R</b><b style="color:#0F0;">G</b><b style="color:blue;">B</b> entry in JS, in 719b. Rendering every RGB colour exactly once '+w+'x'+w+'px - '+(w*w)+' cols.</p>'; | |
o.insertBefore(h,o.firstChild); |
This file contains hidden or 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
this.foo = 1; | |
console.log(this.foo); // 1 | |
function First() { | |
this.foo = 2; | |
console.log(this.foo); // 2 | |
} | |
First(); |
This file contains hidden or 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 rawAnswers = [38,264,35]; | |
// Truncate eg 12345 to 12 to account for data errors. | |
var answers = []; | |
rawAnswers.forEach(function(e, i, c) { | |
answers.push(parseInt(e.toString().substring(0,2))); | |
}); | |
var correct=0,sum=0,b=[], mode='', maxi=0; |
This file contains hidden or 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
$ telnet couchdb portno | |
Trying [ipaddress]... | |
Connected to couchdb | |
Escape character is '^]'. | |
GET /dbname/_design/dname/_view/viewname?key="keyname"&include_docs=true&limit=20&descending=true | |
HTTP/1.1 200 OK | |
X-Couch-Request-ID: 9dc69414 | |
Server: CouchDB/1.1.1 (Erlang OTP/R14B01) | |
Etag: eb2051218277fa86006969ac40867b28 | |
Date: Mon, 17 Sep 2012 08:28:02 GMT |