Skip to content

Instantly share code, notes, and snippets.

View belden's full-sized avatar

Belden Lyman belden

View GitHub Profile

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 / 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:

package Pattern::NullObject;
use strict;
use warnings;
use overload (
'""' => sub { '' },
bool => sub { 0 },
fallback => 1,
);

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.

#!/usr/bin/env perl
# this file is broken
use strict;
use warnings;
{
package My::Base;
use Moose;
@belden
belden / adama-test.el
Created January 29, 2015 15:53
extensions to make emacs more useful as an IDE
(defun adama-run-test ()
"Run a file with run_tests"
(interactive)
(setq compile-rpf-command (concat "/home/dev/bin/development-tools/run_tests --verbose " (buffer-file-name)))
(message "compile-rpf-command: %s" compile-rpf-command)
(compile compile-rpf-command)
(other-window 1)
(toggle-read-only)
(other-window 1))
@belden
belden / findsub.pl
Last active August 29, 2015 14:14
debugging tools
#!/usr/bin/env perl
# use this in the debugger to find a package that implements some name
# to use this:
# 1. download to a local file
# curl https://gist.githubusercontent.com/belden/af7ea7857243743125ed/raw/76b350faaa6ec586f15d426e78d5a5f374783d5a/findsub.pl > /tmp/findsub.pl
# 2. load it up in the debugger
# DB<28> do '/tmp/findsub.pl'
# 3. use it
# DB<29> main::findsub 'prepare_body'
@belden
belden / Deathly-Hallows.pm
Created February 12, 2015 16:07
Make all your modules deadly
use strict;
use warnings;
package Deathly::Hallows;
# Add a hook to force `use warnings (FATAL => 'all');` at the head of
# all Adama modules.
#
# 'perldoc -f require' will tell you about adding coderef hooks to @INC.
#
# Note that this toy module doesn't keep itself at the head of @INC, which
@belden
belden / belden-redef.md
Last active August 29, 2015 14:17
A postgreql function that drops itself

Playing around on the train this morning:

drop function if exists belden_redef();
create function belden_redef()
returns bool
as
$$
begin
 raise notice 'now you see me...';
@belden
belden / gist:f29700695ca5624c97c5
Created April 15, 2015 18:43
lenovo bios update link
http://support.lenovo.com/us/en/products/laptops-and-netbooks/thinkpad-x-series-laptops/thinkpad-x1-carbon-20bs-20bt//downloads/DS101975