Skip to content

Instantly share code, notes, and snippets.

@s1037989
s1037989 / state.pl
Created February 15, 2016 09:31
Demonstration of the use of a state variable in a Mojolicious app
#!/usr/bin/env perl
package A;
use Mojo::Base -base;
use 5.020;
use feature qw(signatures);
has [qw(a b)];
sub new {
@s1037989
s1037989 / tap.pl
Created February 15, 2016 09:23
Demonstration of Mojo::Base::tap()
package Cat;
use Mojo::Base -base;
has name => 'Nyan';
has ['age', 'weight'] => 4;
package Tiger;
use Mojo::Base 'Cat';
has friend => sub { Cat->new };
@s1037989
s1037989 / gist:7b388a4d01e2cd568bbb
Created February 18, 2015 06:19
CPAN release and bump version
Needs some error handling.
release ()
{
NAME=$(perl -p -E '$_ = /^\s*NAME\s*/ ? eval("{$_}")->{NAME} : undef' Makefile.PL);
VERSION_FROM=$(perl -p -E '$_ = /^\s*VERSION_FROM\s*/ ? eval("{$_}")->{VERSION_FROM} : undef' Makefile.PL);
CV=$(perl -E "require '$VERSION_FROM'; say \$$NAME::VERSION");
BV=$(perl -E "require '$VERSION_FROM'; say \$$NAME::VERSION+0.01");
rm -f Mojolicious-Plugin-MimeTypes-*.tar.gz;
git tag $CV;
@jberger
jberger / leaderboard.pl
Last active August 29, 2015 14:05
A golf leaderboard websocket app
#!/usr/bin/env perl
use Mojolicious::Lite;
use Mango;
use Mojo::IOLoop;
use DDP;
use feature 'current_sub';
plugin 'Config' => {
file => 'leaderboard.conf',
@brianmed
brianmed / datachannel.pl
Created October 10, 2013 23:40
WebRTC DataChannel two user chat. Signaling included using websockets.
#!/opt/perl
use Mojolicious::Lite;
use JSON;
get '/' => sub {
my $self = shift;
$self->render("index");
};
@austinmarton
austinmarton / sendRawEth.c
Created February 27, 2012 08:40
Send a raw Ethernet frame in Linux
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
#include <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>