Skip to content

Instantly share code, notes, and snippets.

use strict;
use warnings;
use utf8;
package Weather;
use DateTime;
use Web::Scraper;
use URI;
our $AREA = {
use strict;
use warnings;
main(@ARGV);exit;
sub main {
my $path = shift or help();
my $title = shift or help();
my $dir = "$path/$title";
use strict;
use warnings;
use AE;
use AnyEvent::HTTP;
use Twiggy::Server;
use Plack::Request;
use Plack::Session;
use Plack::Builder;
use strict;
use warnings;
use Plack::Request;
use Plack::MIME;
use Plack::App::Directory;
use FindBin;
my $java_bin = `which java` =~ s/[\n\r]//gr
or die 'Install Java :(';
use strict;
use warnings;
# fork of https://github.com/klange/nyancat
package Nyancat;
use Time::HiRes 'sleep';
local $SIG{INT} = sub {
print "\033[?25h\033[0m";
@punytan
punytan / feeds.sql
Created October 23, 2011 22:57
Post Your Blog Post About #yapcasia 2011
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE posts (
url TEXT UNIQUE,
title TEXT NOT NULL,
time INT NOT NULL
);
INSERT INTO "posts" VALUES('http://mt.endeworks.jp/d-6/2011/10/yapcasia-tokyo-2011-1.html',' YAPC::Asia Tokyo 2011 1日目・・・ - D-6 [相変わらず根無し] ',1318714947);
INSERT INTO "posts" VALUES('http://d.hatena.ne.jp/punitan/20111016/1318722529','YAPC::Asia 2011 に行ってきた - punitan (a.k.a. punytan) のメモ',1318722554);
INSERT INTO "posts" VALUES('http://mt.endeworks.jp/d-6/2011/10/yapcasia-tokyo-2011-backend-apps.html',' YAPC::Asia Tokyo 2011のシステム - D-6 [相変わらず根無し] ',1318723098);
Benchmark for decode/encode large data structure
$ perl benchmark/deserialize.pl
-- deserialize
JSON::XS: 2.3
Data::MessagePack: 0.34
Storable: 2.29
Benchmark: running json, mp, storable for at least 1 CPU seconds...
json: 1 wallclock secs ( 1.03 usr + 0.00 sys = 1.03 CPU) @ 77544.66/s (n=79871)
mp: 1 wallclock secs ( 1.03 usr + 0.00 sys = 1.03 CPU) @ 98247.57/s (n=101195)
storable: 1 wallclock secs ( 1.09 usr + 0.00 sys = 1.09 CPU) @ 71739.45/s (n=78196)
Rate storable json mp
#!/usr/bin/env perl
use strict;
use warnings;
use Benchmark;
use JSON;
use LWP::UserAgent;
use Storable;
use MIME::Base64;
#!perl -w
use common::sense;
use AnyEvent;
use Data::Dumper;
sub sleep_sort {
my @args = @_;
my @output;