Skip to content

Instantly share code, notes, and snippets.

Avatar
🤘
Be excellent to each other

John Barrett jbarrett

🤘
Be excellent to each other
  • Limerick, Ireland
View GitHub Profile
@jbarrett
jbarrett / mozart.pl
Last active Sep 6, 2021
Mozart's dice
View mozart.pl
#!/usr/bin/env perl
use strict;
use warnings;
use v5.32;
use experimental qw/ signatures /;
use MIDI;
use Path::This '$THISDIR';
@jbarrett
jbarrett / munge_bib.pl
Created Aug 8, 2021
Fix URLs in Mendeley's BibTeX export
View munge_bib.pl
#!/usr/bin/env perl
use IO::All -utf8;
my $in = 'library.bib';
my $out = 'library-munged.bib';
my @lines = io($in)->slurp;
for my $url ( grep { /^url/ } @lines ) {
@jbarrett
jbarrett / perl_weekly_challenge_1.md
Last active Mar 30, 2019
Perl weekly challenge 1
View perl_weekly_challenge_1.md

As published on https://perlweeklychallenge.org/blog/a-new-week-a-new-challenge/
Submissions demonstrated here using Reply.

Write a script to replace the character ‘e’ with ‘E’ in the string ‘Perl Weekly Challenge’. Also print the number of times the character ‘e’ is found in the string.

I didn't write a script so I fail this challenge already.

0> my $foo = 'Perl Weekly Challenge'
$res[0] = "Perl Weekly Challenge"
@jbarrett
jbarrett / git-cpr
Created Feb 22, 2019
Git command : checkout PR
View git-cpr
#!/usr/bin/env bash
[ -z "$1" ] && echo PR number required. && exit 1
BRANCHNAME=pr$1
[ ! -z "$2" ] && BRANCHNAME=$2
git fetch origin pull/$1/head:$BRANCHNAME
git checkout $BRANCHNAME
@jbarrett
jbarrett / ntfs_safe.pl
Created Dec 18, 2018
Very quick and dirty NTFS file renamer since ntfs-3g will happily write "invalid" filenames.
View ntfs_safe.pl
#!/usr/bin/env perl
use strict;
use warnings;
use File::Copy qw/ mv /;
use File::Find ();
my $dir = $ARGV[0] || '.';
use vars qw/*name *dir *prune/;
@jbarrett
jbarrett / reclaimWindows10.ps1
Created Aug 30, 2017 — forked from alirobe/reclaimWindows10.ps1
This Windows 10 Setup Script turns off a bunch of unnecessary Windows 10 telemetery, removes bloatware, and privacy invasions. Not guaranteed to catch everything. Review and tweak before running. Reboot after running. Scripts for reversing are included and commented. Fork of https://github.com/Disassembler0/Win10-Initial-Setup-Script (different …
View reclaimWindows10.ps1
##########
# Tweaked Win10 Initial Setup Script
# Primary Author: Disassembler <disassembler@dasm.cz>
# Modified by: alirobe <alirobe@alirobe.com> based on my personal preferences.
# Version: 2.6.1, 2017-08-02
# Primary Author Source: https://github.com/Disassembler0/Win10-Initial-Setup-Script
# Tweaked Source: https://gist.github.com/alirobe/7f3b34ad89a159e6daa1/
# Tweak difference:
#
# @alirobe's version is a subset focused on safely disabling telemetry, 'smart' features, and 3rd party bloat ...
@jbarrett
jbarrett / adflabel.pl
Last active Aug 31, 2016
Dump Amiga Disk Format (ADF) disk label (-ish, sometimes).
View adflabel.pl
#!/usr/bin/env perl
use strict;
use warnings;
use bytes;
use Carp;
my $filename = $ARGV[0] or croak "usage: $0 <ADF filename>";
-f $filename or croak "File does not exist: $filename";
@jbarrett
jbarrett / sc3000_widescreen.pl
Last active Jul 16, 2016
SimCity 3000 Widescreen hack - run from same dir as SC3.EXE / SC3U.EXE
View sc3000_widescreen.pl
#!/usr/bin/env perl
use strict;
use warnings;
use bytes;
use Carp;
use File::Copy qw/ cp /;
# See: http://www.wsgf.org/dr/simcity-3000/en
@jbarrett
jbarrett / echo_headers.pl
Created Jan 20, 2016
What were my request headers?
View echo_headers.pl
# plackup echo_headers.pl
use strict;
use warnings;
use Plack::Request;
use JSON;
my $app = sub {
my $req = Plack::Request->new(shift);
@jbarrett
jbarrett / RootURIFor.pm
Created Apr 14, 2015
Dancer2::Plugin::RootURIFor prototype
View RootURIFor.pm
package Dancer2::Plugin::RootURIFor;
use strict;
use warnings;
my $VERSION = 0;
use URI::Escape;
use Dancer2::Plugin;