Skip to content

Instantly share code, notes, and snippets.

View briandfoy's full-sized avatar

brian d foy briandfoy

View GitHub Profile
@briandfoy
briandfoy / mojo_config.md
Created May 17, 2026 05:53
Reading the (Perl-based) Mojo config outside of the app

I needed to read a Mojo app's config file without being in the Mojo app itself. If I were using YAML or JSON that wouldn't be a problem, but I was using the old-school Perl code format.

I pulled some of the stuff out of Mojolicious::Plugin::Config to write a little script to do it the same way. One thing to note is that mode-specific config files (app.development.conf) overlay the main one rather than merging into it. A later config key at the top level completely replaces the one before it, just as we expect from a Perl hash.

@briandfoy
briandfoy / crontab2launchd
Last active January 5, 2026 09:32
(Perl) convert crontab to launchd files
use v5.42;
use List::Util qw(zip);
use Mojo::Template;
use Set::CrossProduct;
use Storable qw(dclone);
=head1 NAME
crontab2launchd - rough conversion of crontab lines to launchd files
@briandfoy
briandfoy / a-The First Day of MTV Videos.md
Last active September 23, 2025 05:19
The first 116 Music Videos on MTV
@briandfoy
briandfoy / github_missing_days.sh
Created September 12, 2025 00:04
Find the days you did not contribute to GitHub
#!/bin/sh
USER=${GITHUB_USER}
FROM=$(date -u +"%Y-01-01T00:00:00Z")
TO=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
gh api graphql -f query='
query($login:String!,$from:DateTime!,$to:DateTime!){
user(login:$login){
contributionsCollection(from:$from,to:$to){
@briandfoy
briandfoy / mojo-server.pl
Created September 1, 2025 19:28
A mojo server inside a program
#!perl
use v5.40;
use Mojolicious::Lite;
use Mojo::Server::Daemon;
use Mojo::UserAgent;
my $port = 3000;
my $pid = fork;
@briandfoy
briandfoy / find_unused_subs.pl
Created July 7, 2012 00:51
Find unused Perl subroutines
#!/usr/bin/perl
use v5.14;
use strict;
use warnings;
use PPI;
use Scalar::Util qw(blessed);
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
@briandfoy
briandfoy / perl-method-calling-demo.pl
Created July 9, 2025 17:12
A demonstration of some Perl method calling features
#!/usr/bin/perl
{
package Parent;
sub bar { print "Parent: $_[0]" . "\n" }
}
{
package Foo;
use parent qw(Parent);
@briandfoy
briandfoy / grab-gist
Last active February 12, 2025 22:00
A Mojo::UserAgent program to grab all the files in a gist
#!/usr/bin/perl
=encoding utf8;
=head1 NAME
grab-gist - download all the files in a gist
=head1 SYNOPSIS
BuiltinFunctions::ProhibitBooleanGrep
BuiltinFunctions::ProhibitStringyEval
BuiltinFunctions::ProhibitStringySplit
BuiltinFunctions::ProhibitUniversalCan
BuiltinFunctions::ProhibitUniversalIsa
ClassHierarchies::ProhibitExplicitISA
ControlStructures::ProhibitMutatingListFunctions
ControlStructures::ProhibitUnreachableCode
ErrorHandling::RequireCarping
InputOutput::ProhibitBarewordFileHandles
@briandfoy
briandfoy / net-ssh-perl-rt2github.pl
Created January 14, 2024 19:11
Import rt.cpan.org issues to GitHub issues
use v5.26;
use open qw(:std :utf8);
use Mojo::JSON qw(decode_json);
use Mojo::UserAgent;
use Mojo::Util qw(dumper);
# See another gist to create JSON https://gist.github.com/briandfoy/656a8986e2d998122e37486df1f1f999
@ARGV = '/Users/brian/Desktop/net-ssh-perl-rt.json';
my $raw = Mojo::File->new($ARGV[0])->slurp;