hoge
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
#!/bin/sh | |
if [ $# -gt 0 ]; then | |
NAME=$1 | |
virt-install \ | |
--paravirt \ | |
--name=$NAME \ | |
--vcpus=1 \ | |
--ram=256 \ |
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 perl | |
# Download PICS from HTML link in specified page. | |
# http://fetinavi.blog9.fc2.com/ | |
use strict; | |
use warnings; | |
use HTML::LinkExtor; | |
use IO::File; | |
use LWP::UserAgent; | |
use URI; | |
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 | |
mb_internal_encoding('EUC-JP'); | |
// http://www.smarty.net/docs/en/charset.tpl | |
// define('SMARTY_RESOURCE_CHAR_SET', 'EUC-JP'); | |
require_once 'lib/smarty/Smarty.class.php'; // Smarty3 | |
print mb_internal_encoding() . "\n"; // => EUC-JP | |
$smarty = new Smarty(); |
モジュールでは private 宣言しても private メソッドにならないけど、class << self
して特異クラスになると private メソッドを定義できるようになる。
$ irb
irb(main):001:0> module Foo
irb(main):002:1> def self.hello
irb(main):003:2> puts "Hello"
irb(main):004:2> end
irb(main):005:1> end
=> :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
#!/usr/bin/env ruby | |
# http://codekata.com/kata/kata02-karate-chop/ | |
require 'test/unit' | |
def chop(target, values) | |
index = values.index(target) | |
index.nil? ? -1 : index | |
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
#!/usr/bin/env ruby | |
# http://codekata.com/kata/kata02-karate-chop/ | |
require 'minitest/autorun' | |
def chop(target, values) | |
min_index = 0 | |
half_index = values.length / 2 | |
max_index = values.length - 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
#!/usr/bin/env ruby | |
# http://codekata.com/kata/kata02-karate-chop/ | |
require 'test/unit' | |
def chop(target, values) | |
index = values.length / 2 | |
return index if values[index] == target | |
return -1 if index.zero? |
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 | |
# http://codekata.com/kata/kata02-karate-chop/ | |
require 'test/unit' | |
def chop(target, values) | |
middle = values.length / 2 | |
return -1 if values[middle].nil? | |
return middle if target == values[middle] |
OlderNewer