Skip to content

Instantly share code, notes, and snippets.

View jzawodn's full-sized avatar

Jeremy Zawodny jzawodn

View GitHub Profile
#!/usr/bin/perl -w
use strict;
use Event::Lib;
use Data::Dumper;
use MysqlAsync;
use AsyncCaller qw/schedule/;
$Data::Dumper::Terse = 1;
#!/bin/bash
FAIL=0
echo "starting"
./sleeper 2 0 &
./sleeper 2 1 &
./sleeper 3 0 &
./sleeper 2 0 &
@jzawodn
jzawodn / wait.sh
Created November 21, 2008 15:13
how to wait on multiple background processes and check exit status in bash
#!/bin/bash
FAIL=0
echo "starting"
./sleeper 2 0 &
./sleeper 2 1 &
./sleeper 3 0 &
./sleeper 2 0 &
@jzawodn
jzawodn / sleeper
Created November 21, 2008 15:16
sample code used with wait.sh
#!/usr/bin/perl -w
use strict;
my $time = $ARGV[0] || 1;
my $exit = $ARGV[1] || 0;
sleep $time;
exit $exit;
#!/bin/bash
T_USER=twitter_username
T_PASS=twitter_password
T_URL=http://twitter.com/statuses/update.xml
cd $HOME
LAST_IP=`cat .last_ip`
IP=`curl -s -o - http://jeremy.zawodny.com/ip.php`
<? echo $_SERVER['REMOTE_ADDR'] ?>
#!/usr/bin/perl -w
$|++;
use strict;
use Redis;
my $r = Redis->new(server => 'localhost:63790') or die "$!";
for my $key (1..100_000_000) {
my $val = int(rand($key));
#!/usr/bin/perl -w
$|++;
use strict;
use lib 'perl-Redis/lib';
use Redis;
my $r = Redis->new(server => 'localhost:63790') or die "$!";
## 2.5B values
@jzawodn
jzawodn / ae_redis_get.pl
Created October 29, 2010 17:05
AnyEvent Perl GET loop. No memory leak.
#!/usr/bin/perl -w
$|=1;
use strict;
use lib '/home/jzawodn/code/AnyEvent-Redis/lib';
use AnyEvent::Redis;
my $host = 'localhost';
my $port = 6379;
my $key = 'foo';
@jzawodn
jzawodn / ae_redis_blpop.pl
Created October 29, 2010 17:06
AnyEvent Perl BLPOP loop. Has memory leak.
#!/usr/bin/perl -w
$|=1;
use strict;
use lib '/home/jzawodn/code/AnyEvent-Redis/lib';
use AnyEvent::Redis;
my $host = 'localhost';
my $port = 6379;
my @chan = 'a'..'z'; # which queues/channels to check
my $command_timeout = 1; # how long to wait for a response