Skip to content

Instantly share code, notes, and snippets.

View yukkuri.txt
   _,,....,,_  _人人人人人人人人人人人人人人人_
-''":::::::::::::`''>   ゆっくりしていってね!!!   <
ヽ::::::::::::::::::::: ̄^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^ ̄
 |::::::;ノ´ ̄\:::::::::::\_,. -‐ァ     __   _____   ______
 |::::ノ   ヽ、ヽr-r'"´  (.__    ,´ _,, '-´ ̄ ̄`-ゝ 、_ イ、
_,.!イ_  _,.ヘーァ'二ハ二ヽ、へ,_7   'r ´          ヽ、ン、
::::::rー''7コ-‐'"´    ;  ', `ヽ/`7 ,'==─-      -─==', i
r-'ァ'"´/  /! ハ  ハ  !  iヾ_ノ i イ iゝ、イ人レ/_ルヽイ i |
!イ´ ,' | /__,.!/ V 、!__ハ  ,' ,ゝ レリイi (ヒ_]     ヒ_ン ).| .|、i .||
`!  !/レi' (ヒ_]     ヒ_ン レ'i ノ   !Y!""  ,___,   "" 「 !ノ i |
View gist:2605
require 'benchmark'
puts Benchmark.measure {
(2..100).select { |n| '_' * n !~ /\A(__+)\1+\z/ }
}
puts ">_<X"
puts ">_<X"
puts ">_<X"
puts ">_<X"
View gist:2619
class Problem
attr_reader :x, :y, :op
def initialize(op, x, y)
@op = op
@x = x
@y = y
end
View gist:5521
open my $ruby, '|/opt/local/bin/ruby';
print $ruby 'puts "hello"';
close $ruby;
View gist:8599
tell application "iTunes"
play
repeat while (true)
delay 1
next track
end repeat
end tell
View gist:9517
#!/usr/bin/env perl
use strict;
use warnings;
use Perl6::Say;
use Data::Dumper;
use Test::More qw(no_plan);
sub p ($) {
say Dumper @_;
}
View gist:9524
#!/usr/bin/env perl
use strict;
use warnings;
sub bucket_sort {
my ($array, $range) = @_;
my @bucket;
push @{ $bucket[$_] ||= [] }, $_ for @$array;
return [ map {@{$bucket[$_]}} grep {$bucket[$_]} (0..$range) ];
}
View gist:9601
#!/usr/bin/env perl
use strict;
use warnings;
use Perl6::Say;
use Data::Dumper;
#use Test::More qw(no_plan);
sub p ($) {
say Dumper @_;
}
View gist:9654
sub bubble_sort {
my ($array) = @_;
for my $i (0..$#$array) {
for my $j (0..($#$array-$i-1)) {
if ($array->[$j] > $array->[$j+1]) {
($array->[$j], $array->[$j+1]) = ($array->[$j+1], $array->[$j]);
}
}
}
return $array;