Skip to content

Instantly share code, notes, and snippets.

@preaction
preaction / outlier.pl
Last active August 29, 2015 14:16
Basic time series outlier analysis using PDL and TAlib
use strict;
use warnings;
use feature qw( :5.16 );
use PDL;
use PDL::Finance::TA;
my $threshold = 4;
my $limit = 100;
my $period = 30;
@preaction
preaction / Config.pod
Last active August 29, 2015 14:16
New Beam-Wire docs

DESCRIPTION

This is tutorial for Beam::Wire, starting with simple use as a configuration file, to complex dependency injection.

SIMPLE CONFIGURATION

The basic Beam::Wire configuration is a hash of hashes describing how to create objects (which, in a dependency injection context, are called "services"). The top-level keys are the name of the

@preaction
preaction / blog.md
Created February 25, 2015 03:51
Statocles release announcement

Static site generators are popular these days. For small sites, the ability to quickly author content using simple tools is key. The ability to use lower-cost (even free) hosting, often without any dynamic capabilities, is good for trying to maintain a budget. For larger sites, the ability to serve content quickly and cheaply is beneficial, and since most pages are read far more often than it is written, generating a full web page to store on the filesystem can improve performance (and lower costs).

For me, I like the convenience of using Github Pages to host project-oriented websites. The project itself is already on Github, so why not keep the website closely tied to it so it doesn't get out-of-date? For an organization like the Chicago Perl Mongers, Github can even host custom domains, allowing easy collaboration on websites.

It's through the Chicago.PM website that I was introduced to Octopress, a blogging engine buil

@preaction
preaction / gist:a5acc624da4abd9b88b4
Created February 20, 2015 19:34
Devel::Peek from MongoDB and Hash literal with "use utf8"
### From MongoDB
SV = IV(0x40dbef8) at 0x40dbf08
REFCNT = 1
FLAGS = (ROK)
RV = 0x40dbea8
SV = PVHV(0x40d2fb0) at 0x40dbea8
REFCNT = 1
FLAGS = (OOK,SHAREKEYS,HASKFLAGS)
ARRAY = 0x40554f0 (0:5, 1:3)
hash quality = 150.0%
package DbLibTry;
use Mojo::Base '-strict';
use DBI;
has dbh => sub {
DBI->connect( "DBI:SQLite:dbname=songdb.sqlite3", q{}, q{}, {RaiseError => 1} )
or die $DBI::errstr;
};
@preaction
preaction / git-leader.sh
Last active August 29, 2015 14:14
leaderboard for git
git log --shortstat | awk '/Author|changed/' | perl -lne'if ( /^Author: (.+)/ ) { $author = $1 } else { while ( /(?:(\d+) (?:insertions|deletions))/g ) { $changes{ $author } += $1 } } END { print "$changes{$_} $_" for keys %changes }'
# 2674 Doug Bell <[email protected]>
# 18332 Doug Bell <[email protected]>
@preaction
preaction / uniqpersec.sh
Last active August 29, 2015 14:13
Measure unique lines per second
FILE=/tmp/whatever
while ; do;
LINES=$(sort $FILE | uniq | wc -l | awk '{ print $1 }' );
echo $LINES;
echo $OLD_LINES;
echo $( dc -e"$LINES $OLD_LINES - p" );
OLD_LINES=$LINES;
sleep 1;
done;
@preaction
preaction / pythonic_packages.pl
Created January 16, 2015 05:22
Pythonic packages/classes
package My::Pythonic::Package {
use My::Pythonic qw( Base );
class MyClass extends Base {
}
}
# Now in package main again
use My::Pythonic::Package qw( MyClass );
my $obj = MyClass->new;
@preaction
preaction / gist:a624521088c4b916bd84
Last active August 29, 2015 14:13
Simple readonly hash object
use strict;
use warnings;
use feature qw( say );
package Hash::Object;
sub new {
my ( $class, %self ) = @_;
return bless { %self }, $class;
}
use v5.20;
use Class::Anonymous;
my %hash = (
foo => 'bar',
baz => 'fuzz',
);