Skip to content

Instantly share code, notes, and snippets.

@ggl
ggl / .dir_colors
Last active January 19, 2024 08:17
Color scheme for ls
# Configuration file for the color ls utility
# This file goes in the /etc directory, and must be world readable.
# You can copy this file to .dir_colors in your $HOME directory to override
# the system defaults.
# COLOR needs one of these arguments: 'tty' colorizes output to ttys, but not
# pipes. 'all' adds color characters to all output. 'none' shuts colorization
# off.
#
COLOR all
@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 / htpasswd.pl
Last active October 18, 2021 21:51
htpasswd in perl, no need to install apache tools
#!/usr/bin/env perl
#
# htpasswd.pl
#
# Copyright (c) 2013, Gelu Lupas <gelu@devnull.ro>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
@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 / 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;