Skip to content

Instantly share code, notes, and snippets.

View stash's full-sized avatar
🎯
Focusing

Jeremy Stashewsky stash

🎯
Focusing
View GitHub Profile
package MyBaseWorker;
extends 'TheSchwartz::Moosified::Worker'
sub work {
my $class = shift;
my $job = shift;
my $subtasks = $job->{subtasks};
for my $subtask (@$subtasks) {
my $task = Subtask::Factory->Create($subtask);
Moose::Meta::Class->create_class('MyParticularWorker' => ['BasicWorker','Fetcher','LOLifier']);
$client->can_do('MyParticularWorker');
#!/usr/bin/perl
use warnings;
use strict;
use Benchmark qw/cmpthese/;
# perl 5.8.6 x86_64-linux-gnu-thread-multi
# Rate h_e l_c h_d l3_e l2_e l_e l_d l2_d l_a l2_a l2_b l_b a_c hr_e hr_f
# h_e 371747/s -- -1% -21% -22% -23% -24% -34% -40% -42% -43% -53% -53% -57% -74% -78%
# l_c 377358/s 2% -- -20% -21% -22% -23% -33% -39% -42% -42% -52% -52% -57% -73% -77%
# h_d 469484/s 26% 24% -- -2% -3% -4% -17% -24% -27% -28% -40% -40% -46% -67% -72%
@stash
stash / gist:207935
Created October 11, 2009 22:51
Outline for a Moose Intro
The hard way
* manual constructors and accessors
The declarative way
* Perhaps compare some of the older accessor-generators.
The Moose way
* declarative = good.
Attributes.
package Plack::Server::CoroAnyEvent;
use warnings;
use strict;
use base 'Plack::Server::AnyEvent';
use Coro;
use Coro::AnyEvent;
use AnyEvent ();
#!/usr/bin/env perl
use warnings;
use strict;
use Test::More;
use JavaScript;
my $rt = JavaScript::Runtime->new;
my $cx = $rt->create_context;
my $js_callback;
@stash
stash / array-mem.pl
Created July 16, 2010 23:16
Demonstration of perl array memory usage
#!/usr/bin/perl
use warnings;
use strict;
use Devel::Size qw/size total_size/;
use constant N => 1_000_000;
fillerup: {
my $x = [2 .. N];
print size($x) . " " . total_size($x) . "\n";
var http = require('http'),
Iconv = require('iconv').Iconv,
buffertools = require('buffertools');
function goGetAmazon() {
var headers;
var chunks = [];
var req = http.request({
method: 'GET',
vows = require 'vows'
assert = require 'assert'
vows.describe("nesting").addBatch(
"top":
topic: () -> "topval"
"check": () -> console.log(arguments); assert.ok 1
"alpha":
topic: () ->
console.log("topic alpha",arguments)
@stash
stash / node-get.js
Created August 30, 2011 21:29
Strange .pause() behaviour for http client response stream
var fs = require('fs'),
http = require('http');
var ws = fs.createWriteStream('/tmp/get.png',{flags:'w'});
var reqOpts = {
method: 'GET',
path: '/images/nav_logo83.png',
host: 'www.google.ca'
};