Skip to content

Instantly share code, notes, and snippets.

var not_oquno = Array.filter(window.$("#following_list img"),function(img){return!/oquno/.test(img.src)});
setInterval(function(){
if (not_oquno.length == 0) return;
var i=Math.floor(Math.random()* not_oquno.length);
not_oquno[i].src="http://a3.twimg.com/profile_images/256862425/oquno-c_mini.png";
not_oquno.splice(i, 1);
}, 1000);
#!/usr/bin/perl
# http://todeskin.g.hatena.ne.jp/eigokun/20090902/1251903150
# TODO: cache LWP response
use strict;
use URI;
use JSON;
use LWP::UserAgent;
use Web::Scraper;
use lib qw(../lib);
use Plack::Loader;
Plack::Loader->load("AnyEvent", port => 8888, host => "127.0.0.1")->run(\&handler);
sub handler {
my ( $env, $start_response ) = @_;
unless ($env->{psgi.async}) {
return [200, [], "Not Supported."]
use AnyEvent;
my $cv = AE::cv;
my $count = 0;
my $timer;
$timer = AE::timer 0, 0.1, sub {
$count++;
$cv->send("hoge" . $count);
package Plack::Middleware::AsyncSupport;
use strict;
use warnings;
use base qw/Plack::Middleware/;
our $USE_CORO = 1;
use Coro;
use Coro::Channel;
use IO::Handle::Util qw(io_from_getline);
/*
// mxhr.js
// BSD license
var mxhr = new MXHR;
mxhr.listen(mime, function(body){ process(body) });
mxhr.listen('complete', function(status_code){ ... }); // 2xx response
mxhr.listen('error', function(status_code){ ... }); // other case
mxhr.open("GET", url, true); // or mxhr.open("POST", url, true);
mxhr.send("");
@mala
mala / background.html
Created March 10, 2010 11:49
presen to jpg extension
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript">
chrome.browserAction.onClicked.addListener(function(tab){
capture();
});
--- ares_init.c.old 2010-04-23 11:46:56.000000000 +0900
+++ ares_init.c 2010-04-23 12:19:06.000000000 +0900
@@ -831,12 +831,16 @@
FILE *fp;
size_t linesize;
int error;
+ const char *path_resolv_conf = getenv("ARES_PATH_RESOLV_CONF");
+ if (!path_resolv_conf) {
+ path_resolv_conf = PATH_RESOLV_CONF;
+ }
#!/usr/bin/perl
use strict;
use Benchmark qw(:all);
use Data::Dumper;
use HTTP::Response;
use HTTP::Headers::Fast;
{
package HTTP::Headers::Fast;
my %CACHE;
@mala
mala / memcachedos.pl
Created August 13, 2010 11:49
DoS for memcached
#!/usr/local/bin/perl
# DoS tool for memcached
# ulimit -n 15000; perl memcachedos.pl 127.0.0.1 11211 3
# original: http://gist.github.com/522741
# This is Public Domain Software
use strict;
use warnings;
use AnyEvent;