View 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
/* | |
Scala勉強中 | |
同じディレクトリに以下を置きます | |
twitter4j-core-x.x.x.jar | |
twitter4j.properties | |
dajare.txt | |
以下で実行します | |
$ scala -cp .;twitter4j-core-x.x.x.jar dajarebot.scala |
View gist:72b7f8844c6402ea206f
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(); } |
View gist:4eae6401721b0faff338
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
import java.net.InetAddress; | |
import java.net.InterfaceAddress; | |
import java.net.NetworkInterface; | |
import java.net.SocketException; | |
import java.util.Enumeration; | |
public class BroadcastAddressTest { | |
public static void main(String[] args) throws SocketException { | |
BroadcastAddressTest client = new BroadcastAddressTest(); |
View file0.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
mysql -uuser_name db_name -p -B < sample.sql | sed -e 's/\t/,/g' > sample.csv |
View gist:2d4ea86058c1511be482
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 -e 'while(<index.html*>) { ($new = $_) =~ s/index\.html\?(.*)$/$1/; rename $_, $new }' |
View gist:2155294
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"; |
View gist:2155296
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 |
View gist:2155298
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; |
View gist:3167392
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) { |
View Dice.java
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> |
OlderNewer