Skip to content

Instantly share code, notes, and snippets.

@blippy
blippy / oleo-mc-01.patch
Last active March 26, 2017 12:09
Oleo compilation patch for CVS 26-Mar-2017
Index: configure.in
===================================================================
RCS file: /sources/oleo/oleo/configure.in,v
retrieving revision 1.96
diff -u -r1.96 configure.in
--- configure.in 5 Jul 2011 06:08:43 -0000 1.96
+++ configure.in 26 Mar 2017 08:51:35 -0000
@@ -84,10 +84,6 @@
LIBS="-L/usr/local/lib $LIBS "
fi
@blippy
blippy / Makefile
Last active March 22, 2017 18:42
Decimal arithmetic C and C++ interoperability
dec : decc.o deccc.o
g++ decc.o deccc.o -o dec
decc.o : decc.c
gcc -c decc.c
deccc.o : deccc.cc
g++ -c deccc.cc
.PHONY : clean
@blippy
blippy / oleo.pm6
Created March 10, 2017 09:22
Convert oleo file to csv
#!/usr/bin/env perl6
grammar ofg { # oleo file grammar
token TOP { <line>+ }
token line { (<cell> || <other>) \n }
token rest { \N+ }
token cell { 'C;' <col>? <row> 'K' <rest> }
@blippy
blippy / build-2017.07.txt
Last active July 25, 2017 10:40
rakudo-star
https://rakudo.perl6.org/downloads/star/
PERL6_NCURSES_LIB=libncursesw.so.6 # now set in ~/repos/redact/docs/dotfiles/env/perl6.env
perl Configure.pl --prefix=$HOME/.local --backend=moar --gen-moar
make
make install
perl6 --version
This is Rakudo version 2017.04.3 built on MoarVM version 2017.04-53-g66c6dda
implementing Perl 6.c.
@blippy
blippy / copybook.pm6
Created December 23, 2016 23:18
Parsing COBOL copybook in perl6
#use Grammar::Debugger;
grammar CopybookGrammar {
token TOP { {say "at TOP" } <data-description-entry-top> <data-description-entry>* <ws0> }
#token data-description-entry-top { <ws0> '01' <ws1> <data-name> <ws0> '.' }
#token data-description-entry { <ws1> <level-num> <ws1> <data-name> <ws1> 'pic' <ws1> <picture-string> <ws0> '.' }
token data-description-entry-top { \s* '01' \s+ <data-name> \s* '.' }
token data-description-entry { <ws1> <level-num> \s+ <data-name> \s+ 'pic' \s+ <picture-string> <dot> }
#rule phrase { <TOP> <word> '.' }
token dot { { say "found dot" } <ws0> '.' }
@blippy
blippy / fork.pm6
Last active December 19, 2016 13:45
Perl6 forks and pipes
use NativeCall;
# http://www.perlmonks.org/?node_id=989766
our sub c_close(int32) returns int32 is native is symbol('close') { * }
our sub c_fork() returns int32 is native is symbol('fork') { ... };
our sub c_pipe(CArray[int32]) returns int32 is native is symbol('pipe') { ... }
our sub c_puts(Str) is native is symbol("puts") { * }
our sub c_read(int32, CArray[uint8], size_t) returns ssize_t is native is symbol('read') { *}
our sub c_wait(int32 is rw) is native is symbol('wait') { * }
our sub c_waitpid(int32, Pointer, int32) returns int32 is native is symbol('waitpid') {*};
@blippy
blippy / plish.pm6
Created December 17, 2016 15:00
APL in Perl 6
# Blogged about here:
# https://mcturra2000.wordpress.com/2016/12/14/perl6-needs-more-sigils/#comment-1702
my @a1 := 4, 5 ,6;
say @a1;
#say(@a1.rotate(1));
# or equivalently
#
# Φ in vim is C-k F* (Unicode U+03A6)
@blippy
blippy / build.txt
Last active December 16, 2016 17:32
rakudo-star-2016.11 build
[mcarter@vivo rakudo-star-2016.11]$perl Configure.pl --prefix=$HOME/.local --gen-moar
You can now use 'make' to build Rakudo.
After that, 'make test' will run some tests and
'make install' will install Rakudo.
#PROBLEM
make install
panda depends on File::Find, Shell::Command, JSON::Fast, File::Which
@blippy
blippy / ustr.cob
Created December 12, 2016 09:19
unstring with delimiter in last field
001000 IDENTIFICATION DIVISION.
001010 PROGRAM-ID. ustr.
002000 ENVIRONMENT DIVISION.
003000 DATA DIVISION.
003020 WORKING-STORAGE SECTION.
01 input-string pic x(30).
01 ptr-last-field pic 99.
@blippy
blippy / aservet.tcl
Created December 12, 2016 09:09
Simple server
set i 0
proc accept {chan addr port} { ;# Make a proc to accept connections
global i
puts "$addr:$port says $i [gets $chan]" ;# Receive a string
puts $chan goodbye ;# Send a string
close $chan ;# Close the socket (automatically flushes)
set i [expr 1 + $i]
} ;#
socket -server accept 12345 ;# Create a server socket
vwait forever ;# Enter the event loop