Skip to content

Instantly share code, notes, and snippets.

$rv->{ contacts } = [ map { { $_->{ contact_type } => $_->{ contact_data }, private => $_->{ private } } } map { { $_->get_columns() } } $person->search_related('contacts')->all ];
@PWBENNETT
PWBENNETT / _service_ccc_log_run
Last active August 29, 2015 14:04
For Doug & Bill
#!/bin/bash
exec multilog t ./main
@PWBENNETT
PWBENNETT / MyPackage.pm
Created July 23, 2014 08:56
Can you think of a better way to open myfile.dat, assuming it's installed in the same directory as MyPackage.pm?
package MyPackage;
use 5.020;
use utf8;
use File::Spec;
use File::Util qw( SL );
use IO::All;
sub foo {
my $oldfork = \&UNIVERSAL::fork;
sub fork {
# This makes child processes volunteer to be killed first by the kernel
# in case of a system-wide Out Of Memory error
my $rv = $oldfork->(@_);
eval {
open my $oom_adj, '>', "/proc/$$/oom_adj";
print $oom_adj "15\n";
close $oom_adj;
} unless $rv;
@PWBENNETT
PWBENNETT / stats.slif
Last active January 3, 2016 08:28
I think this is a good start on the Bhat / Vuduc / Agarwal / Gray stats language "as she is wrote", as opposed to the rather slim BNF given in the paper.
:start ::= Source
:discard ~ whitespace
:default ::= action => [values]
lexeme default = latm => 1 action => [value]
whitespace ~ [\p{Separator}]+
Source ::= HeaderFile
| ProgramFile
HeaderFile ::= Preamble UDFDefinitions
ProgramFile ::= Preamble OptionalUDFDefinitions PDFCalculation
PDFCalculation ::= ('pdf') Distribution
@PWBENNETT
PWBENNETT / MPL.tmLanguage
Created November 30, 2013 20:56
I've got these two .tmLanguage files in my Sublime Text 2 config. Marpa.tmLanguage works great on standalone Marpa SLIF grammars, and MPL.tmLanguage definitely does _something_ to the Perl source to make the contents of the heredoc "different" or "special" in some way, but it doesn't activate the SLIF syntax highlighting.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Marpa in Perl</string>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
@PWBENNETT
PWBENNETT / 00-sanity.t
Last active December 28, 2015 05:09
Next (working but fugly) stab at a simplified wrapper pragma for Marpa::R2::Scanless
#!perl -T
use 5.018;
use Test::More;
use lib qw( /home/paul/grammar-marpa/lib );
use grammar::marpa;
my $dsl = <<'END_OF_DSL';
:default ::= action => ::first
@PWBENNETT
PWBENNETT / mop.ebnf
Last active December 28, 2015 00:49
My first thoughts on something approaching the input format for the EBNF to .tmLanguage compiler
:start ::= Class
:discard ::= whitespace
:include = source.perl
:scopeName = source.mop
whitespace ~ [\s]+
Class ::= ClassKeyword ClassModifiers '{' ClassContent '}'
ClassKeyword ::= 'class' ClassName scope => meta.class.mop
| 'role' ClassName scope => meta.class.mop
ClassContent ::= ClassContent ClassContent include => source.perl
| Has
@PWBENNETT
PWBENNETT / ARIN.pm
Last active December 27, 2015 21:29
This is all I've got so far. Part of the plan is to make the follow() method perform a query using the value of a given resultset key, analogous to clicking a link in a browser, and the back() method analogous to hitting the back button in a browser. The ResultPath would in that case simply need to be an arrayref of resultsets, onto which follow…
package Net::Whois::Marpa::ARIN;
use 5.016;
use mop;
use IO::All;
use Marpa::R2;
class Net::Whois::Marpa::ARIN extends Net::Whois::Marpa with Net::Whois::Marpa::Logger {
has $!source = 'whois.arin.net';
@PWBENNETT
PWBENNETT / mop.tmLangauge
Created November 9, 2013 22:42
Start of a .tmLanguage file for p5-mop-redux
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Perl mop</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>