Skip to content

Instantly share code, notes, and snippets.

View hinrik's full-sized avatar

Hinrik Örn Sigurðsson hinrik

View GitHub Profile
#!/usr/bin/env perl
use strict;
use warnings;
my $file = 'lib/Hailo.pm';
my $old = qx"git rev-parse HEAD:$file 2>/dev/null";
my $new = qx"git rev-parse :$file 2>/dev/null";
if (($? >> 8) != 0 || $old ne $new) {
$ENV{PERL_UNICODE} = 'O';
CREATE TABLE info (
attribute TEXT NOT NULL UNIQUE PRIMARY KEY,
text TEXT NOT NULL
);
CREATE TABLE expr (
id INTEGER PRIMARY KEY AUTOINCREMENT,
text TEXT UNIQUE,
);
package Session;
use MooseX::POE;
use namespace::clean -except => 'meta';
has session_id => (
isa => 'Int',
is => 'rw',
);
@hinrik
hinrik / gist:305741
Created February 16, 2010 17:57
Supplying a custom FTS3 tokenizer to SQLite from Perl
use strict;
use warnings;
use Inline C => Config => LIBS => '-lsqlite3';
use Inline C => <<'END';
#include <sqlite3.h>
/* Not included in sqlite.h */
#define SQLITE_PRIVATE static
#define SQLITE_ENABLE_FTS3 1
#define UNUSED_PARAMETER(x) (void)(x)
use strict;
use warnings;
use lib 't/inc';
use POE qw(Wheel::SocketFactory);
use Socket;
use POE::Component::IRC;
use POE::Component::Server::IRC;
use Test::More tests => 4;
my $bot1 = POE::Component::IRC->spawn(
From 28e984dbb1ad6f47e419414d07b298b97c022d07 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hinrik=20=C3=96rn=20Sigur=C3=B0sson?= <[email protected]>
Date: Thu, 20 May 2010 15:25:18 +0000
Subject: [PATCH] Support a user-supplied authorization sub for commands
---
Changes | 1 +
lib/POE/Component/IRC/Plugin/BotCommand.pm | 31 ++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 0 deletions(-)
@hinrik
hinrik / flac2mp3
Created June 2, 2010 00:21
Encode FLAC files into properly tagged MP3 files
#!/usr/bin/env perl
use strict;
use warnings;
use File::Spec::Functions qw(catfile splitpath);
use File::Which;
use Getopt::Long qw(:config auto_help);
use List::Util qw(first);
use Pod::Usage;
use String::ShellQuote;
From 780e2410506ecd78b43c71ee2d2bbbc2a37184ca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hinrik=20=C3=96rn=20Sigur=C3=B0sson?= <[email protected]>
Date: Tue, 22 Jun 2010 18:53:42 +0000
Subject: [PATCH] Fix child exit problems
A typo was plaguing the Program => ARRAY form.
Wrap the Program => CODE form in an eval. Otherwise, code that die()s
will not exit cleanly.
---
#!/usr/bin/env perl
# vim: ts=2 sw=2 filetype=perl expandtab
use strict;
use warnings;
use Test::More;
use POE qw(Wheel::Run);
plan tests => 1;
use strict;
use warnings;
use POE;
use Test::More tests => 1;
POE::Session->create(
package_states => [
(__PACKAGE__) => [qw(
_start
exit