Skip to content

Instantly share code, notes, and snippets.

View belden's full-sized avatar

Belden Lyman belden

View GitHub Profile

I like a stand that has a swivel on it. Unfortunately they stopped making the one I like, but this one looks pretty good.

These speakers hold a charge for a good amount of time and sound pretty good.

I like to get a convex lens for the ipad too. The adhesive that comes with this kit is pretty crappy - the idea is you permanently affix a metal ring around your camera, then different lenses can magnetically attach to the metal ring. I just superglued the metal ring around the front-facing camera on the ipad, and then the lenses didn't pull that ring off.

package Pattern::NullObject;
use strict;
use warnings;
use overload (
'""' => sub { '' },
bool => sub { 0 },
fallback => 1,
);
@belden
belden / keybase.md
Created August 28, 2014 13:06
keybase.md

Keybase proof

I hereby claim:

  • I am belden on github.
  • I am belden (https://keybase.io/belden) on keybase.
  • I have a public key whose fingerprint is DB3E D821 7352 F18D CC2C 50AD 62D4 6597 FBFA 8A90

To claim this, I am signing this object:

Let's say you're writing this a lot:

my %hew_hash;
@new_hash{@keys} = @old_hash{@keys};

In perl 5.20, you'll be able to do that slice as a single assignment:

@belden
belden / tail-factorial.pl
Created December 2, 2013 23:03
Tail recursion pattern in Perl - for some reason people say Perl doesn't have tail recursion; you just need to do a little extra work.
#!/usr/bin/env perl
use strict;
use warnings;
use bigrat;
my $n = shift || 100;
print "$n! = " . tail_factorial($n) . "\n";
Inhalation of crystalline silica is harmful to the lungs, causing
silicosis. Amorphous silica is considered to be low toxicity, but prolonged
inhalation cause changes to the lungs.[24] Diatomaceous earth is mostly
amorphous silica, but contains some crystalline silica, especially in the
saltwater forms.[25] In a study of workers, those exposed to natural DE for
over 5 years had no significant lung changes, while 40% of those exposed
to the calcined form had developed pneumoconiosis.[26] Today's common
D.E. formulations are safer to use as they are predominantly made up of
amorphous silica and contain little or no crystalline silica.[27]
@belden
belden / gmtime-for-cookies.pl
Created April 24, 2013 15:28
Testing equivalence: gmtime for cookies from an epoch
# instruct Test::Easy's time-equivalence function how to compare an epoch timestamp
# to something like "Wed, 24-Apr-2013 16:15:38 GMT"
Test::Easy::Time->add_format(
_description => 'gmtime for cookies',
format_epoch_seconds => sub {
@belden
belden / maybe.pl
Created March 18, 2013 14:55
Whenever I look at Patterns::UndefObject I want it to act more like this instead.
#!/usr/bin/env perl
{
package maybe;
use overload 'bool' => sub { 0 };
sub new { bless \$_[0] }
sub DESTROY {}
sub AUTOLOAD { shift }
}
@belden
belden / sticky-inc.patch
Created February 21, 2013 01:02
lib::with::preamble places a code hook at the beginning of @inc, and then relies upon that hook remaining at $INC[0]. In a suitably complicated codebase, there is likely to be one module which modifies the head of @inc, and some subsequent module which violates the constraints that lib::with::preamble is intended to enforce. Included in the patc…
diff --git a/Makefile.PL b/Makefile.PL
index cfc4d6d..8e90634 100644
--- Makefile.PL
+++ Makefile.PL
@@ -8,5 +8,8 @@ WriteMakefile(
NAME => 'lib-with-preamble',
VERSION_FROM => 'lib/lib/with/preamble.pm',
PM_FILTER => 'perl my/filter',
- PREREQ_PM => { 'PerlIO::via::dynamic' => 0.02 },
+ PREREQ_PM => {
@belden
belden / y-combinator.pl
Created August 22, 2012 20:55
y-combinator.pl
#!/usr/bin/env perl
use strict;
use warnings;
sub y_combinator (&) {
my $curried = shift;
return sub {
my $f1 = shift;
return $curried->(sub { $f1->($f1)(@_) });
}->(sub {