Skip to content

Instantly share code, notes, and snippets.

@RogerDodger
RogerDodger / md2bbc.pl
Last active December 8, 2020 21:05
Converts Markdown to BBCode
#!/usr/bin/env perl
use strict;
use warnings;
use 5.01;
use Text::Markdown;
use Encode;
use HTML::Entities;
use Getopt::Long;
@RogerDodger
RogerDodger / osu_lz.pl
Created March 26, 2019 08:51
Calculate Lempel-Ziv complexity of beatmap note intervals
use 5.01;
use warnings;
use strict;
use Data::Dump;
for my $bm (glob "beatmaps/*") {
say "\n### " . substr($bm, 9) . " ###";
my $deltas = beatmap_deltas($bm);
say "Length: " . sum($deltas) / 1000 . "s";
say "Intervals: " . ($#$deltas + 1);
#!/usr/bin/env perl
use Mojo::Base -strict;
use Mojo::UserAgent;
use DateTime;
use DateTime::Format::Strptime;
my $id = shift or print <<"USAGE" and exit(1);
usage: $0 thread
USAGE
use Mojolicious::Lite;
open my $fh, "<", "nouns.txt";
my @nouns = map { chomp && lc $_ } $fh->getlines;
close $fh;
sub nurble {
my $text = uc shift;
$text =~ s{
@RogerDodger
RogerDodger / JudgeDistr.pl
Created August 25, 2012 07:59
Distributes stories to judges (using input from UNIX wc)
#!/usr/bin/perl -w
use warnings;
use strict;
use List::Util qw/shuffle min sum/;
use feature qw/say/;
use utf8;
# Usage:
# $wc *.txt | $0 <outfile>
@RogerDodger
RogerDodger / mafia_role_assg.pl
Created July 17, 2012 10:58
Randomly assigns players into a mafia setup
#!/usr/bin/perl
use warnings;
use strict;
use Data::Dump;
use feature qw/say/;
use List::Util qw/shuffle/;
my %setups = (
Scumcity => [
@RogerDodger
RogerDodger / storyVoter.pl
Created June 20, 2012 19:22
Runs through stories in heats to judge which ones are best.
#!/usr/bin/perl
use warnings;
use strict;
use List::Util qw/shuffle/;
if($#ARGV != 2 || grep {$ARGV[0] eq $_} qw/help h/) {
print
"Usage: perl $0 <inputfile> <outputfile> <groupsize>\n",
" <inputfile> is the name of the file containing the stories to be\n",
@RogerDodger
RogerDodger / writeoff-scrape.pl
Last active August 29, 2015 14:01
Grabs stories from writeoff.me and saves them to disk
#!/usr/bin/env perl
# Scrape writeoff.me events for stories and write them to files
use Mojo::Base -strict;
use Mojo::UserAgent;
use File::Spec;
# IDs of events to scrape
my @events = (1..23);