Skip to content

Instantly share code, notes, and snippets.

View haukex's full-sized avatar
🍔

Hauke D haukex

🍔
View GitHub Profile
@haukex
haukex / Makefile
Created March 28, 2024 15:05
sphinx-markdown-builder unknown node type desc_returns
.PHONY: docs clean
docs:
PYTHONPATH=. sphinx-build -M markdown . output
clean:
rm -rf output
@haukex
haukex / Dockerfile
Last active September 30, 2023 20:46
rsyslogd rotation.sizeLimitCommand problem
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends rsyslog
COPY rsyslog.d-demo.conf /etc/rsyslog.d/00-demo.conf
RUN mkdir -vp /var/log/user
# this command just comments out kernel logging support (the line `module(load="imklog")`)
RUN perl -wMstrict -i -ple 's/^(?=\s*module\s*\(\s*[^)]*\bimklog\b)/#/' /etc/rsyslog.conf
COPY *.sh /usr/local/bin/
@haukex
haukex / requirements.txt
Last active April 16, 2023 11:46
Test adjusting system clock during sleep_until
igbpyutils >= 0.0.3
sleep_until
@haukex
haukex / pm_ajaxcb.js
Last active June 9, 2020 09:03
PerlMonks Browser Notifications for New Nodes
"use strict";
// Documented at: https://www.perlmonks.org/?node_id=11116369
$(function () {
var CB_FETCHTIME_MS = 15 * 1000;
var GERNERAL_REFRESHTIME_MS = 60 * 1000;
// AJAX CB Refresh
var refresh = function () {
$.ajax({ url: '/', dataType: 'html',
// testing shows the table rendered here is the same as in the nodelet
data: { node: 'showchatmessages', displaytype: 'raw', ticker: 'yes' } })
# cpanm --installdeps .
requires 'Mojo::DOM';
requires 'HTML::TreeBuilder::XPath';
requires 'HTML::LinkExtor';
requires 'WWW::Mechanize', '1.97';
requires 'XML::LibXML';
# for runsols.pl:
requires 'Path::Class';
requires 'IPC::Run3';
requires 'Test::More';
#!/usr/bin/env perl
use warnings;
use strict;
my %tehcodez = (
sortfirst => q{
@list = sort {$a<=>$b} @list;
@list = ( (grep {$_>=0} @list), (grep {$_<0} @list) ); },
grepfirst => q{
my @pos = grep {$_>=0} @list;
use warnings;
use 5.018;
# run this multiple times: sometimes it prints "x1x2x1x", sometimes "x2bar-x2x2bar-x"
{
my %repl = ( '-foo-bar-'=>1, '-foo-'=>2 );
my $re = join '|', map { "\\b$_\\b" } keys %repl;
$re = qr/$re/;
# WARNING # WARNING # WARNING # the following command generates a ~1 GIGABYTE file!
$ perl -le '$,=$/;for(1..50000){print+("Foo")x5000,"Bar CAPTURE Bar"}print+("Foo")x5000' >test.txt
# For testing outputs:
# perl -le '$,=$/;print"Bar CAPTURE Bar";for(1..49999){print+("Foo")x5000,"Bar CAPTURE Bar"}' >out_expect.txt
# UPDATE: Replace "time" with "/usr/bin/time" to get memory usage stats as well!
#!/usr/bin/env perl
use warnings;
use strict;
use Time::HiRes qw/gettimeofday tv_interval/;
use DBI;
my $dbh = DBI->connect("dbi:SQLite:dbname=:memory:",undef,undef,
{ RaiseError=>1, AutoCommit=>0 } );
{ # create table and fill with fake data
$dbh->do(<<'END_SQL');
#!/usr/bin/env perl
use warnings;
use strict;
use Benchmark 'cmpthese';
use List::Util 'first';
my @tests = (
{ nrand=> 100, nlook=> 10, match=>'beginning' },
{ nrand=> 100, nlook=> 100, match=>'beginning' },
{ nrand=>10_000, nlook=> 100, match=>'beginning' },