Skip to content

Instantly share code, notes, and snippets.

@leedo
leedo / gist:1320474
Created October 27, 2011 18:55
Condvar zen
sub post_download {
my ($self, $body, $cb) = @_;
my $data = decode_json $body;
my $gist = $data->{gists}[0];
my $cv = AE::cv;
while (my $file = shift @{$gist->{files}}) {
$cv->begin;
if ($provider->matches($req)) {
$provider->pre_download($req, sub {
my $req = shift;
$self->download($provider, $req);
});
}
leedo$ brew list
cmake gnupg libevent libxml2 pcre wget
faac gnutls libgcrypt lighttpd php x264
ffmpeg imagemagick libgpg-error little-cms pidof xcache
gdbm irssi libogg mcrypt pkg-config xvid
gettext jasper libpng memcache-php readline yasm
ghc jhead libtasn1 memcached redis zsh
gifsicle jpeg libtiff mongodb taglib
git lame libvorbis mysql theora
glib lftp libvpx node watch
@leedo
leedo / gist:1243567
Created September 26, 2011 22:17
psgi blacklist middleware
my $ref_blacklist = [
qr{antronio},
];
my $refcheck = sub {
my $app = shift;
sub {
my $env = shift;
for (@$ref_blacklist) {
return [401, [], ['forbidden']] if $env->{HTTP_REFERER} =~ $_;
use Plack::Builder;
use Plack::App::Proxy;
my $proxy = Plack::App::Proxy->new(
remote => "http://dev.office.xerox.com",
preserve_host_header => 1,
);
builder {
mount "/" => sub {
@leedo
leedo / gist:1182198
Created August 30, 2011 21:58
make links clickable
makeLinksClickable: function(elem) {
var children = elem.childNodes;
var length = children.length;
for (var i=0; i < length; i++) {
var node = children[i];
if (node.nodeName == "#text" && node.nodeValue.match(Alice.RE.url)) {
var span = new Element("SPAN");
span.innerHTML = node.nodeValue.replace(
Alice.RE.url, '<a href="$1" target="_blank" rel="noreferrer">$1</a>');
@leedo
leedo / app.pl
Created August 6, 2011 19:17
given/when dispatch
sub call {
my ($self, $env) = @_;
given ([$env->{REQUEST_METHOD}, $env->{PATH_INFO}]) {
when ([GET => "/"]) {
return $self->index;
}
when ([POST => qr{^/track/?$}]) {
return $self->upload($env);
}
use AnyEvent::AIO;
use IO::AIO;
sub {
my $env = shift;
return sub {
my $respond = shift;
aio_open __FILE__, IO::AIO::O_RDONLY, 0, sub {
my $fh = shift;
warn $fh;
lee@hq:~$ perl sphinx-stats.pl
07-03-2011 | 1382 | 1376
07-04-2011 | 1547 | 1540
07-05-2011 | 3309 | 3300
07-06-2011 | 4073 | 4072
07-07-2011 | 4067 | 4068
07-08-2011 | 4210 | 4203
07-09-2011 | 1749 | 1744
07-10-2011 | 1365 | 1363
07-11-2011 | 620 | 3679

#Installing Alice's dependencies from the CPAN

Alice has a number of dependencies, all of which can be installed from the CPAN1. The simplest way to get these installed is with the cpanm tool.

Install cpanm by running

curl -L http://xrl.us/cpanm | perl - --sudo App::cpanminus

Check out alice's git repository