Skip to content

Instantly share code, notes, and snippets.

View pjlsergeant's full-sized avatar
🙇‍♂️
I don't really have time for this anymore

Peter Sergeant pjlsergeant

🙇‍♂️
I don't really have time for this anymore
  • Bangkok, Thailand
View GitHub Profile
@ascjones
ascjones / about.md
Created November 28, 2012 12:50 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@pjlsergeant
pjlsergeant / bubble.pl
Created November 27, 2012 09:23
BubbleCharts of DB Tables
#!perl
# Display a bubble chart of DB tables, with rows and relationships to other tables
# Either run directly: perl bubble.pl
# Or with Plack: plackup bubble.pl
use strict; use warnings;
# cpanm Dancer Template DBIx::Class::Schema::Loader Data::Google::Visualization::DataTable
use Dancer;
@pjlsergeant
pjlsergeant / gist:2556399
Created April 30, 2012 08:01
Concise map-reduce in Perl
use strict; use warnings;
use List::Util qw(reduce);
use File::Slurp qw(read_file);
# Given a list of filenames, return a hash of each word and the number of times
# it occurs.
sub word_count {
reduce { $a->{$b}++; $a } {},
@pjlsergeant
pjlsergeant / upgrading passwords.js
Created June 28, 2011 14:26
Upgrading passwords in place
// How to upgrade your users passwords in the DB without their intervention
//
// SHA-1 isn't strong enough to hash passwords with, but lots of people have a
// whole bunch of SHA-1'd passwords because they thought it was. You could use
// bcrypt or scrypt, but maybe in two years' time someone will tell you that's
// also not strong enough, and you'll want to upgrade.
//
// This sample demonstrates how you can remove weak password hashes from your
// user database, without needing the user to enter their password.
//
@pjlsergeant
pjlsergeant / explain.pl
Last active September 24, 2015 15:58
explain()
# Given a string, print out the codepoints that it currently compromises of. If
# you pass it a bytestring, you will get the bytes. If you pass it a character
# string, you will get the characters. This can be helpful when you're not sure
# if your terminal is playing around with the output.
sub explain {
# We will build up the output in $explain
my $explain;
# Split the first argument in to characters
for my $char ( split(//, shift() ) ) {