Skip to content

Instantly share code, notes, and snippets.

@sebkirche
sebkirche / test_pp_tree.pl
Created May 2, 2024 16:33
Pretty print a tree structure in ascii using box drawing chars
use strict;
use warnings;
use feature 'say';
use Data::Dumper;
# Pretty print a tree structure
# Constants for drawing lines and spaces
@sebkirche
sebkirche / ppv2.pl
Last active October 21, 2022 17:37
simple pure Perl pipe viewer similar to pv. hacked to replace Number::Bytes::Human::format_bytes by a simpler formatter
#!/usr/bin/env perl
=encoding utf8
=head1 NAME
Pure perl pipe viewer
=head1 VERSION
Version 1.3
@sebkirche
sebkirche / sscce_rxjs.pl
Created April 16, 2020 12:10
Short, Self Contained, Correct (Compilable), Example of JSON recursive descent parser based on an extended regexp
use strict;
use warnings;
use feature 'say';
use utf8;
use open ':std', ':encoding(UTF-8)';
use Data::Dumper;
$Data::Dumper::Sortkeys = 1;
$Data::Dumper::Indent = 2;
my $data = $ARGV[0] || '{"id":42}';
@sebkirche
sebkirche / defrag.pl
Created January 4, 2015 14:58
defragment files not processed by system defrag tool (as listed in the final log) with SysInternals contig tool
# Process the XP defrag log file
# to defragment the "Files that cannot be defragmented" with SysInternals / defrag tool.
#
# Seki - 2014
use strict;
use warnings;
use Data::Dumper;
#~ use 5.10.1; #not compatible with my old 5.8.8, but I just need "say"
@sebkirche
sebkirche / cw_commandbutton.sru
Created December 13, 2013 09:48
WIP source code of an improved command button for PowerBuilder that can handle vertical alignment, draw of themes and many improved characteristics compared to system command button
forward
global type cw_commandbutton from commandbutton
end type
type rect from structure within cw_commandbutton
end type
type logbrush from structure within cw_commandbutton
end type
type imageinfo from structure within cw_commandbutton
end type
type st_size from structure within cw_commandbutton
@sebkirche
sebkirche / exp.y
Created December 10, 2013 19:11
a simple expression parser generated from an ancient Yacc
%token NAME NUMBER LPAREN RPAREN EQUAL PLUS MINUS
%token TIMES DIVIDE IF THEN ELSE
/* associativity and precedence: in order of increasing precedence */
%nonassoc LOW /* dummy token to suggest shift on ELSE */
%nonassoc ELSE /* higher than LOW */
%nonassoc EQUAL
@sebkirche
sebkirche / rx_name.pl
Last active December 19, 2015 08:38
Perl sample that illustrate the usage of (duplicated) named subpatterns
use v5.10.01;
use strict;
use warnings;
my $rx =
qr{
# match contain groups 'file' + 'line'
\bfile:? (?<file>.+) \s at \s line \s (?<line>\d+)
# match contain only 'line'
| \s at \s line \s (?<line>\d+)