Skip to content

Instantly share code, notes, and snippets.

Avatar

Ovid Ovid

View GitHub Profile
@Ovid
Ovid / Counter.pl
Created Feb 8, 2021
user-defined attributes in Cor?
View Counter.pl
class Counter {
# My::Cor::Attributes is using some hypothetical
# tool to extend Cor attributes. Because it's a
# `use` statement, it happens at compile time
use My::Cor::Attributes ':isa';
has $count :reader :new :isa(PositiveInt) = 0;
method inc () { $count++ }
method dec () { $count-- unless 0 == $count }
}
@Ovid
Ovid / grep.pm
Last active Oct 15, 2020
A small hack to add a 'sqitch grep ...' command that sorts things in the order of the sqitch plan
View grep.pm
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 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 Aug 11, 2020
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 Feb 14, 2021
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};
}