Skip to content

Instantly share code, notes, and snippets.

for my $source_name (__PACKAGE__->sources) {
my $method_name = lc($source_name =~ s/(?<=.)(?=[A-Z])/_/axmsgr);
s/(?<![aeiou])y$/ies/axms or s/(?:ss|s|sh|ch|x)\K\z/es/axms or s/\z/s/axms
for $method_name; # XXX: perhaps use Lingua::EN::Inflect or similar?
my $method = sub {
my $rs = shift->resultset($source_name);
return @_ ? $rs->search_rs(@_) : $rs;
};
no strict 'refs';
*$method_name = $method;
@arc
arc / slab.c
Created October 23, 2014 15:24
/* Trivial (and totally untested) slab allocator */
struct slab;
struct slab {
struct slab *prev;
void *buf;
size_t avail, orig_size;
};
struct slab *slab_create(size_t initial_size) {
@arc
arc / gist:0330448a68672b71170b
Last active August 29, 2015 14:06
Velvet cheesecake recipe

(Originally from Evelyn Rose’s “Complete International Jewish Cookbook”, ISBN 1861057326.)

Pastry

This is enough for a 20 cm tin, about 5 cm deep. Mix 175 g self-raising flour (or plain flour with 1½ tsp baking powder), 125 g butter, 50 g icing sugar, 1 egg yolk, and 1 tbsp water, until the ingredients form a dough of a suitable texture. Chill for 30 minutes, then roll out on a floured board to fit your desired tin. Return to the fridge while you prepare the filling.

Filling

Separate 2 eggs. Beat the yolks with 450 g curd cheese, ½ teaspoon vanilla, juice and rind of half a lemon, 50 g melted butter, 50 g caster sugar, 2 level tbsp cornflour, and 150 ml soured cream, until smooth and thick. Whisk the whites to stiff peaks, then whisk in an additional 2 tsp caster sugar. Fold the whites into the cheese mixture, then fill the prepared pastry. Ensure the top is smooth and level.

@arc
arc / gist:6688183
Created September 24, 2013 17:23
Straw-man support for calling table_class/::View in DBIC Schema::Loader. Is this totally insane?
diff --git i/lib/DBIx/Class/Schema/Loader/Base.pm w/lib/DBIx/Class/Schema/Loader/Base.pm
index b37223c..9c1f295 100644
--- i/lib/DBIx/Class/Schema/Loader/Base.pm
+++ w/lib/DBIx/Class/Schema/Loader/Base.pm
@@ -2393,6 +2393,11 @@ sub _make_column_accessor_name {
return $accessor;
}
+sub _table_is_view {
+ #my ($self, $table) = @_;
@arc
arc / gist:6268974
Last active December 21, 2015 07:09
sub call_with_timeout {
my ($timeout, $callback) = @_;
my $timeout_expired;
my $completed = eval {
local $SIG{ALRM} = sub { $timeout_expired = 1; die "alarm\n" };
my $completed = eval {
alarm $timeout;
$callback->();
1;
@arc
arc / gist:1957998
Created March 2, 2012 11:58 — forked from Ovid/gist:1957853
perlfind -- perldoc on steroids
#!/usr/bin/env perl
use strict;
use warnings;
use Carp qw(cluck);
use autodie ':all';
use Getopt::Long 2.33 qw(:config auto_help);
use File::Find::Rule;
use File::Basename 'basename';