Skip to content

Instantly share code, notes, and snippets.

View ltriant's full-sized avatar
🪐
floating

Luke Triantafyllidis ltriant

🪐
floating
View GitHub Profile
#!/usr/bin/env perl
use v5.10;
use warnings;
use strict;
use EV;
use AnyEvent;
use Sys::Hostname qw(hostname);
@ltriant
ltriant / mx.psgi
Last active October 2, 2017 06:39
Promises-based non-blocking Plack/PSGI app
#!/usr/bin/env perl
# mx.psgi -- get geographic information about a domain's mailservers
# This was written purely as an example real-world-ish non-blocking
# Plack/PSGI application because I'm sick of seeing the usual
# "Hello World"-esque examples.
# In one shell:
# $ feersum --listen :5000 -a mx.psgi
#
#!/usr/bin/env perl
use warnings;
use strict;
use Mojo::UserAgent;
die "usage: cpanver <module>\n" unless @ARGV;
my ($module) = @ARGV;
@ltriant
ltriant / xmas.erl
Last active December 17, 2015 22:43
-module(xmas).
-export([tree/1]).
tree(Width, _, _) when Width < 3 orelse Width > 21 ->
error( { out_of_range, { min, 3 }, { max, 21 }, { input, Width } } );
tree(Width, _, _) when Width rem 2 == 0 ->
error( { width_is_not_odd, Width } );
tree(Width, Trunk, Leaves) ->
lists:foreach(
fun (A) ->