Skip to content

Instantly share code, notes, and snippets.

View ElectricCoffee's full-sized avatar

Niko Lepka ElectricCoffee

View GitHub Profile
=head1 Updater
A class that houses the data and processes required to correctly deal with the updater yaml file.
=over 4
=cut
package Updater;
@ElectricCoffee
ElectricCoffee / game_of_pig.pl
Last active April 29, 2021 12:47
A game of pig simulation based on this video: https://www.youtube.com/watch?v=ULhRLGzoXQ0
use v5.30;
use warnings;
use constant VERBOSE => 0; # set to 1 if you want to print intermediate messages.
package Player {
use Moo; # OOP library, don't ask.
# the name of the player
has name => (is => 'ro');
@ElectricCoffee
ElectricCoffee / autoupdate.pl
Last active June 13, 2022 22:17
A script that automates updating the various packages on my system
#!/usr/bin/env perl
# autoupdate.pl
# copyright 2021 Nikolaj Lepka <[email protected]>
use v5.28;
use strict;
use warnings;
use autodie;
use Term::ANSIColor qw(:constants);
use Carp;
use Getopt::Long;
@ElectricCoffee
ElectricCoffee / woman.pl
Last active March 10, 2021 14:04
woman, a unified manual printing tool. Prints the help page of a program if a manpage doesn't exist.
#!/usr/bin/env perl
# woman
# copyright 2021 Nikolaj Lepka <[email protected]>
use v5.30;
use warnings;
use autodie;
use Pod::Usage;
use Getopt::Long;
GetOptions (
@ElectricCoffee
ElectricCoffee / russian-roulette.pl
Last active December 22, 2020 13:31
A simple russian roulette statistics calculator inspired by the VSauce2 video. Simply calculates the win percentage of any given player position. (Spoiler: first player always has advantage)
#!/usr/bin/env perl
# russian-roulette.pl
# copyright 2020 Nikolaj Lepka <[email protected]>
use v5.30;
use warnings;
use autodie;
use List::Util 'sum';
use constant {
# The revolver's capacity. A standard revolver holds 6 rounds.
CYLINDER_CAPACITY => 6,
@ElectricCoffee
ElectricCoffee / perltouch
Last active October 28, 2020 09:43
A simple script to create perl scripts with all the boilerplate
#!/usr/bin/env perl
use v5.30;
use warnings;
use autodie;
use Time::localtime;
=head1 LICENCE
Copyright (c) 2020, Nikolaj Lepka <[email protected]>
Redistribution and use in source and binary forms, with or without
use v5.28;
use warnings;
no warnings qw(experimental::smartmatch);
use List::Util qw(sum);
my $debug;
my $die_notation = qr/
(?<count>\d*)
d(?<faces>\d+)
#!/usr/bin/env perl
=for comment
Copyright 2020 Niko Lepka
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation

My Lisp

Design Goals

  1. Modern feel
    • No archaic syntax or keywords besides the parentheses
    • No over-use of the word ‘def’ (defmacro, defun, defgeneric, etc.)
    • Strong text manipulation out of the box for terminal scripting purposes
  2. Fast
  3. JIT compiled with Julia-style method monomorphisation
  4. Macros!!
(defun mk-klist (args)
"takes a plist of data and returns a keyed alist as its result.
i.e. an alist where the first element is a :keyword"
(assert (evenp (length args)) (args)
"arglist ~a is not even" args)
(loop :for (k v) :on args :by #'cddr
:do (check-type k keyword)
:collect (cons k v)))
(defun node (name &rest attrs)