Skip to content

Instantly share code, notes, and snippets.

View sergot's full-sized avatar

Filip Sergot sergot

  • Wrocław, Poland
View GitHub Profile
const fs = require('fs');
const path = require('path');
const PNG = require('pngjs').PNG;
const pixelmatch = require('pixelmatch');
const dir1 = 'dev4';
const dir2 = 'dev5';
fs.readdir(dir1, (err, files) => {
if (err) throw err;
@sergot
sergot / gist:56d54f782d1210ac6203
Created December 11, 2015 19:52
p6 errors occur every **first** run of changed program
Use of uninitialized value %ENV of type Any in string context
Any of .^name, .perl, .gist, or .say can stringify undefined things, if needed. in block at /home/local/filip.sergot/p6/sambal/lib/Sambal.pm:171
Use of uninitialized value %ENV of type Any in string context
Any of .^name, .perl, .gist, or .say can stringify undefined things, if needed. in block at /home/local/filip.sergot/p6/sambal/lib/Sambal.pm:171
Use of uninitialized value %ENV of type Any in string context
Any of .^name, .perl, .gist, or .say can stringify undefined things, if needed. in block at /home/local/filip.sergot/p6/sambal/lib/Sambal.pm:171
Use of uninitialized value %ENV of type Any in string context
Any of .^name, .perl, .gist, or .say can stringify undefined things, if needed. in block at /home/local/filip.sergot/p6/sambal/lib/Sambal.pm:171
Use of uninitialized value %ENV of type Any in string context
Any of .^name, .perl, .gist, or .say can stringify undefined things, if needed. in block at /home/local/filip.sergot/p6/samb
@sergot
sergot / gist:ac3c90fcef831274a22a
Created July 25, 2014 12:51
panda install NativeCall
==> Testing NativeCall
t/01-argless.t ......... ok
t/02-simple-args.t ..... ok
t/03-simple-returns.t .. ok
t/04-pointers.t ........ ok
t/05-arrays.t .......... 1/26 # Looks like you planned 26 tests, but ran 20
t/05-arrays.t .......... ok
t/06-struct.t .......... 1/30 # Looks like you planned 30 tests, but ran 19
t/06-struct.t .......... ok
t/07-writebarrier.t .... ok
@sergot
sergot / poll_perl6_vms
Last active August 29, 2015 13:58
[Perl 6] A poll about VMs.
Hey!
This is a poll about VMs for Perl 6. It would be awesome if you fill it,
just write a comment with your answers or fork it and edit.
I need it because I work on a huge summary (including, among the others, statistics, tests)
of VMs and Perl 6 itself.
Thank you very much in advance!
sergot
@sergot
sergot / strminus.pl6
Last active December 17, 2015 18:19
Removes string $b from string $a
use v6;
multi sub infix:<->(Str $a, Str $b) {
nqp::join('', nqp::split($b, $a));
}
say 'a b c' - ' ' - 'a';
say 5 - 2;
@sergot
sergot / golf.pl
Last active December 16, 2015 20:59
My solutions. masak/workshop
TODO
@sergot
sergot / gist:1900171
Created February 24, 2012 11:04
New &unlink
sub unlink($path) {
die "$path is not a file." if $path.IO.d;
try {
pir::new__PS('OS').rm($path);
}
$! ?? fail($!) !! Bool::True
}
@sergot
sergot / gist:1892277
Created February 23, 2012 10:56
rmdir function for Perl 6
use v6;
sub rmdir($path) {
die "$path does not exist." unless $path.IO.e;
die "$path is not a directory." unless $path.IO.d;
die "$path directory is not empty." if dir $path;
try {
pir::new__PS('OS').rm($path);
}
$! ?? fail($!) !! Bool::True;
@sergot
sergot / gist:1888091
Created February 22, 2012 22:47
rm_rf() for Perl 6
use v6;
use File::Find;
sub rm_rf(*@files) is export {
for @files -> $path {
for find(dir => $path).map({ .Str }).reverse -> $f {
$f.IO.d ?? rmdir($f) !! unlink($f);
}
rmdir $path;
}
@sergot
sergot / dump.c
Created November 2, 2011 14:57
Old Dump function.
void dump(const unsigned char *data_buffer, const unsigned int length) {
unsigned char byte;
unsigned int i, j;
for(i=0; i < length; i++) {
byte = data_buffer[i];
printf("%02x ", data_buffer[i]);
if(((i%16)==15) || (i==length-1)) {
for(j=0; j < 15-(i%16); j++)
printf(" ");
printf("| ");