Skip to content

Instantly share code, notes, and snippets.

View briandfoy's full-sized avatar

brian d foy briandfoy

View GitHub Profile
#!/Users/brian/bin/perls/perl5.24.0
use v5.24;
use feature qw(signatures);
no warnings qw(experimental::signatures);
use Data::Dumper;
use HTML::Entities;
use Mojo::UserAgent;
use open qw(:std :utf8);
#!/Users/brian/Dropbox/perl6s/rakudo-star-2016.10/bin/perl6
use v6;
# https://docs.perl6.org/language/unicode_texas#Other_acceptable_single_codepoints
# https://gist.github.com/briandfoy/619638701f38817387f3e5d22d6dab12
my %hash;
BEGIN { # Phasers on!
websocket '/find' => sub ( $c ) {
state $loop = Mojo::IOLoop->singleton;
app->log->debug( "websocket for find" );
$c->inactivity_timeout( 50 );
my $id;
$c->on( message => sub ( $ws, $message ) {
my $json = decode_json( $message );
my $command = $json->{c};
@briandfoy
briandfoy / dos_globs.pl
Created February 22, 2016 21:44
DOS pattern matching, in Perl
#!perl
use strict;
use warnings;
=pod
Match 8.3 filenames in the DOS way, from Raymond Chen
https://blogs.msdn.microsoft.com/oldnewthing/20071217-00/?p=24143
#!/Users/brian/bin/perls/perl5.22.0
use v5.22;
use feature qw(signatures);
no warnings qw(experimental::signatures);
package Tie::Scalar::Sub {
use parent qw(Tie::Scalar);
use Carp qw(croak);
CC = clang
LD = clang
AR = ar
MAKE = make
PERL = /usr/local/bin/perl
RM = rm -f
CAT = cat
SHELL = /bin/sh
LUA = ./3rdparty/dynasm/minilua
CP = $(PERL) -MExtUtils::Command -e cp
@briandfoy
briandfoy / find_env_vars.pl
Last active June 6, 2016 14:43
Find all the environment variables you might use in Perl. There are are false positives here, but so what.
use File::Find;
use List::MoreUtils qw(uniq);
use v5.22;
use feature qw(postderef signatures);
no warnings qw(experimental::postderef experimental::signatures);
use Data::Dumper;
use PPI::Document;
use PPI::Dumper;
@briandfoy
briandfoy / mojo-ua-post-process.pl
Last active September 8, 2015 17:45
Mojo::UserAgent post-request processing to add meta charset
#!/Users/brian/bin/perls/perl5.22.0
use v5.20;
use feature qw(signatures);
no warnings qw(experimental::signatures);
use Data::Dumper;
use Mojo::UserAgent;
my $ua = Mojo::UserAgent->new;
@briandfoy
briandfoy / amazon_itemid.pl
Created September 3, 2015 08:37
Look up an item based on Amazon ID
#!/Users/brian/bin/perls/perl5.22.0
use v5.22;
use experimental qw(postderef);
no warnings qw(experimental::postderef);
use strict;
use warnings;
use URI::Amazon::APA;
use Mojo::UserAgent;
use XML::Simple;
#!/Users/brian/bin/perls/perl5.22.0
use open qw(:std :utf8);
use v5.10;
use Mojo::UserAgent;
use Devel::Peek qw(Dump);
use Encode qw(decode find_encoding);
use HTML::HeadParser;
my $ua = Mojo::UserAgent->new;