Skip to content

Instantly share code, notes, and snippets.

Toby Inkster tobyink

Block or report user

Report or block tobyink

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tobyink
tobyink / Example.java
Created Feb 7, 2019
Example of using arrays in Java
View Example.java
/* I'm not very good at Java */
class Example {
public static void main(String[] args) {
exampleWithoutArray();
exampleWithArray();
}
public static void exampleWithoutArray () {
View Point.pm
use strict; use warnings;
package Point {
sub new {
bless {
x => 0,
y => 0,
@_,
}, shift;
}
View gist:ea5e4f7cb4a8b0dec3f883d6cc0d189e
use strict; use warnings;
package Point {
sub new {
bless {
x => 0,
y => 0,
@_,
}, shift;
View bench.pl
use strict;
use warnings;
use Benchmark qw(cmpthese);
package Local::Moose::Native {
use Moose;
has foo => (is => 'rw', isa => 'Int');
}
package Local::Moose::TypeTiny {
@tobyink
tobyink / perldocsort.pl
Created Jun 28, 2018
Better sorting for perl docs
View perldocsort.pl
use v5.14;
use strict;
use warnings;
use version;
use List::MoreUtils qw(part);
my @packages = map [split / - /], map { chomp; $_ } <DATA>;
my ($perl, $delta, $other) = part {
$_->[0] =~ /^perl.*delta$/ ? 1 :
View XSConstructor.xs
#include "xshelper.h"
#define IsObject(sv) (SvROK(sv) && SvOBJECT(SvRV(sv)))
#define IsArrayRef(sv) (SvROK(sv) && !SvOBJECT(SvRV(sv)) && SvTYPE(SvRV(sv)) == SVt_PVAV)
#define IsHashRef(sv) (SvROK(sv) && !SvOBJECT(SvRV(sv)) && SvTYPE(SvRV(sv)) == SVt_PVHV)
#define IsCodeRef(sv) (SvROK(sv) && !SvOBJECT(SvRV(sv)) && SvTYPE(SvRV(sv)) == SVt_PVCV)
#define XSCON_xc_stash(a) ( (HV*)XSCON_av_at((a), XSCON_XC_STASH) )
static HV*
View gist:517b88251b5c0d576130cb110a72553d
Program received signal SIGSEGV, Segmentation fault.
0x0000555555616f00 in Perl_hv_common ()
(gdb) bt
#0 0x0000555555616f00 in Perl_hv_common ()
#1 0x0000555555618144 in Perl_hv_common_key_len ()
#2 0x00007ffff69060a9 in XS_Class__XSConstructor_new ()
from /home/tai/src/p5/p5-class-xsconstructor/Class-XSConstructor-0.001/blib/arch/auto/Class/XSConstructor/XSConstructor.so
#3 0x0000555555623e09 in Perl_pp_entersub ()
#4 0x000055555561bf33 in Perl_runops_standard ()
#5 0x00005555555a7b74 in perl_run ()
@tobyink
tobyink / example.pl
Last active Jun 24, 2017
Demonstration of Template::Compile
View example.pl
use Types::Standard -types;
use Template::Compiled;
my $template = Template::Compiled->new(
signature => [
name => Str,
age => Int->plus_coercions(Num, sub { int $_ } ),
],
template => '<p>Hi <?= $name ?>. You are <?= $age ?> years old.</p>',
escape => 'html',
View factory.pl
use strict;
use warnings;
{
package Widget;
use Moose;
has identifier => (
is => 'ro',
isa => 'Int',
required => !!1,
View list-of-instances.pl
use strict;
use warnings;
use Data::Dumper;
{
package My::Example;
use Moose;
use Scalar::Util qw(weaken);
use Hash::Util::FieldHash::Compat qw(fieldhash);
You can’t perform that action at this time.