Skip to content

Instantly share code, notes, and snippets.

//
// ViewController.swift
// PDFAttempt
//
// Created by Glen Hinkle on 3/17/15.
// Copyright (c) 2015 Zombie Dolphin. All rights reserved.
//
import UIKit
@tempire
tempire / scope.pl
Last active August 29, 2015 13:56
delay around_action tx scope mojolicious
use Mojolicious::Lite;
use Mojo::IOLoop::Delay;
hook around_action => sub {
my ($next, $c, $action, $last) = @_;
$c->stash->{tx} = $c->tx; # Maintain scope
return $next->() if not $last;
my $delay = Mojo::IOLoop::Delay->new;
@tempire
tempire / delay remaining.pl
Last active August 29, 2015 13:56
delay remaining use case
my $ua = Mojo::UserAgent->new;
my $async1 = sub {
my $delay = shift;
$ua->get('http://api1?do_this=1' => sub { $delay->begin(0)->(pop->res->json) });
};
my $async2 = sub {
my $delay = shift;
Mojo::IOLoop->delay->steps(
named_serial_step => sub { ... },
named_serial_step2 => sub {
my $delay = shift;
$something ? $delay->pass : $delay->skip_to('named_serial_step3');
},
{
Mojo::IOLoop->delay->steps(
sub { ... },
sub {
my $delay = shift;
Mojo::IOLoop->timer(3 => sub { $delay->pass(-s1) });
},
# concurrent steps
@tempire
tempire / selection.pl
Created April 15, 2014 17:26
every n of element, limited by selection of /3
# The initial array
my @a = (1..100);
# Copy it, every 3rd elements
my @b = @a[ map { 3 * $_ } 0..$#a/3 ];
# Print it. space-delimited
$, = " ";
say @b;
Glen is a wandering developer who has been working with Perl for around 15 years, and still uses it because of Mojolicious. He created the Mojocasts, dabbles in iPhone apps, hates imperative coding, and believes that state doesn’t exist, but is rather a derivative of reality.
When he has the time, he plans on writing the accounting system to end all accounting system, at least until version 2,
when some company purchases it and decides to rewrite it all in imperative Python, at which point he will lose all faith in humanity and dissapate into the aether.
@tempire
tempire / ev_warnings.txt
Created May 10, 2014 17:44
ev make warnings
cc -c -Ilibev -fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -O3 -DVERSION=\"4.15\" -DXS_VERSION=\"4.15\" "-I/Users/glen/perl5/perlbrew/perls/perl-5.18.2/lib/5.18.2/darwin-2level/CORE" -DEV_USE_MONOTONIC=1 -DEV_USE_REALTIME=0 -DEV_USE_SELECT=1 -DEV_USE_POLL=1 -DEV_USE_EPOLL=0 -DEV_USE_KQUEUE=1 -DEV_USE_PORT=0 -DEV_USE_INOTIFY=0 -DEV_USE_EVENTFD=0 -DEV_USE_SIGNALFD=0 EV.c
In file included from EV.xs:34:
./libev/ev.c:477:48: warning: '/*' within block comment [-Wcomment]
/*#define MIN_INTERVAL 0.00000095367431640625 /* 1/2**20, good till 2200 */
^
In file included from EV.xs:34:
In file included from ./libev/ev.c:2396:
libev/ev_poll.c:110:18: warning: expression result unused [-Wunused-value]
assert (("libev: poll() returned illegal result, broken BSD kernel?", p < polls + pollcnt));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@tempire
tempire / more requirements
Created May 16, 2014 05:49
more requirements
Students are recommended to bring laptops running OSX or Linux. Windows will work for much of the labs, although high performance examples may not operate as expected.
Please arrive with Perl 5.16.3+, Mojolicious 4.98+, Modern::Perl, and App::cpanminus installed.
For those using lower versions of Perl, http://perlbrew.pl is recommended.
Modules can be installed using the following command:
curl -L cpanmin.us | perl - Mojolicious Modern::Perl App::cpanmin.us
use Mojolicious::Lite;
get '/:id' => sub {
my $self = shift;
my $id = $self->param('id');
my $ua = Mojo::UserAgent->new;
$ua->get(
"http://localhost:3001/" => sub {
my $tx = pop;