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
/** | |
* Private members in JavaScript | |
* | |
* @author Yuya Takeyama | |
*/ | |
var Dog = (function () { | |
var Dog, | |
privateNameSpace = {}; | |
/** |
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
parser = Xml2Obj() | |
root = self.parser.parse("""<?xml version="1.0"?><parent id="top"><child1 name="paul">Text goes here</child1><child2 name="fred">More text</child2></parent>""") | |
# These have the same meaning. | |
print root.getElements('item1')[0].getData() | |
# => Text goes here | |
print root.item1[0].getData() | |
# => Text goes here |
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
<?php | |
/** | |
* addslashes() for multi-byte characters | |
* | |
* @param string $input Input characters | |
* @param string $enc Internal encoding (optional) | |
* @return string Charcters added slashes | |
*/ | |
function mb_addslashes($input, $enc = NULL) | |
{ |
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
# This script generates properties for PHP. | |
class String | |
def camelize | |
result = "" | |
self.split("_").each do |word| | |
result += word.capitalize | |
end | |
result | |
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
def qsort(arr: Array[Int]): Array[Int] = arr.length match { | |
case n if n <= 1 => arr | |
case _ => { | |
var pivot = arr(0) | |
qsort(arr.filter(x => x < pivot)) ++ arr.filter(x => x == pivot) ++ qsort(arr.filter(x => x > pivot)) | |
} | |
} |
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
<?php | |
class Calc | |
{ | |
public function add($a, $b) | |
{ | |
return $a + $b; | |
} | |
} |
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
<?php | |
class Calc | |
{ | |
public function add($a, $b, $c = NULL) | |
{ | |
if (isset($c)) { | |
return $a + $b + $c; | |
} else { | |
return $a + $b; | |
} |
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 Singleton = (function () { | |
var | |
obj = {}, | |
id, | |
init, | |
get_instance, | |
get_id; | |
init = function () { | |
id = Math.random(); |
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
n = 100 | |
r = [1, 2, 3, 4, 5].inject(0) {|n, i| n + i } | |
puts "r = " + r.to_s | |
puts "n = " + n.to_s |
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
<?php | |
/** | |
* List_Rubyfoo | |
* Rubyppoi array iterator for PHP. | |
* | |
* @author Yuya Takeyama <sign.of.the.wolf.pentagram@gmail.com> | |
*/ | |
class List_Rubyfoo implements Iterator, ArrayAccess, Countable | |
{ |
OlderNewer