Skip to content

Instantly share code, notes, and snippets.

sub _serverName {
my $self = shift;
my $row = shift;
return (length($row->{'inventory_tag'})
? $row->{'inventory_tag'}
: (length($row->{'hostname'})
? $row->{'hostname'}
: (length($row->{'rack_id'})
? $row->{'rack_id'}
: (length($row->{'nickname'})
#!/usr/bin/perl
use Regexp::Grammars;
use File::Slurp;
use Data::Dump qw/dump/;
my $config = read_file $ARGV[0];
my $parser = qr{
<[Item]>+
onCmdC: function(event) {
if (!this.activeWindow.input.focused) {
this.activeWindow.input.cancelNextFocus();
}
},
onCmdK: function() {
this.activeWindow.messages.update("");
this.activeWindow.lastNick = "";
},
@leedo
leedo / gist:213500
Created October 19, 2009 16:33
alice frontend using seed
#!/usr/bin/env seed
Gtk = imports.gi.Gtk;
Glib = imports.gi.GLib;
WebKit = imports.gi.WebKit;
os = imports.os;
Gtk.init(Seed.argv);
window = new Gtk.Window({title: "Alice"});
$$('head script[src]').findAll(function(s) {
return s.src.match(js);
}).each(function(s) {
var params = s.src.match(js)[1];
params.split("&").each(function(o) {
var kv = o.split("=");
options[kv[0]] = kv[1];
});
});
#!/usr/bin/perl
use IO::Socket::INET;
use AnyEvent::Socket;
use AnyEvent::Handle;
use FindBin;
use lib "$FindBin::Bin/../lib";
use App::Alice;
my $confdir = "/home/leedo/alices";
use Text::MicroTemplate::File;
use AnyEvent::DBI;
my $dbh = AnyEvent::DBI->new("DBI:SQLite:dbname=users.db","","");
my $tmt = Text::MicroTemplate::File->new(
include_path => "/home/leedo/alice-manager/templates"
);
package HTTPProxyHandler;
use base qw(Tatsumaki::Handler);
http_request(GET => $url,
want_body_handle => 1,
sub {
my ($handle, $headers) = @_;
$self->response->headers($headers);
$handle->on_eof(sub {
$self->finish;
$handle->destroy
});
$handle->on_read(sub {
package Joe::Registration::Form;
use HTML::FormHandler::Moose;
extends 'HTML::FormHandler';
has '+item_class' => ( default => 'Registration' );
has_field username => (
type => 'Username',
label => 'Username',
package Plack::App::ImageProxy;
use strict;
use warnings;
use Path::Class qw/dir/;
use Cache::File;
use Plack::Request;
use Plack::Response;
use AnyEvent::HTTP;