Skip to content

Instantly share code, notes, and snippets.

Avatar
🦈
hi

Toby Inkster tobyink

🦈
hi
View GitHub Profile
@tobyink
tobyink / fortune-500.pl
Created Oct 25, 2021
Calculate the excess profits of Fortune 500 companies and how much of a pay rise they could give employees
View fortune-500.pl
#!perl
use strict;
use warnings;
use constant {
THOUSAND => 1_000,
MILLION => 1_000_000,
BILLION => 1_000_000_000,
};
@tobyink
tobyink / hue-mood.pl
Created Jan 22, 2021
Cycles a list of Philips Hue light bulbs through a gradient of colours
View hue-mood.pl
#!/usr/bin/env perl
use v5.16;
use warnings;
package ColourSet {
use Moo;
use Types::Standard -types;
has initial => (
@tobyink
tobyink / cpanm-5.6.pl
Created Nov 23, 2020
App::cpanminus for Perl 5.6
View cpanm-5.6.pl
#!/usr/bin/env perl
#
# This is a pre-compiled source code for the cpanm (cpanminus) program.
# For more details about how to install cpanm, go to the following URL:
#
# https://github.com/miyagawa/cpanminus
#
# Quickstart: Run the following command and it will install itself for
# you. You might want to run it as a root with sudo if you want to install
# to places like /usr/local/bin.
@tobyink
tobyink / my-perltidy
Last active Nov 19, 2020
tobyink's custom perltidy
View my-perltidy
#!/usr/bin/env perl
use strict;
use warnings;
use Perl::Tidy;
exit Perl::Tidy::perltidy(
perltidyrc => \( do { local $/ = <DATA> } ),
prefilter => sub {
no warnings;
@tobyink
tobyink / pw-84-matrix.pl
Last active Oct 31, 2020
Finding squares in a matrix
View pw-84-matrix.pl
use strict;
use warnings;
package Weekly84 {
use Zydeco;
class Matrix {
# public required attribute
has cells! ( type => ArrayRef[ArrayRef[Bool, 1], 1] );
View frequency-sort.pl
use strict;
use warnings;
use List::MoreUtils qw( frequency part uniq );
my @words = map /([\w']+)/g, <DATA>;
my %freq = frequency @words;
my @parts = part { $freq{$_} } uniq @words;
for my $i ( 0 .. $#parts ) {
next unless $parts[$i];
@tobyink
tobyink / subop.pl
Created Oct 2, 2020
Sub::Operable Example
View subop.pl
use strict;
use warnings;
use feature 'say';
use List::Util 'shuffle';
use Sub::Operable 'subop';
*greetings = subop {
my @greetings = shuffle(
'Greetings',
'Hello',
@tobyink
tobyink / wp-t-d-auto-eg1.html
Last active Sep 29, 2020
WP Tempus Dominus Auto Example 1
View wp-t-d-auto-eg1.html
<div class="form-group">
<label>Start Date (required)</label>
<input
type="date"
required
class="form-control"
id="startdate"
name="startdate"
data-tempus-dominus-overlay="ddd D MMM YYYY"
data-tempus-dominus-onclick="true"
@tobyink
tobyink / github-visitor.pl
Last active Sep 29, 2020
Script to switch off the "issues" feature for all my Perl repos. (Issues for my Perl repos should be reported to rt.cpan.org.)
View github-visitor.pl
#!/usr/bin/env perl
use Z;
my $app = app sub {
class 'Visitor' => sub {
constant 'USER' => 'tobyink'; # Your username!
constant 'TOKEN' => 'XXXXXXX'; # https://github.com/settings/tokens
has 'code' => ( type => CodeRef, required => true );
has 'repos' => ( is => 'lazy', init_arg => undef );
@tobyink
tobyink / linked-lists.pl
Last active Sep 25, 2020
Linked lists, Zydeco example
View linked-lists.pl
package SLL {
use Zydeco;
class Node {
has value ( type => Int );
has nextnode ( type => Maybe[Object] );
method printvalue () {
print $self->value, " ";
}