Skip to content

Instantly share code, notes, and snippets.

View VienosNotes's full-sized avatar

D.Aoki VienosNotes

View GitHub Profile
#include<stdio.h>
#include<math.h>
int main (int argc, char** argv) {
char* count = argv[1];
int d = 0;
int ans = 0;
while (*(count++) != '\0');
count -= 2;
do {
@VienosNotes
VienosNotes / cind.pl
Created February 26, 2012 09:27
なにかの画像を収集するスクリプト
use v6;
my @type = (1..3).list;
my @rare = (0..5).list;
my @num = (1..29).list;
my @plus = (1..3).list;
my $cmd;
for @type X @rare X @num X @plus -> $t, $r, $n, $p {
$cmd = 'wget http://example.com/directory/' ~ $t ~ $r ~ $n.fmt("%03d") ~ $p.fmt("%02d") ~ ".jpg";
@VienosNotes
VienosNotes / nomlish.txt
Created March 1, 2012 10:51
ノムリッシュ変換のテスト
#原文 (http://perldoc.jp/func/quotemeta)
EXPR の中のすべての非英数字キャラクタをバックスラッシュで エスケープしたものを返します (つまり、/[A-Za-z_0-9]/ にマッチしない全ての文字の前には ロケールに関わらずバックスラッシュが前置されます)。 これは、ダブルクォート文字列での \Q エスケープを 実装するための内部関数です。
EXPR が省略されると、$_ を使います。
クォートメタ (と \Q ... \E) は、文字列を正規表現に展開するのに 便利です; なぜなら、デフォルトでは展開された変数は小さな正規表現として 扱われるからです。 例えば:
my $sentence = 'The quick brown fox jumped over the lazy dog';
my $substring = 'quick.*?fox';
$sentence =~ s{$substring}{big bad wolf};
@VienosNotes
VienosNotes / libsox.c
Created March 13, 2012 16:08
LibSoX for Ruby
#include <sox.h>
#include "ruby.h"
#include <stdlib.h>
#include <assert.h>
typedef struct sox_target {
sox_format_t * in;
sox_format_t * out;
sox_effects_chain_t * chain;
} sox_target_t;
@VienosNotes
VienosNotes / chara_make.pl
Created April 14, 2012 11:15
character making for CoC
use 5.14.0;
use List::Util qw/sum/;
use Tie::IxHash;
use Data::Dumper;
use POSIX;
my @params_a = ("STR", "CON", "POW", "DEX", "APP");
my @params_b = ("SIZ", "INT");
my %all;
@VienosNotes
VienosNotes / XML-Parser.pl
Created April 19, 2012 15:31
Minimal XML Parser for Perl6 with Grammars
use v6;
grammar XML {
token word { \w+ }
token element { [ $<characters>=(<.word>+ % <.ws>) || <tag>] }
token attr { $<attr_name>=<word> '=' '"' $<attr_val>=<word> '"' }
token tag {
'<' $<tag_name>=<word> <.ws> [<attr>+ % <.ws>]? '>' <.ws>
[<element>* % <.ws>] <.ws>
'</' <{$<tag_name>}> '>'
@VienosNotes
VienosNotes / gist:3060244
Created July 6, 2012 13:46
Error log with building Rakudo
Error log says that
---
% ./Configure.pl --gen-parrot
Bareword found where operator expected at lib/lib.pm line 3, near "@*INC"
(Missing operator before INC?)
Operator or semicolon missing before *INC at lib/lib.pm line 3.
Ambiguous use of * resolved as operator * at lib/lib.pm line 3.
syntax error at lib/lib.pm line 3, near "@*INC"
Compilation failed in require at ./Configure.pl line 10.
BEGIN failed--compilation aborted at ./Configure.pl line 10.
@VienosNotes
VienosNotes / coin.pl
Created July 9, 2012 06:46
コインを10枚振った時のすべての組み合わせを、表の出た回数別に分けて出力する
use v6;
my @count = 0 xx 10;
my @tmp;
my $i;
for 0..1023 -> $n {
$i = 0;
@tmp = $n.fmt("%010b").comb;
for @tmp {
@VienosNotes
VienosNotes / minecraft_hajini.pl
Created August 3, 2012 08:16
マインクラフト廃人ランキング生成スクリプト
class User {
has Int $.count is rw;
has Int $.time is rw;
has DateTime $.lastlogin is rw;
method new () {
return self.bless(*, count => 1, time => 0);
}
}
role Minecraft::ServerLog::Actions {
@VienosNotes
VienosNotes / dec_to_n.pl
Created October 1, 2012 22:33
10進数から任意のN進数への変換 with Perl6
use v6;
sub MAIN ($n! is copy, $radix = "2**31") {
my $num_radix = eval $radix.Str;
my $num_n = eval $n.Str;
CATCH {
die "something is wrong!";
}