Skip to content

Instantly share code, notes, and snippets.

use strict;
use warnings;
use Benchmark qw< cmpthese >;
my @elements = 1..50;
cmpthese(100000, {
hash => sub {
map { $_->{bar} }
sort { $a->{foo} <=> $b->{foo} }
use strict;
use warnings;
package ReportRequire;
sub import {
my (undef, @targets) = @_;
@targets = map { s{::}{/}g; "$_.pm" } @targets;
unshift @INC, sub {
my ($self, $filename) = @_;
BINS := sponge pee
PERLSCRIPTS := chronic
MANS := $(BINS:=.1) $(PERLSCRIPTS:=.1)
PREFIX := /usr/local
selected := PREFIX=$(PREFIX) BINS="$(BINS)" PERLSCRIPTS="$(PERLSCRIPTS)" MANS="$(MANS)"
all:
make all $(selected)
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long;
use File::Basename qw(basename);
use List::MoreUtils qw(any);
my $PROC = $^O eq 'linux' ? 'gnome-session' : 'ssh-agent';
my $USER = getlogin();
@tsibley
tsibley / keybase.md
Created November 10, 2014 00:08
keybase.io

Keybase proof

I hereby claim:

  • I am tsibley on github.
  • I am trs (https://keybase.io/trs) on keybase.
  • I have a public key whose fingerprint is F725 2810 4751 90A7 4083 D8D5 B1E6 B89F B44E 4AA1

To claim this, I am signing this object:

cat("\n\n=== df initially\n");
print(df)
cat("\n\n=== df as data frame\n");
df = data.frame(x = c(1,2), y = c(3,4))
print(df)
aFunction = function(df) {
cat("\n\n=== df in function\n");
print(df)
#!/usr/bin/env perl
use strict;
use warnings;
use 5.018;
use List::Util qw< sum min max >;
use Bio::Cigar;
my ($file, $region) = @ARGV;
my @region = split /-/, $region =~ s/^.+://r;
@tsibley
tsibley / The-Puzzle.md
Last active August 29, 2015 14:11
ERRRNTATCR RESPNDENCE BETWEENNAM ESANDSEQS

A Puzzling Error

Today I noticed the following in the error logs of a small webservice I run at work:

Last alignment is non-null!  It should be the empty alignment of the bogus sequence.
  at lib/Bio/WebService/LANL/SequenceLocator.pm line 456.
Alignment is <
 Query ERRRNTATCR RESPNDENCE BETWEENNAM ESANDSEQS  39
 .:::: . : . . : .: .
#!/bin/bash
# From the releases mentioned in cpanfile.snapshot, filter out those mentioned in `carton tree`
if ! grep --version | grep -q GNU; then
echo "GNU grep is required; BSD grep is too feeble"
exit 1
fi
grep -vFf <(carton tree | grep -oP '(?<=\().+(?=\))') <(grep -P '^ \S' cpanfile.snapshot) | cut -c 3-
#!/usr/bin/env perl
# Given a string and a number of tolerable mismatches, generate a list of
# regexes for all possible combinations. Optionally anchor each regex either
# to the beginning (^) or end ($). For example:
#
# $ generate-mismatch-regexes ATCG 2 '^'
# ^ATCG
# ^.TCG
# ^A.CG
# ^AT.G