Skip to content

Instantly share code, notes, and snippets.

View lizmat's full-sized avatar
💭
Functioning within parameters

Elizabeth Mattijsen lizmat

💭
Functioning within parameters
View GitHub Profile
@lizmat
lizmat / gist:4f31120e7ca6bbebc16d
Created September 15, 2014 21:37
diff for adding CCLASS_CRLF
diff --git a/docs/ops.markdown b/docs/ops.markdown
index 30554c7..a71c968 100755
--- a/docs/ops.markdown
+++ b/docs/ops.markdown
@@ -1685,6 +1685,7 @@ constants below can be used in nqp as (e.g.) `nqp::const::CCLASS_ANY`.
* CCLASS_ALPHANUMERIC
* CCLASS_NEWLINE
* CCLASS_WORD
+ * CCLASS_CRLF
@lizmat
lizmat / gist:ab00347d5cc44a23c65b
Created October 20, 2014 21:55
take problems on JVM
sub ROLLPICKGRABN( # N times
$self, $count, @pairs is rw, :$keep
) is hidden_from_backtrace {
my Int $total = $self.total;
my Int $rand;
my Int $seen;
my int $todo = ($keep ?? $count !! ($total min $count)) + 1;
gather {
while $todo = $todo - 1 {
@lizmat
lizmat / gist:16382a07084c5bb33d19
Created October 20, 2014 22:03
using private method instead of sub confuses the VM
$ git diff
diff --git a/src/core/Baggy.pm b/src/core/Baggy.pm
index 060b74f..56110d5 100644
--- a/src/core/Baggy.pm
+++ b/src/core/Baggy.pm
@@ -99,7 +99,7 @@ my role Baggy does QuantHash {
proto method grab(|) { * }
multi method grab(Baggy:D:) {
- my \grabbed := ROLLPICKGRAB1(self,%!elems.values);
@lizmat
lizmat / gist:c68fda121ea7078e52cc
Last active August 29, 2015 14:14
diff so far
diff --git a/src/io/fileops.c b/src/io/fileops.c
index 309d1be..873ca8c 100644
--- a/src/io/fileops.c
+++ b/src/io/fileops.c
@@ -440,3 +440,14 @@ void MVM_file_symlink(MVMThreadContext *tc, MVMString *oldpath, MVMString *newpa
MVM_free(oldpath_s);
MVM_free(newpath_s);
}
+
+MVMString * MVM_file_readlink(MVMThreadContext *tc, MVMString *path) {
@lizmat
lizmat / gist:243be8a85efba7bbd614
Created February 16, 2015 13:17
make test failures on parrot
LizyPro-2:rakudo.parrot liz$ make test
/usr/local/bin/perl t/harness t/00-parrot t/01-sanity t/04-nativecall
t/01-sanity/03-op-logic.t ............ ok
t/01-sanity/02-op-math.t ............. ok
t/01-sanity/01-literals.t ............ ok
t/01-sanity/05-var.t ................. ok
t/01-sanity/04-op-cmp.t .............. ok
t/01-sanity/07-op-string.t ........... ok
t/00-parrot/09-pir.t ................. ok
t/01-sanity/06-op-inplace.t .......... ok
@lizmat
lizmat / gist:a4f4646711a72d4c4211
Created February 16, 2015 13:20
make test failures on jvm
LizyPro-2:rakudo.jvm liz$ make test
/usr/local/bin/perl t/harness --jvm t/01-sanity
t/01-sanity/01-literals.t ............ ok
t/01-sanity/02-op-math.t ............. ok
t/01-sanity/03-op-logic.t ............ ok
t/01-sanity/04-op-cmp.t .............. ok
t/01-sanity/05-var.t ................. ok
t/01-sanity/06-op-inplace.t .......... ok
t/01-sanity/07-op-string.t ........... ok
t/01-sanity/08-var-array.t ........... ok
@lizmat
lizmat / gist:87b2db1a6d058dc8c21e
Created February 17, 2015 16:41
runner + output
$ cat `which perl6-j`
#!/bin/sh
exec java -noverify -Xms100m -Xbootclasspath/a:/Users/liz/Github/rakudo.jvm/install/languages/nqp/runtime/asm-4.1.jar:/Users/liz/Github/rakudo.jvm/install/languages/nqp/runtime/asm-tree-4.1.jar:/Users/liz/Github/rakudo.jvm/install/languages/nqp/runtime/jline-1.0.jar:/Users/liz/Github/rakudo.jvm/install/languages/nqp/runtime/jna.jar:/Users/liz/Github/rakudo.jvm/install/languages/nqp/runtime/nqp-runtime.jar:/Users/liz/Github/rakudo.jvm/install/languages/nqp/lib/nqp.jar:/Users/liz/Github/rakudo.jvm/install/languages/perl6/runtime/rakudo-runtime.jar:/Users/liz/Github/rakudo.jvm/install/languages/perl6/runtime/perl6.jar -cp $CLASSPATH:/Users/liz/Github/rakudo.jvm/install/languages/perl6/runtime:/Users/liz/Github/rakudo.jvm/install/languages/perl6/lib:/Users/liz/Github/rakudo.jvm/install/languages/nqp/lib -Dperl6.prefix=/Users/liz/Github/rakudo.jvm/install -Dperl6.execname="$0" -Djna.library.path=/Users/liz/Github/rakudo.jvm perl6 "$@"
$ perl6-j t/04-nativecall/01-argless.t
1..3
jav
@lizmat
lizmat / gist:695c8187f5279ab41c88
Created February 21, 2015 22:50
make substr-rw work like substr, but make substr 2.5x as slow
diff --git a/src/core/Str.pm b/src/core/Str.pm
index 0cb832a..57bf2cf 100644
--- a/src/core/Str.pm
+++ b/src/core/Str.pm
@@ -1556,64 +1556,79 @@ sub chrs(*@c) returns Str:D {
@c.map({.chr}).join;
}
-sub substr(Str() \what, \from, $chars?) {
- my str $str = nqp::unbox_s(what);
@lizmat
lizmat / gist:c54a35f3002ff0eee070
Created February 24, 2015 13:01
Initial implementation of "substr-fields"
Proof-of-concept:
The substr-fields() sub creates fields in a string, and allows indexed access to those fields, increasing / shrinking the fields as appropriate if they're changed.
The first parameter is the string on which to operate.
THe other parameters are from/chars pairs, just like you would use them in a substr(). In this implementation, there are no checks on validity of parameters passed: they must all be in ascending order and not overlap.
Comments welcome!
@lizmat
lizmat / gist:a10b3e6b659cfe7dd762
Last active August 29, 2015 14:19
Diff for lazy @*INC initialization
diff --git a/src/core/Inc.pm b/src/core/Inc.pm
index 3d6f07f..5b246f4 100644
--- a/src/core/Inc.pm
+++ b/src/core/Inc.pm
@@ -1,4 +1,4 @@
-{
+sub INIT-INC-CUSTOM_LIB($inc) {
my @INC;
my %CUSTOM_LIB;