Skip to content

Instantly share code, notes, and snippets.

View semifor's full-sized avatar

Marc Mims semifor

  • Spokane Valley, WA
View GitHub Profile
#!/usr/bn/env perl
use 5.12.1;
use warnings;
package Foo {
use Devel::GlobalDestruction;
sub new { bless {}, ref $_[0] || $_[0] }
sub DESTROY {
#!/usr/bin/env perl
use 5.12.1;
use warnings;
#use POSIX qw/_exit/;
package Foo {
use Moose;
sub DEMOLISH {
my ( $self, $in_global_destruction ) = @_;
sub retry_once {
my ($code, $msg) = @_;
try { $code->() }
catch {
WARN "RETRY $msg: $_";
try { $code->() }
catch {
ERROR "FAIL $msg: $_";
};
#!/usr/bin/env perl
use 5.12.1;
use warnings;
use strict;
use ZeroMQ qw/:all/;
use ZeroMQ::Raw qw/zmq_device/;
my $worker_address = 'ipc:///tmp/workers.sock';
sub nt_with_retry {
my ( $nt, $method, @args ) = @_;
my $result;
my $redo = 0;
my $delay = 0.25;
do {
try {
$result = $nt->$method(@args);
@semifor
semifor / Keys.pm
Created December 6, 2011 06:02
For Lady_Aleena - revised Twitter::Keys
package Twitter::Keys;
use strict;
use warnings;
use base 'Exporter';
our @EXPORT = qw(consumer_key consumer_secret access_token access_token_secret);
my %tokens;
# I used <DATA> for simplicity
for ( <DATA> ) {
chomp;
# tokens.pl
package My::Consumer;
sub key () { 'foo' }
sub secret () { 'eyes-only!' }
1;
=head1 SYNOPSIS
@semifor
semifor / accounts.pl
Created November 29, 2011 22:17
Lady_Aleena's account setup script
#!/usr/bin/perl
use warnings;
use strict;
use Net::Twitter::Lite;
use lib '../../files/perl/lib';
use Base::Roots qw(get_data);
my %consumer_tokens = (
@semifor
semifor / xmonad.hs
Created September 26, 2011 22:35
xmonad.hs
import XMonad
import System.IO
import qualified XMonad.StackSet as W
import Data.Ratio ((%))
import XMonad.Actions.Commands
import XMonad.Hooks.DynamicLog
@semifor
semifor / bare-word.pl
Created September 24, 2011 19:48
Bareword disambiguation with + and ::
#!/usr/bin/env perl
use Test::More;
use O qw/-qq Deparse/;
package Foo;
sub Bar {}
package Foo::Bar;
sub new { bless {}, shift }