Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael G. Schwern schwern

View GitHub Profile
View gist:137761
package Foo;
use parent 'signatures';
sub import {
my $class = shift;
my $caller = shift;
$class->setup_for($caller);
return;
View gist:137778
package Foo;
use strict;
use warnings;
use parent 'signatures';
require Method::Signatures;
sub proto_unwrap {
my $class = shift;
return Method::Signatures->parse_sub( proto => $_[0] );
View perl5i.c
#include <unistd.h>
#include <stdlib.h>
/*
* Meant to mimic the shell command
* exec perl -Mperl5i "$@"
*
* This is a C program so it works in a #! line.
*/
View Daring Fireball URI regex
qr{
\b
(
# scheme or schemeless
([\w-]+://? | www[.])
# anything but whitespace or brackets
[^\s()<>]+
# letters and numbers in parens
View gist:306297
#!/usr/bin/perl
use utf8;
use YAML::XS qw(Load);
binmode $_, ':encoding(utf8)' for (*STDIN, *STDOUT, *STDERR, *DATA);
#no utf8; # its interfering with the DATA loading
my $authors2email = Load(join "", <DATA>);
exit;
View wrapping require benchmark.pl
#!/usr/bin/perl -w
use strict;
use warnings;
use Benchmark qw(cmpthese);
BEGIN {
*CORE::GLOBAL::require = sub {
return CORE::require $_[0];
View release.pl
#!/usr/local/bin/perl
use perl5i::0;
use File::Copy;
my %Is;
my $builder;
my $build_file;
my @build_args;
View git-child
#!/bin/bash
# Find the child of the current (or supplied) commit.
REV=$1
if [ x$REV == x ]; then
REV="HEAD"
fi
View uniq.pl
#!/usr/bin/perl -w
use strict;
use warnings;
use List::MoreUtils qw(uniq);
use Benchmark qw(cmpthese);
sub somni_uniq { my %seen; grep { !$seen{$_}++ } @_ }
View try.c
#include <time.h>
#include <stdio.h>
int main() {
time_t now = -4136232677718LL;
printf("%lld\n", (long long int)timegm(gmtime(&now)));
return 0;
}