Skip to content

Instantly share code, notes, and snippets.

View tobyink's full-sized avatar
🦈
hi

Toby Inkster tobyink

🦈
hi
View GitHub Profile
use strict;
use warnings;
use File::Spec;
my @candidates = (
File::Spec->catfile('/', 'usr', 'bin', 'zip'),
File::Spec->catfile('/', 'usr', 'local', 'bin', 'zip'),
File::Spec->catfile('C:', 'bin', 'zip'), # for Windows
);
@tobyink
tobyink / rpg.pl
Last active August 29, 2015 13:56
package main;
use Moops;
class Character {
has name => (is => 'ro', isa => Str);
method BUILD ($p) {
my $race = $p->{race} // 'Human';
Moo::Role->apply_roles_to_object($self, "Race::$race");
}
}
dSP;
int count;
SV *ret;
bool can;
SV *method_name = newSV(0);
sv_setpv(SV*, "MATCH");
ENTER;
SAVETMPS;
PUSHMARK(SP);
dSP;
int count;
SV *ret;
bool can;
SV *method_name = newSV(0);
sv_setpv(SV*, "MATCH");
ENTER;
SAVETMPS;
PUSHMARK(SP);
use feature qw(state)
use Types::Standard qw(-all);
use Type::Params qw(compile);
sub yada {
state $check = compile Value, ArrayRef, Optional[HashRef];
my (...) = $check->(@_);
...;
}
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
#include "const-c.inc"
int _mycall (char* methodname, SV* args[], int argc, int gimme)
{
{
my $_only_called_in_calc = sub {
...;
};
sub calc {
my $result = $_only_called_in_calc->(1,2,3);
...;
}
}
use strict;
use warnings;
{
package Event;
use Moose;
use Types::Standard qw( Str );
use Types::XSD qw( Date );
has start_date => (
<!-- Generated by CGI::FormBuilder v3.09 available from www.formbuilder.org -->
<form method="post" onsubmit="return validate(this);">
<div><input id="_submitted" name="_submitted" type="hidden" value="1" /></div>
<table>
<tr valign="top">
<td><b>Activity Desc</b></td>
<td><input id="activity_desc" name="activity_desc" type="text" value="Other" /></td>
</tr>
<tr valign="top">
<td><b>Historic</b></td>
simple_crud(
record_title => $source,
prefix => "/lookup/$table",
db_table => $table,
key_column => do { my @cols = $class->primary_columns; @cols==1 or die; $cols[0] },
editable => true, # TODO: need auth!
deletable => false,
downloadable => true,
paginate => undef,
);