Skip to content

Instantly share code, notes, and snippets.

Ovid Ovid

View GitHub Profile
@Ovid
Ovid / cor_attributes.md
Last active Mar 1, 2020
Cor attribute/slot declaration?
View cor_attributes.md

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 Jan 25, 2020
Script to make altering tables in SQLite easier
View alter-table.pl
#!/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 Dec 9, 2019
Convert from Arabic to Babylonian numerals (only positive integers)
View babylonian.pl
#!/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 Nov 20, 2019
use less boilerplate
View Boilerplate.pm
package Less::Boilerplate;
use 5.26.0;
use strict;
use warnings;
use feature ();
@Ovid
Ovid / cor.md
Last active Mar 24, 2020
Cor—A minimal object system for the Perl core
View cor.md

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 Aug 27, 2019
Partial desription of a date matching regex
View date.pl
#!/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
View keybase.md

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 Jul 24, 2018
Sample LRU cache in Perl 6?
View lrutest.p6
# 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};
}
View gist:a28f15da01f5b69a55779e42e7046766
#!/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
View git-refresh.sh
#!/bin/bash
# vim: filetype=sh
set -e # exit if any command fails
prog=$(basename $0)
branch=$(git rev-parse --abbrev-ref HEAD)
need_to_stash=$(git status --porcelain -uno)
You can’t perform that action at this time.