Skip to content

Instantly share code, notes, and snippets.

View exodist's full-sized avatar

Chad Granum exodist

View GitHub Profile
@exodist
exodist / gist:777505
Created January 13, 2011 06:52
What gives?
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
our $TBOUT;
BEGIN {
if ( eval { require Test::Builder; 1 }) {
my $Testout;
open( $Testout, '>', \$TBOUT ) || die $!;
@exodist
exodist / gist:813826
Created February 6, 2011 23:32
radvd.conf
interface br1
{
AdvSendAdvert on;
AdvLinkMTU 1280;
MaxRtrAdvInterval 300;
prefix 2002:4b94:5e91:2::/16
{
AdvOnLink on;
AdvAutonomous on;
};
@exodist
exodist / gist:1124341
Created August 4, 2011 01:55
Modifying exports in before_export.
sub before_import {
my ( $dest, $spec ) = @_;
if ( $spec->config->{someoption} ) {
$spec->exports->{foo} = [
Exporter::Declare::Export::Sub->new(
sub { ... },
exported_by => __PACKAGE__,
),
{},
@exodist
exodist / gist:1129133
Created August 6, 2011 07:25
Memory manager with parallel GC
Each thread has it's own memory unit containing a stack and a heap.
Stack:
* contains a region of memory that issues out pointers (called stack-handles)
* can be pushed which marks the last used pointer in the region
* can be popped resetting the pointer to the last pushed position
* is a stack, so the pushed pointers are in a linked list, LIFO
Heap:
* Has region of memory that issues a fixed-width structure with a data pointer and flags
package Foo;
use strict;
use warnings;
use Test::More;
BEGIN { $INC{'Foo.pm'} = __FILE__ }
sub import {
my $class = shift;
my $caller = caller;
@exodist
exodist / archive
Created February 27, 2012 23:35
archive
NUMBER OF FILES
BYTESTART NAMESTART
FNAMELENGTH Path/to/file1 BYTESTART BYTELENGTH
FNAMELENGTH Path/to/file2 BYTESTART BYTELENGTH
File1...
File2...
...
/*
Index entry count is numfiles / 25
@exodist
exodist / format
Created March 2, 2012 05:19
format
IndexableArchiveVXXXX.XXXX
uint64 jump size
uint64 jump count
...long data...
(
Checksum
Data
)
...index index...
@exodist
exodist / composition
Created May 24, 2012 04:06
Composition
Role Composition:
* Adopt all attributes of sub-roles, error on conflict
* Adopt all requirements of sub-roles, except those met by this role.
* Adopt all methods of sub-roles, add conflicts to required
* Merge roles hash (squash config)
Type Composition:
* Adopt all attributes of roles, error on conflict
* For each role
* bring in role methods, exclude those also listed as a requirement
@exodist
exodist / gist:4774202
Created February 12, 2013 22:48
eval example
package My::Thing;
use strict;
BEGIN {
$INC{'My/Thing.pm'} = __FILE__;
}
sub import {
my $caller = caller;
eval <<" EOT" || die $@;
@exodist
exodist / gist:4774332
Last active December 12, 2015 12:48
no eval
package My::Thing;
use strict;
BEGIN {
$INC{'My/Thing.pm'} = __FILE__;
}
sub import {
my $class = shift;
my $caller = caller;