Skip to content

Instantly share code, notes, and snippets.

View araraloren's full-sized avatar
🏠
Working from home

loren araraloren

🏠
Working from home
View GitHub Profile
@araraloren
araraloren / Perl6
Created December 28, 2015 14:57
Perl6
# some comment ....
EN -> value1
CN -> value2
EN -> value3
CN -> value4
-------------------above is inputfile content
###sample code
my $pattern = "value1";
my @lines = "inputfile".IO.lines;
@araraloren
araraloren / update-to-ftp.p6
Created January 16, 2017 11:21
use perl5 Net::FTP module in perl6
#!/usr/bin/perl6
use JSON::Fast;
use Inline::Perl5;
#`{
{
"user-list":[
"xxx"
],
@araraloren
araraloren / out-parameters.adoc
Last active January 16, 2017 14:12
perl6 nativecall with out parameters

We have a c source file: something.c

int xmode(char** str)
{
  (*str)[0] = 'X';
	(*str) ++; // xmode modified *str
	return 0;
}
@araraloren
araraloren / slice.p6
Created January 19, 2017 15:47
slice for perl6
#!/usr/bin/env perl6
class SliceThing {
has $.f;
has $.t;
}
sub infix:<<':'>>(Int $f, Int $t) {
return SliceThing.new(f => $f, t => $t);
}
@araraloren
araraloren / NC-callback.p6
Last active February 28, 2017 16:37
NativeCall callback
c code, compiler to libgetint.so :
#include <stdio.h>
int getint()
{
return 42;
}
int setint(int* ptr, int(*get)())
{
@araraloren
araraloren / output.p6
Last active May 5, 2017 17:05
perl6 -Ilib ./bin/galaxy.p6 laws bin/laws rakudostar-0.7-x86_64
new output:
Level 0 elems: 5
star =>
Level 1 elems: 6
core => NQPMu
name => Str|rakudostar
star => Str|rakudostar-0.7-x86_64
tag => NQPMu
form => NQPMu
@araraloren
araraloren / htmlparser.p6
Last active May 12, 2017 08:10
HTML grammar for perl6 doc index
#!/usr/bin/env perl6
use v6;
# not support innser html in paragraph
# not support single-tag like <x>
# the test source https://docs.perl6.org/language.html, without not support part
grammar HTML {
rule TOP {
<html>
@araraloren
araraloren / hosts.p6
Created May 17, 2017 07:53
Parse a sample file, distinguishing newline
127.0.0.1 dp.559.cc
127.0.0.1 1.yhzm.cc
127.0.0.1 sta.jcjk0451.com
127.0.0.1 www.716703.com
127.0.0.1 www.hao934.com
127.0.0.1 p.kjwx8.com
127.0.0.1 pdl.gionee.com
127.0.0.1 ads.gionee.com
127.0.0.1 info.yitsoftware.com
127.0.0.1 www.1680go.com
@araraloren
araraloren / ping-pong.p6
Created May 23, 2017 08:28
Ping Pong in Perl6
#!/usr/bin/env perl6
class Spawn {
has &.cb;
has @.args;
has $.name;
has $.in = Channel.new;
method receive() {
return $!in.receive;
@araraloren
araraloren / pap.p6
Created May 27, 2017 09:25
Proc::Async::Pool
#!/usr/bin/env perl6
our $process-id-counter = 0;
class Process::Async {
has $.id;
has $.executable;
has @.args;
has $.program;
has @.flag;