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 | |
function camelize($input, $lower = false) | |
{ | |
$result = ''; | |
$words = explode('_', $input); | |
$wordCount = count($words); | |
for ($i = 0; $i < $wordCount; $i++) { | |
$word = $words[$i]; | |
if (!($i === 0 && $lower === false)) { | |
$word = ucfirst($word); |
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 | |
/** | |
* Csv file iterator. | |
* An easy example of IteratorAggregate implementation. | |
* Iteration logics are provided by SplFileObject. | |
* | |
* @author Yuya Takeyama <sign.of.the.wolf.pentagram@gmail.com> | |
*/ | |
class Csv implements IteratorAggregate | |
{ |
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
observer |
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 | |
$server = socket_create_listen(12345); | |
echo "Listening..." . PHP_EOL; | |
while (true) { | |
$client = socket_accept($server); | |
$receivedInput = chop(socket_read($client, 1024)); | |
echo "Received Input: " . $receivedInput . PHP_EOL; | |
if (strlen($receivedInput) === 0) { | |
break; | |
} |
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 works on Rhino. | |
var counter = (function () { | |
var i = 1; | |
return function () { | |
return i++; | |
}; | |
})(); | |
print(counter()); // 1 |
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
47 18 * * * perl /path/to/ddoupdate.pl your_sub_domain your_password >> /path/to/logfile |
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
require 'jsmin' | |
if ARGV[0].nil? or not Dir.exist?(ARGV[0]) | |
puts "Usage: ruby #{$0} [Path to syntax highligter JavaScript directory]" | |
exit | |
end | |
path = ARGV[0].sub(%r{/$}, '') | |
scripts = Dir.glob(path + "/sh*.js").sort_by {|s| s.scan(%r{/shCore.js$}).size }.reverse |
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 | |
/** | |
* Script generates N-gram from csv and inserts to MySQL. | |
* The csv can be downloaded from JapanPost website. | |
* http://www.post.japanpost.jp/zipcode/download.html | |
* | |
* @author Yuya Takeyama | |
*/ | |
require_once 'Text/Ngram.php'; |
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
puts "Hello, World!" |