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
#!perl
use strict;
use warnings;
my %digits = map { $_ => 1 } ( 0 .. 9 );
sub choose ($&) {
my ( $set, $sub ) = @_;
map { $sub->($_) } grep { $set->{$_} } keys %$set;
1993
* 02 Jun '93: Dave Raggett updates his HTML+ DTD to include support for "INPUT and SELECT form interaction elements"[0]
* 05 Sep '93: Marc Andreessen says NCSA Mosaic 2.0 will submit form parameters as: "name=value&name=value&name=value"[1]
* 13 Sep '93: Rob McCool announces NCSA httpd 1.0a1[2], which supports:
"server scripts, which are executable programs which the server runs to generate documents on the fly. They are easy to write and can be written in your favorite language, whether it be C, PERL, or even the Bourne shell" [3]
* 14 Nov '93: Rob McCool complains that his users are avoiding writing code because they think the interface will change, and throws open a bunch of open-issues he wants fixing in what he calls the "gateway"
### Keybase proof
I hereby claim:
* I am pjlsergeant on github.
* I am pjlsergeant (https://keybase.io/pjlsergeant) on keybase.
* I have a public key whose fingerprint is 24D0 CFF6 6CE6 C9EE 9731 962B AA91 4EB0 D57E E0AC
To claim this, I am signing this object:
#!/opt/xt/xt-perl/bin/perl
use strict;
use warnings;
use File::Spec;
use Git::Wrapper;
use Cwd 'realpath';
use Term::ANSIColor;
use Term::ReadKey;
function epochToAgo ( epoch ) {
var rightNowObj = new Date();
var rightNowEpoch = Math.floor(rightNowObj.getTime() / 1000);
var diff = rightNowEpoch - epoch;
var human;
if ( diff < 3600 ) {
human = Math.floor( diff / 60 ) + ' minutes ago';
} else if ( diff < 86400 ) {
sub permutation {
my ( $count, $columns, $permutations ) = @_;
my $total_permutations = @$permutations ** $columns;
return if $count >= $total_permutations;
my $num = $count;
my $base = @$permutations;
sub permutation {
my ( $desired_permutation, $column_count, $permutation_set ) = @_;
my $permutation_set_count = @$permutation_set;
# The total number of permutations
my $total_permutations = $permutation_set_count ** $column_count;
# Return if we're being asked for a permutation outside the total number
# possible
return if $desired_permutation >= $total_permutations;
@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() ) ) {
@pjlsergeant
pjlsergeant / gist:981539
Created May 19, 2011 19:33
Healthy carbonara recipe
Name : Healthy Carbonara
Serves: 4 x 371 calorie portions (so two meals for me)
Stats:
Calories : 371 kcal (calc: 373)
% Fat : 28% - 106 kcal - 12g
% Protein: 27% - 101 kcal - 25g
% Carbs : 45% - 167 kcal - 42g
[
abc =>
[ '<!--', "I am a comment" ], # This is a magic tag
[ '<![CDATA[', "I am some CDATA" ], # This is also a magic tag
"\nHere is &, an ampersand, which will be quoted automatically",
\"\nHere is &ampersand;, an ampersand - string refs are 'raw'",
[ 'bar', { 'foo' => "The first hashref is the attributes" }, "some stuff" ],
[ 'single_no_attr' ],