Skip to content

Instantly share code, notes, and snippets.

View Ovid's full-sized avatar

Ovid Ovid

View GitHub Profile
@Ovid
Ovid / grep.pm
Last active May 12, 2022 12:36
A small hack to add a 'sqitch grep ...' command that sorts things in the order of the sqitch plan
package App::Sqitch::Command::grep;
use 5.010;
use strict;
use warnings;
use utf8;
use App::Sqitch::X qw(hurl);
use Moo;
use App::Sqitch::Target;
use App::Sqitch::Types qw(Str Enum Target Bool);
@Ovid
Ovid / cor_attributes.md
Last active March 1, 2020 12:44
Cor attribute/slot declaration?

This is a rough draft of some thoughts I've had regarding Cor attributes declaration. Please leave your thoughts.

Part of the problem with the Cor object proposal for the Perl code is that we tended to use the semantics of has as declared in the Moose OO extension for Perl. Unfortunately, this function handles:

  • Data
@Ovid
Ovid / alter-table.pl
Created January 25, 2020 09:49
Script to make altering tables in SQLite easier
#!/usr/bin/env perl
# ALTER TABLE syntax in SQLite is very limited. This script follows the pattern
# outlined in https://www.sqlite.org/lang_altertable.html to make it easier to
# alter a table in SQLite
# this script is designed to use core Perl so that non-Perl users can use it
use 5.6.1; # minimum version for File::Temp
use strict;
use warnings;
@Ovid
Ovid / babylonian.pl
Last active December 9, 2019 12:34
Convert from Arabic to Babylonian numerals (only positive integers)
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
binmode STDOUT, ':utf8_strict';
my $num = shift;
if ( $num < 1 || $num != int($num) ) {
die "'$num' is not a positive integer";
}
@Ovid
Ovid / Boilerplate.pm
Last active August 11, 2020 01:49
use less boilerplate
package Less::Boilerplate;
use 5.26.0;
use strict;
use warnings;
use feature ();
@Ovid
Ovid / cor.md
Last active September 12, 2021 08:02
Cor—A minimal object system for the Perl core

NAME

Cor — A minimal OO proposal for the Perl core

VERSION

This is version 0.10 of this document.

AUTHOR

@Ovid
Ovid / date.pl
Created August 27, 2019 13:45
Partial desription of a date matching regex
#!/usr/bin/env perl
use Test::Most;
use Veure::Script; # strict, warnings, postderef, sigs, and more
use re 'eval'; # needed for (??{}) in the regex
# the (??{}) construct will execute code and consider the result of that
# to be a regex to match on.
my $yyyy_mm_dd = qr/
^
# any four digit year

Keybase proof

I hereby claim:

  • I am ovid on github.
  • I am ovidperl (https://keybase.io/ovidperl) on keybase.
  • I have a public key ASDsbYunRavQwS2b6ZR7TER9LwNC4YtX7oDIqaGPu6URwAo

To claim this, I am signing this object:

@Ovid
Ovid / lrutest.p6
Last active July 24, 2018 20:59
Sample LRU cache in Perl 6?
# Turns out this doesn't work because OrderedHash
# is sorted, not ordered
class Cache::LRU {
use OrderedHash;
has %.cache = {} does OrderedHash;
has UInt $.max_size = 20;
method get($key) {
return %.cache{$key};
}
#!/usr/bin/env perl
# This program constantly prints the time in GCT (Galactic Coordinated Time)
# as used in the MMORPG Tau Station (https://taustation.space/)
# Obviously, we use something a bit more sophisticated than this :)
use strict;
use warnings;
use Time::HiRes 'sleep';
$|++; # unbuffer STDOUT