Skip to content

Instantly share code, notes, and snippets.

Avatar

Gelu Lupaș ggl

View GitHub Profile
View flac2opus.pl
#!/usr/bin/env perl
use strict;
use warnings;
use Capture::Tiny;
use File::Which;
use Getopt::Std;
use Path::Tiny;
View .vimrc
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 Mar 11, 2019
Mojo::IOLoop::Subproces task runner
View mojo-ioloop-subprocess.pl
#!/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 Jul 17, 2020
The Sieve of Sundaram (1934)
View sundaram.cr
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 Sep 14, 2018
Benchmark six Perl serializers
View serializer-benchmark.pl
#!/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 Apr 10, 2017
Fibonacci numbers in D
View fib.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) {
@ggl
ggl / .dir_colors
Last active Sep 7, 2020
Color scheme for ls
View .dir_colors
# 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 Sep 10, 2016
Generate a histogram from a list of numbers
View histogram.pl
#!/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 Sep 10, 2016
Start a child process and feed it Sereal encoded data
View sereal-child.pl
#!/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 Sep 10, 2016
Tell the time using a recurring Mojo::IOLoop timer
View mojo-ioloop-time.pl
#!/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;
You can’t perform that action at this time.