Skip to content

Instantly share code, notes, and snippets.

View belden's full-sized avatar

Belden Lyman belden

View GitHub Profile
@belden
belden / testing-thoughts.md
Last active August 29, 2015 14:22
thoughts on testing

A few thoughts on testing:

  • If you're used to PHPunit, then you might find Test::Class to be analogous.
  • However, if you're not going to use the different features of Test::Class (namely: being able to subclass your test classes), then you'll probably get a lot of mileage out of just using Test::More or Test::Most.

Here's a quick rundown of the features that I see these three providing.

module ships with perl ease of use like phpunit
Test::More yes high no
@belden
belden / belden-2015-lightning-talk-abstract.md
Last active August 29, 2015 14:22
Belden's 2015 YAPC::NA Lightning Talk Abstract
Let's say you've got this code:
{
  package math;

  sub add {
    my ($left, $right) = @_;   # Look, I am a function

    return $left + $right;
@belden
belden / sparse.pl
Created May 29, 2015 18:32
Shows how to correctly de-sparsify a Perl array for storage into a postgresql 'array' data type
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
my @sparse;
$sparse[0] = 'start';
$sparse[3] = undef;
@belden
belden / logan-golang.el
Last active August 29, 2015 14:21
Golang stuff for Logan
;; this could use some improvement
;;
;; - it doesn't clean up the temp file
;; - it doesn't ensure there's a selected region
;; - etc.
;;
(defun logan/run-selected-golang-code ()
"run the selected code as though it is golang code"
(interactive)
(let ((tempfile (format "%s.go" (make-temp-file "logan-golang"))))
@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
@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 / 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 / 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 / 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))
#!/usr/bin/env perl
# this file is broken
use strict;
use warnings;
{
package My::Base;
use Moose;