Skip to content

Instantly share code, notes, and snippets.

View yuya-takeyama's full-sized avatar
🎐
Humility, Kindness, Bonds

Yuya Takeyama yuya-takeyama

🎐
Humility, Kindness, Bonds
View GitHub Profile
<?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);
@yuya-takeyama
yuya-takeyama / Csv.php
Created September 30, 2010 16:23
An easy example of IteratorAggregate implementation.
<?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
{
@yuya-takeyama
yuya-takeyama / .gitignore
Created October 12, 2010 11:57
Observer Pattern implemented in C++.
observer
@yuya-takeyama
yuya-takeyama / echo_server.php
Created October 14, 2010 01:45
Various implementations of echo server.
<?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;
}
@yuya-takeyama
yuya-takeyama / counter.js
Created October 17, 2010 05:52
Closure examples.
// This works on Rhino.
var counter = (function () {
var i = 1;
return function () {
return i++;
};
})();
print(counter()); // 1
@yuya-takeyama
yuya-takeyama / crontab.txt
Created October 17, 2010 09:47
Script updates IP address of Dynamic DNS hosted on DDO.jp.
47 18 * * * perl /path/to/ddoupdate.pl your_sub_domain your_password >> /path/to/logfile
@yuya-takeyama
yuya-takeyama / syntax-highlighter-minimizer.rb
Created November 4, 2010 16:30
A script minimizes syntax highlighter JavaScript files.
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
@yuya-takeyama
yuya-takeyama / make_ngram_addresses.php
Created November 7, 2010 09:07
Script generates N-gram from csv and inserts to MySQL.
<?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';
@yuya-takeyama
yuya-takeyama / wp-social-bookmarking-light.patch
Created November 13, 2010 06:59
A patch makes WP Social Bookmarking Light visible on top page.
diff --git a/public_html/wp-content/plugins/wp-social-bookmarking-light/wp-social-bookmarking-light.php b/public_html/wp-content/plugins/wp-social-bookmarkin
index 6c08727..d9bbba5 100644
--- a/public_html/wp-content/plugins/wp-social-bookmarking-light/wp-social-bookmarking-light.php
+++ b/public_html/wp-content/plugins/wp-social-bookmarking-light/wp-social-bookmarking-light.php
@@ -123,8 +123,12 @@ class WpSocialBookmarkingLight
*/
function twitter()
{
- return $this->link_raw( '<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal">Tweet</a>'
- .'<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>' );
puts "Hello, World!"