Skip to content

Instantly share code, notes, and snippets.

View hoelzro's full-sized avatar

Rob Hoelz hoelzro

View GitHub Profile
/* compile like this: gcc -o test test.c -ldl */
#include <stdio.h>
#include <dlfcn.h>
int main(void)
{
const char *path = "/usr/lib64/lua/5.1/lgob/webkit.so";
void *handle;
my $error;
local $SIG{__DIE__} = sub {
( $error ) = @_;
$cond->send;
};
$cond->recv;
if($error) {
( $status, $headers, $body ) = ( 500, ['Content-Type' => 'text/plain'], [ $error ] );
}
package MyPackage;
has path => (
is => 'ro',
isa => 'Str',
default => sub {
return '~/Sandbox';
},
traits => ['ExpandHome'],
);
#!/usr/bin/env perl
use Moose;
use MooseX::Types -declare => [qw/Arrayify/];
use MooseX::Types::Moose qw/Any ArrayRef Str/;
subtype Arrayify,
as ArrayRef;
coerce Arrayify,
#!/usr/bin/env plackup
use strict;
use warnings;
use autodie qw(exec fork open);
use IO::Pipe;
sub {
perl -le 'my $str = q{TEST}; $pat = "test"; my $mod = "i"; $regex = qr/(?^$mod:$pat)/; print $str =~ $regex;'
my $body = IO::File->new('some-large-file', 'r');
my $sender = sub {
my ( $h, $continuation ) = @_;
my $body_h;
$body_h = AnyEvent::Handle->new(
fh => $body,
on_read => sub {
my $buf = $body_h->rbuf;
@hoelzro
hoelzro / act-template.ini
Created August 22, 2011 23:35
Act Configuration Template
[general]
conferences = yapcna
cookie_name = act
searchlimit = 20
dir_photos = photos
dir_ttc = var/
max_imgsize = 320x200
root = $(home)/wwwdocs
default_language = en
languages = en
use Plack::Builder;
builder {
enable $mw1;
enable $mw2;
enable $mw3;
$app;
}; # this works like normal!
@hoelzro
hoelzro / gist:1201430
Created September 7, 2011 19:12
Pure Lua implementation of require() that allows you to specify a custom function environment
function env_require(module, env)
local loaders = package.loaders
local errors = {}
local load_fn
for _, loader in ipairs(loaders) do
local fn = loader(module)
if type(fn) == 'function' then
load_fn = fn
break
elseif type(fn) == 'string' then