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 python | |
# dynzoom.py - dynamic zooming for uzbl, based on dynzoom.js | |
# Usage: | |
# @on_event GEOMETRY_CHANGED spawn /path/to/dynzoom.py \@geometry 1024 768 | |
# Where 1024x768 is the resolution where we start to zoom out | |
import sys, re | |
" Parses WxH+X+Y into a 4-tuple of ints " |
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
use v6; | |
grammar Newick { | |
rule TOP { <node> ';' } | |
rule node { | |
<name> | | |
'(' (<neighbor=node>+)+ % ',' ')' <name>? | |
} | |
token name { [ <.alpha> | <.digit> ]+ } | |
} |
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
class Modular does Real { | |
has ($.n, $.modulo); | |
multi method new($n, :$modulo where * > 1) { | |
self.new: :n($n % $modulo), :$modulo | |
} | |
method Bridge { $.n % $.modulo } | |
multi method gist { "{self.Bridge} 「mod $.modulo」" } | |
method succ { self.Bridge.succ % $.modulo } | |
multi method Inverse { | |
my ($c, $d, $uc, $vc, $ud, $vd) = ($.n, $.modulo, 1, 0, 0, 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
use v6; | |
my $sample = q :to 'STOP'; | |
(cat)dog; | |
dog cat | |
(dog,cat); | |
dog cat | |
STOP |
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
==> Testing panda | |
t/panda/builder.t .... ok | |
t/panda/common.t ..... ok | |
t/panda/ecosystem.t .. ok | |
t/panda/fetcher.t .... ok | |
t/panda/installer.t .. ok | |
t/panda/tester.t ..... ok | |
t/stubs.t ............ ok | |
All tests successful. | |
Files=7, Tests=49, 36 wallclock secs ( 0.16 usr 0.02 sys + 31.56 cusr 1.80 csys = 33.54 CPU) |
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
use v6; | |
my $sample = "((((((((((((((Odobenus_clarus)Opheodrys_nippon)Seokia_dignus,((Megaloperdix_coloratovillosum,(Ceratophrys_perrotetii)Cuora_boa)Meles_subminiatus,Megaloperdix_terrestris,(Boiga_lobatus)Caiman_brevirostris)Scolopendra_kopsteini)Thecla_temminskii,Nyctaalus_schrencki)Tupinambus_krueperi)Uncia_ornata,Trapelus_monorhis,(((Melanocoryhpa_australis,(Chelydra_mystacinus)Crotaphytus_mitratus)Streptopelia_mutabilis,Pterocles_caucasicus,(((Aegialifes_colombianus)Castor_ferox)Coenobita_glaucescens)Hyperoodon_hardwickii,Equus_relictus)Streptopelia_similis,((Eurynorhynchus_serricollis)Salvelinus_clypeatus,Pyrgilauda_glaucescens,(Aplopeltura_venulosa)Machetes_trianguligerus,Coleonyx_nupta)Spalerosophis_indicus)Thymallus_stellio,((Eucratoscelus_iguana)Machetes_penelope,Ahaetulla_melanoleucus)Sitta_quadriocellata,(Ameiva_crassidens)Oenanthe_longipennis)Ursus_himalayensis,((Acanthosaura_rusticolus)Thymallus_olivacea,Phrynohyas_dominicus)Tiliqua_cavimanus,(Limosa_glacialis,Eryx_guttata,Bubulcus_altaica)Myot |
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
use v6; | |
my @data = '10', '{1, 2, 3, 4, 5}', '{2, 8, 5, 10}'; | |
my Set $N .= new: 1 .. @data.shift.Int; | |
my Set $A .= new: eval @data.shift.subst(/<[{}]>/, '', :g); | |
my Set $B .= new: eval @data.shift.subst(/<[{}]>/, '', :g); | |
sub infix:<∩>(Set \A, Set \B) { Set.new: B.list.grep: * eq any A.list } | |
sub infix:<∪>(Set \A, Set \B) { Set.new: |$A.list, |$B.list } |
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
use strict; | |
use warnings; | |
my @sample = map { chomp; $_ } <>; #qw{TGAT CATG TCAT ATGC CATC CATC}; | |
sub revc { my $_ = join '', reverse split //, shift; tr/ACGT/TGCA/; $_ } | |
my %SSrc; $SSrc{$_}++ for @sample, map { revc($_) } @sample; | |
for (keys %SSrc) { | |
printf "(%s, %s)\n", substr($_, 0, -1), substr($_, 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
class Modular does Real { | |
our $.Modulus; | |
has ($.residue, $.modulus); | |
multi method new($residue, :$modulus where * > 1) { self.new: :residue($residue % $modulus), :$modulus } | |
method Bridge { $.residue % $.modulus } | |
multi method gist { "{self.Bridge} 「mod $.modulus」" } | |
method succ { self.Bridge.succ % $.modulus } | |
multi method Inverse { | |
return Mu unless $.residue gcd $.modulus == 1; | |
my ($c, $d, $uc, $vc, $ud, $vd) = ($.residue, $.modulus, 1, 0, 0, 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
sub infix:<o>(&f, &g) { -> $x { &f(&g($x)) } } | |
sub continued-fraction(@a, @b) | |
{ | |
gather for [\o] (@a.shift + @b.shift / *) xx * { | |
take .(Inf) | |
} | |
} | |
say continued-fraction((1, 2 xx *).list, (1 xx *).list)[3]; |
OlderNewer