Skip to content

Instantly share code, notes, and snippets.

View samcv's full-sized avatar

Samantha McVey samcv

  • Amsterdam, Netherlands
View GitHub Profile
use nqp;
my @a;
my Str $haystack = slurp 'tolstoy.txt';
add-to-list("index with single codepoint needle", test-index($haystack, "\x[01]"));
my $target = 'abdicatez';
add-to-list("index with word needle", test-index($haystack, $target));
my $new-haystack;
for $haystack.comb(($haystack.chars / 20).Int) {
$new-haystack ~= $_;
}
my $*test-count = 0;
my @results;
my $b1 = { .defined };
my $b2 = { 0 ≤ $_ };
my @blocks = $b1, $b2;
test-it({
my $b = 'a' x 999999 ~ 'b';
$b ~~ /b/ for ^400;
},
#$b1,
sub MAIN {
use Test;
my $char = 'a';
my @result = what-matches($char);
for @result {
ok EVAL("'$char' ~~ /$_/"), "$char ~~ /$_/";
}
}
use nqp;
sub what-matches (Str:D $chr) {
----
for @array -> $element { # good
  say $element;
}
for @array {
  .say # good
}
.say for @array; # better
# Enter your code here. Read input from STDIN. Print output to STDOUT
use feature 'say';
use v5.022;
use Data::Dumper;
my $lastAnswer = 0;
my $seqList = [];
#chomp(my $first_line = <STDIN>);
my $data = get_data("100 100
1 345255357 205970905
1 570256166 75865401
# Enter your code here. Read input from STDIN. Print output to STDOUT
use feature 'say';
use v5.022;
use Data::Dumper;
my $DEBUG = $ENV{da_DEBUG} // 1;
my $EVAL = $ENV{da_EVAL} // 0;
my $lastAnswer = 0;
my $seqList = [];
#chomp(my $first_line = <STDIN>);
my $data = get_data("100 100
<?xml version="1.0"?>
<!--*- mode: xml -*-->
<interface>
<object class="GtkWindow" id="main_window">
<property name="visible">True</property>
<property name="title" translatable="yes">Avahi Discovery</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="default_width">500</property>
@samcv
samcv / -
Created September 15, 2017 23:26
6 () {
local rl_text=''
if cmd-in-path rlwrap
then
rl_txt='rlwrap'
fi
if (( 0 < $# ))
then
local i
for i in $@
@samcv
samcv / -
Created September 12, 2017 09:23
diff --git a/lib/IRC/Client/Plugin/Github.pm6 b/lib/IRC/Client/Plugin/Github.pm6
index c62bda1..62e1be3 100644
--- a/lib/IRC/Client/Plugin/Github.pm6
+++ b/lib/IRC/Client/Plugin/Github.pm6
@@ -18,16 +18,15 @@ class IRC::Client::Plugin::Github does IRC::Client::Plugin
post "/" => sub {
my Str $event = request.headers<X_GITHUB_EVENT>.wordcase;
my Str $module = "IRC::Client::Plugin::Github::WebhookEvents::$event";
-
- if (::{"&{$module}"} ~~ Nil) {
@samcv
samcv / -
Created September 12, 2017 08:55
diff --git a/lib/IRC/Client/Plugin/Github.pm6 b/lib/IRC/Client/Plugin/Github.pm6
index c62bda1..4eee807 100644
--- a/lib/IRC/Client/Plugin/Github.pm6
+++ b/lib/IRC/Client/Plugin/Github.pm6
@@ -18,16 +18,15 @@ class IRC::Client::Plugin::Github does IRC::Client::Plugin
post "/" => sub {
my Str $event = request.headers<X_GITHUB_EVENT>.wordcase;
my Str $module = "IRC::Client::Plugin::Github::WebhookEvents::$event";
-
- if (::{"&{$module}"} ~~ Nil) {