Skip to content

Instantly share code, notes, and snippets.

View sharifulin's full-sized avatar

Anatoly Sharifulin sharifulin

View GitHub Profile
@sharifulin
sharifulin / gist:117622
Created May 25, 2009 17:15
Search Twitter for Station 2.0
#!/usr/bin/perl
use utf8;
use strict;
use lib '../../lib';
use common;
use util;
use Net::Twitter;
use Storable qw(nstore retrieve);
@sharifulin
sharifulin / gist:118079
Created May 26, 2009 13:56
Script for parsing JavaScript object and generate plist
#!/usr/bin/perl
use utf8;
use strict;
BEGIN {
open STDERR, '>>', '../log/****.log';
$SIG{'__WARN__'} = sub { CORE::warn sprintf "[%s] %s", scalar localtime, @_ };
};
use lib '/path/my/lib';
@sharifulin
sharifulin / gist:118677
Created May 27, 2009 14:44
Simple parse proftpd log
#!/usr/bin/perl
use utf8;
use strict;
use lib '../../lib';
use common;
my $LOG = '/var/log/proftpd.log';
my $TMP = '/tmp/***/proftpd.tmp'; unlink $TMP if @ARGV;
my $M = {May => 5, Jun => 6, Jul => 7, Aug => 8, Sep => 9, Oct => 10, Nov => 11, Dec => 12, Jan => 1, Feb => 2, Mar => 3, Apr => 4};
@sharifulin
sharifulin / gist:126039
Created June 8, 2009 20:24
Tiny URL to long
perl -MLWP::UserAgent -e'print LWP::UserAgent->new(max_redirect => 0, timeout => 5)->get($_)->header("location")' 'http://ff.im/2OEON'
@sharifulin
sharifulin / gist:130628
Created June 16, 2009 10:11
Real Perl PHP warn
function warn($msg) { fwrite(STDERR, substr($msg, -1) == "\n" ? $msg : $msg.' at '.__FILE__.' line '.__LINE__.".\n"); }
@sharifulin
sharifulin / gist:131836
Created June 18, 2009 10:12
Parse RSS Yandex Search
#!/usr/bin/perl
use utf8;
use strict;
use lib '../../lib';
use common;
use XML::Feed;
use Storable qw(nstore retrieve);
use Data::Dumper;
@sharifulin
sharifulin / gist:135885
Created June 25, 2009 14:07
Check avatar and get from twitter
#!/usr/bin/perl
use strict;
use utf8;
use lib '../../lib';
use common;
use POE qw(Component::Client::HTTP);
use HTTP::Request::Common qw(GET);
use Data::Dumper;
@sharifulin
sharifulin / gist:139389
Created July 2, 2009 09:15
Real ucfirst for string
sub ucfirst($) {
return join ' ', map { CORE::ucfirst } split / /, lc shift;
}
@sharifulin
sharifulin / gist:180393
Created September 3, 2009 16:45
Twitter Stream API + HTTPD
use strict;
use utf8;
use JSON;
use Encode ();
use AnyEvent::HTTPD;
use AnyEvent::Twitter::Stream;
use constant L => 30;
@sharifulin
sharifulin / Simple POE server
Created September 27, 2009 07:52
Simple POE server
#!/usr/bin/perl
use strict;
use POE qw(Component::Server::SimpleHTTP XS::Queue::Array Loop::IO_Poll);
POE::Component::Server::SimpleHTTP->new(ALIAS => 'HTTPD', PORT => 8010, HANDLERS => [{ DIR => '/', SESSION => 'MANAGER', EVENT => 'req' }]);
POE::Session->create(inline_states => {
_start => sub { $_[KERNEL]->alias_set('MANAGER') },
req => sub {
for ($_[ARG1]) {
$_->code(200);