Skip to content

Instantly share code, notes, and snippets.

@ggl
ggl / easydbi.pl
Created November 10, 2022 06:50
POE::Component::EasyDBI example
#!/usr/bin/env perl
use strict;
use warnings;
use lib 'lib';
use POE qw(Component::EasyDBI);
use Data::Dumper;
POE::Session->create(
#!/usr/bin/env perl
# ABSTRACT: A simple message broker using Mojolicious WebSockets
# USAGE: ./pubsub.pl daemon
#
# This is my remix of Doug Bell's event broker. It publishes numbers
# on a topic, subscribes to that topic and appends the numbers to the
# document body. The original source can be found here:
#
# https://gist.github.com/preaction/2078d33d87b126621e45
#
@ggl
ggl / valea-morii.geojson
Created February 22, 2021 08:52
ROSCI0074 Făgetul Clujului - Valea Morii
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ggl
ggl / pure-ftpd-conf.pl
Last active February 21, 2021 13:34
Pure-FTPd configuration generator
#!/usr/bin/env perl
#
# Generates pureftpd.config options in the conf/ directory for use
# with pure-ftpd-wrapper
#
use strict;
use warnings;
use Getopt::Long;
#!/usr/bin/env perl
use strict;
use warnings;
use Capture::Tiny;
use File::Which;
use Getopt::Std;
use Path::Tiny;
@ggl
ggl / .vimrc
Last active July 17, 2020 07:17
set nocompatible
set backspace=2
set autoindent noexpandtab softtabstop=-1 tabstop=4 shiftwidth=4
set ruler
syntax on
colorscheme torte
@ggl
ggl / mojo-ioloop-subprocess.pl
Last active March 11, 2019 13:24
Mojo::IOLoop::Subproces task runner
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
use Mojo::Log;
use Mojo::IOLoop;
use Mojo::IOLoop::Subprocess;
@ggl
ggl / sundaram.cr
Last active October 10, 2021 13:04
The Sieve of Sundaram (1934)
def sieve_sundaram(n : UInt64)
a = Hash(UInt64, Bool).new
s = Array(UInt64).new
m = (n/2.0).round
(1_u64..n).each do |i|
(i..n).each do |j|
p = i + j + 2_u64*i*j
if p <= n
a[p] = true
end
@ggl
ggl / serializer-benchmark.pl
Last active September 14, 2018 08:44
Benchmark six Perl serializers
#!/usr/bin/env perl
use Benchmark;
use CBOR::XS ();
use Cpanel::JSON::XS ();
use Data::MessagePack;
use JSON::XS ();
use Sereal::Encoder;
use Sereal::Decoder;
@ggl
ggl / fib.d
Last active April 10, 2017 19:06
Fibonacci numbers in D
import std.stdio;
import std.bigint;
import core.checkedint;
void main() {
writefln("%d", fib_iter(72));
writefln("%d", fib_binet(72));
}
auto fib_iter (int n) {