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 / histogram.pl
Last active September 10, 2016 07:36
Generate a histogram from a list of numbers
#!/usr/bin/end perl
use strict;
use warnings;
use Data::Dumper;
my $hist = sub {
my $input = shift;
if ($input and $input =~ /^\d+$/) {
@ggl
ggl / sereal-child.pl
Last active September 10, 2016 07:36
Start a child process and feed it Sereal encoded data
#!/usr/bin/env perl
use strict;
use warnings;
use Child;
use Data::Dumper;
use Sereal::Encoder;
use Sereal::Decoder;
@ggl
ggl / mojo-ioloop-time.pl
Last active September 10, 2016 07:39
Tell the time using a recurring Mojo::IOLoop timer
#!/usr/bin/env perl
use Mojo::IOLoop;
use POSIX;
# Start at sec % 5 == 0
Mojo::IOLoop->timer((5 - (localtime)[0] % 5) => sub {
# Perform operation every 5 seconds
Mojo::IOLoop->recurring(5 => sub {
my $loop = shift;
@ggl
ggl / aliases.sh
Last active September 10, 2016 07:44
Bash/zsh shell alaiases
#!/bin/sh
alias rm='rm -i'
alias mv='mv -i'
alias cp='cp -i
alias plack-app-dir="plackup -MPlack::App::Directory -e 'my \$app = Plack::App::Directory->new({ root => \"\$ENV{HOME}/public\" })->to_app;'"
@ggl
ggl / www-get-links.pl
Last active September 10, 2016 07:44
Get href links from an URL using Mojo::UserAgent
@ggl
ggl / ro-utf8-replace.pl
Last active September 10, 2016 07:47
Replace Turkish UTF-8 glyphs with Romanian ones
#!/usr/bin/env perl
use strict;
use warnings;
if (@ARGV < 1) {
print "usage: $0 <file>\n";
exit 0;
};
@ggl
ggl / json-time.pl
Created May 20, 2014 17:24
Timing JSON modules
#!/usr/bin/env perl
use strict;
use warnings;
use Try::Tiny;
use Benchmark qw(cmpthese);
use JSON::XS ();
use Cpanel::JSON::XS ();
use JSON::Tiny;
@ggl
ggl / cleaner.pl
Created March 20, 2014 11:53
PHP malware cleaner
#!/usr/bin/env perl
use strict;
use warnings;
use File::Copy;
use Path::Iterator::Rule;
unless ($ARGV[0]) {
print "usage: $0 <directory>\n";
@ggl
ggl / poi_sqlite.pl
Last active September 10, 2016 08:02
Create a POI SQLite database from a Garmin CSV
#!/usr/bin/env perl
use strict;
use warnings;
use DBI;
use Data::Dumper;
use Geohash;
use Text::CSV;