Skip to content

Instantly share code, notes, and snippets.

@pmurias
pmurias / bug.js
Created April 6, 2019 14:28
chrome bug?
const array = [0,1,2,3,4,5,6];
array.shift();
array.shift();
array.shift();
array[3] = '_set_';
array[10] = '_set_';
console.log('atpos', array.map(x => x.toString()).join(','));
@pmurias
pmurias / gist:d868e9c9d5421d741bbd3d110b5ff55f
Created January 15, 2019 19:04
async/await stacks sometimes work
async function bottom() {
console.log('in bottom');
const stack = new Error().stack;
console.log('stack:', '<<<' + stack + '>>>');
console.log(typeof stack);
console.trace('stack trace');
}
async function middle() {
await bottom();
@pmurias
pmurias / gist:292b3ac5b672d9e690d823aca1ecc767
Created January 11, 2019 10:28
Ruby style dsls and ast tree correspondence.
Q::Block.new(Q::Statement::Expr.new(Q::Postfix::Call.new(
Q::Identifier.new("say"),
Q::Literal::Str.new("OH HAI")
)));
block {
expr {
call {
identifier "say";
str "OH HAI";
@pmurias
pmurias / test_precompiled.p6
Created January 2, 2019 16:56
A script to run tests under precompilation
my $precompiled_tests = 't/precompiled'.IO;
mkdir($precompiled_tests);
for @*ARGS.map(*.IO) -> $file {
my $name-part = $file.relative($file.parent.parent).IO;
my $module = $file.basename.IO.extension('', :parts(0..*));
if ($module ~~ /^\d/) {
$module = 'module_' ~ $module.Str;
@pmurias
pmurias / index.html
Created October 17, 2018 14:17
A P6 DOM clock
Time: <span id="clockDisplay"></span>
@pmurias
pmurias / main.p6
Created October 14, 2018 18:19
99 Bottles of Beer
for 99...1 -> $bottles {
sing $bottles, :wall;
sing $bottles;
say "Take one down, pass it around";
sing $bottles - 1, :wall;
say "";
}
#| Prints a verse about a certain number of beers, possibly on a wall.
sub sing(
@pmurias
pmurias / main.p6
Created October 14, 2018 17:56
Quicksort
# Empty list sorts to the empty list
multi quicksort([]) { () }
# Otherwise, extract first item as pivot...
multi quicksort([$pivot, *@rest]) {
# Partition.
my $before := @rest.grep(* before $pivot);
my $after := @rest.grep(* !before $pivot);
# Sort the partitions.
@pmurias
pmurias / main.p6
Last active October 22, 2018 14:18
Hello World
say("Hello World");
@pmurias
pmurias / main.dart
Created October 1, 2018 20:22
Test sharing
void main() {
print('Hello, World!');
}
@pmurias
pmurias / gist:6b6c08b35e9b697860ce24458a2de4d1
Created July 11, 2018 12:30
native-image -jar p6vm.ja
Build on Server(pid: 6196, port: 42749)
classlist: 175.64 ms
(cap): 787.16 ms
setup: 999.88 ms
analysis: 4,829.95 ms
error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Detected a started Thread in the image heap. This is not supported. The object was reached from a static initializer. All static class initialization is done during native image construction, thus a static initializer cannot contain code that captures state dependent on the build machine. Write your own initialization methods and call them explicitly from your main entry point.
Detailed message:
Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Detected a started Thread in the image heap. This is not supported. The object was reached from a static initializer. All static class initialization is done during native image construction, thus a static initializer cannot contain code that captures state dependent on the build machine. Write your own initialization metho