Skip to content

Instantly share code, notes, and snippets.

View jrockway's full-sized avatar

June Rockway jrockway

View GitHub Profile
#!/usr/bin/env perl
use strict;
use warnings;
use feature ':5.10';
use URI::Escape;
sub xx {
uri_unescape(
#!/usr/bin/env perl
use strict;
use warnings;
use feature ':5.10';
use Guard;
sub unwind_protect(&@){
my $code = shift;
use strict;
use warnings;
use feature ':5.10';
# this is a test
has 'breadboard' => (
is => 'ro',
isa => 'Bread::Board::Container',
handles => ['fetch'],
builder => '_build_breadboard',
);
sub _build_breadboard {
my $self = shift;
#include <EXTERN.h>
#include <perl.h>
#include <stdlib.h>
#include <stdio.h>
PerlInterpreter *my_perl;
inline SV *run_in(PerlInterpreter *perl, char *code){
SV *result;
my_perl = perl;
use strict;
use warnings;
use Test::More;
BEGIN { use_ok 'Eval::Clean' };
use JSON;
my $perl = Eval::Clean::new_perl();
ok $perl, 'got a new perl';
@jrockway
jrockway / get.pl
Created December 16, 2010 01:38
node.js proxy (with AnyEvent::HTTP test case)
#!/usr/bin/env perl
use strict;
use warnings;
use feature ':5.10';
use AnyEvent::HTTP;
my $cv = AE::cv;
http_get 'http://www.google.com/', $cv;
use strict;
use 5.010;
{ package Class;
sub new { my $self = bless $_[1], $_[0]; warn $self; $self }
sub DESTROY { warn $_[0] }
}
# works
{
@jrockway
jrockway / sock.c
Created April 4, 2011 23:13
perl vs. c for syslog protocol
#include <errno.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <time.h>
@jrockway
jrockway / events.js
Created April 6, 2011 02:53
class as event handler in node?
function EventListener() {}
EventListener.prototype.listen_to = function (that) {
for (var key in this) {
var event;
if(event = /^handle_(.+)$/.exec(key)){
var method = [this, this[event[0]]];
that.on( event[1], function() {
method[1].apply(method[0], arguments);
});