Skip to content

Instantly share code, notes, and snippets.

🐢
AWOL

Gelu Lupaș ggl

🐢
AWOL
Block or report user

Report or block ggl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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 Dec 4, 2018
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 10, 2016
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;
@ggl
ggl / aliases.sh
Last active Sep 10, 2016
Bash/zsh shell alaiases
View aliases.sh
#!/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 Sep 10, 2016
Get href links from an URL using Mojo::UserAgent
View www-get-links.pl
You can’t perform that action at this time.