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
# | |
# Perlのオブジェクト指向なコードを書いてみる | |
# http://codepad.org/z5axBdJP | |
# | |
use strict; | |
use warnings; | |
# 名前空間(パッケージ)の宣言。 | |
# すべてのパッケージは暗黙のルートパッケージ main に属する。 | |
package PerlOop; |
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
# http://codepad.org/Ee48yTys | |
use Benchmark; | |
$t0 = new Benchmark; | |
for (1..1000000) {} | |
$t1 = new Benchmark; | |
$td = timediff($t1, $t0); | |
print "the code took:",timestr($td),"\n"; |
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
# http://codepad.org/utbefxEC | |
use List::Util qw(shuffle); | |
print join ',', shuffle(1..40); | |
#-> 31,4,39,27,40,5,2,14,9,29,8,37,20,17,30,24,15,33,36,10,18,32,28,11,6,21,12,25,35,34,19,7,26,1,38,23,3,13,22,16 |
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
# | |
# 配列の要素数、配列の添え字最大値を求めるには | |
# http://codepad.org/SrwvXijK | |
# | |
use strict; | |
my @hoge = (1,2,3); | |
my $fuga = [1,2,3]; | |
print scalar @hoge, $#hoge; | |
print scalar @{$fuga}, $#$fuga; |
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
# DNS PTR record lookup | |
# 標準入力から与えられたIPアドレスのリストを逆引きして出力する | |
use strict; | |
use Net::DNS; | |
my $resolver = Net::DNS::Resolver->new(); | |
while (<>) { | |
chomp; | |
my $ipaddress = $_; | |
my $query = $resolver->search($ipaddress, 'PTR'); | |
unless ($query) { |
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
package jp.windish.utils; | |
/** | |
* Dice rolling class. | |
* <pre> | |
* Dice d1 = new Dice(); // 2d6 (default) | |
* Dice d3 = new Dice(100); // d100 | |
* Dice d2 = new Dice(2, 8); // 2d8 | |
* System.out.println(d1.roll()); //=> 1 to 6 at random | |
* </pre> |
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
# Solv: http://cp1.nintendo.co.jp/ | |
x = 1 | |
while true | |
if (x ** 17) % 3569 == 915 | |
break | |
end | |
x = x + 1 | |
end | |
puts x #=> 2012 |
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
# one-liner | |
# Markdown document to HTML from Text::Markdown | |
# | |
# perl -MText::Markdown=markdown -e "$txt='';while(<>){$txt.=$_};print markdown($txt);" < test.txt | |
# |
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
/* | |
Scala勉強中 | |
同じディレクトリに以下を置きます | |
twitter4j-core-x.x.x.jar | |
twitter4j.properties | |
dajare.txt | |
以下で実行します | |
$ scala -cp .;twitter4j-core-x.x.x.jar dajarebot.scala |
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 | |
// http://php.net/manual/ja/language.oop5.traits.php | |
trait Kanikama { | |
function eat_kani() { print "eat kanikama"; } | |
} | |
class Salad { | |
use Kanikama; | |
public function eat() { $this->eat_kani(); } |
OlderNewer