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 | |
/** | |
* Returns a html to preload images using jQuery. | |
* | |
* @param array $urls An array of image URLs | |
* @return string HTML contents | |
*/ | |
function preload_images($urls) | |
{ | |
if (!is_array($urls)) { |
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 DIContainer | |
{ | |
private $components = array(); | |
/** | |
* 指定された名前でコンポーネントを登録します。 | |
* | |
* @param string $name 登録する際の名前 | |
* @param mixed $value コンポーネントとして登録する値 |
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
if ($date->before(SUMMER_START) || $date->after(SUMMER_END)) { | |
$charge = $quantity * $this->winter_rate + $this->winter_service_charge; | |
} else { | |
$charge = $quantity * $this->summer_rate; | |
} |
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
if ($this->notSummer($date)) { | |
$charge = $this->winterCharge($quantity); | |
} else { | |
$charge = $this->summerCharge($quantity); | |
} | |
... | |
/** | |
* 指定された日付が夏以外かどうかを返します。 |
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
#!/usr/bin/env ruby | |
# -*- coding:utf-8; mode:ruby-mode -*- | |
require 'rubygems' | |
require 'shorturl' | |
ARGF.each do |line| | |
puts line.gsub(%r|(s?https?://[-_.!~*'a-zA-Z0-9;/?:@&=+$,%#]+)|) {|s| ShortURL.shorten($1)} | |
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
<?php | |
// ドキュメントインスタンスを生成する | |
$doc = new HaruDoc; | |
// 日本語エンコーディングを利用する | |
$doc->useJPEncodings(); | |
// 日本語フォントを利用する | |
$doc->useJPFonts(); |
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
// Jaml(http://github.com/edspencer/jaml) practice. | |
var sys = require('sys'); | |
require('./Jaml-all'); | |
Jaml.register('simple', function() { | |
div( | |
h1("Hello") | |
); | |
}); |
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 'ice_cube' | |
require 'active_support' | |
include IceCube | |
# 開始日を指定してScheduleインスタンスを生成 | |
schedule = Schedule.new(Time.utc(2010, 7, 1)) | |
# 2010年7月の5の付く日をスケジュールに追加 | |
(5..30).step(5) do |day| |
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
$ brew install neon | |
==> Downloading http://www.webdav.org/neon/neon-0.29.3.tar.gz | |
File already downloaded and cached to /Users/juno/Library/Caches/Homebrew | |
==> ./configure --prefix=/usr/local/Cellar/neon/0.29.3 --disable-debug --enable-shared --disable-static --with-ssl | |
==> make install | |
/usr/bin/install -c -d /usr/local/Cellar/neon/0.29.3/include/neon | |
Installing ne_request.h into /usr/local/Cellar/neon/0.29.3/include/neon | |
/bin/sh ../libtool --quiet --mode=compile /usr/bin/cc -DHAVE_CONFIG_H -no-cpp-precomp -I.. -O3 -march=core2 -msse4.1 -w -pipe -c ne_request.c -o ne_request.lo | |
Installing ne_session.h into /usr/local/Cellar/neon/0.29.3/include/neon | |
Installing ne_utils.h into /usr/local/Cellar/neon/0.29.3/include/neon |
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
#!/usr/bin/env ruby | |
require 'base64' | |
f = open(ARGV[0]) | |
data = f.read | |
f.close | |
puts "data:image/png;base64,#{Base64.encode64(data).gsub(/\n/, '')}" |
OlderNewer