Skip to content

Instantly share code, notes, and snippets.

View base58.pl
use 5.016;
use Encode::Base58::GMP;
use Data::UUID;
# '11115QchsAWLTKggVhJEd'
# '00000000-ffff-ffff-0000-000000000000'
# 55b1a44d-e22b-4cf1-9c89-486d20c06adc
# 4da4b155 2be2 f14c 9c89 486d20c06adc
View http-request-read.pl
sub listener {
push_read(line => sub {
my $line = shift; # GET / HTTP/1.1
# PUT /file HTTP/1.1
my ($method, $path, $http) = $line =~ m{^(\S+)\s+(\S+)};
# Key: value
# Conetent-Length: 10
#
# body...
View sort.pl
#!/usr/bin/env perl
use 5.016;
use integer;
my $n = <>;
local $/ = " ";
$, = " ";
my @bottom;
while (<>) {
View keybase.md

Keybase proof

I hereby claim:

  • I am mons on github.
  • I am mons (https://keybase.io/mons) on keybase.
  • I have a public key ASC3bELAJoi7ctVU4P64sjft5udPls8hIk5rVfrxSEUHyQo

To claim this, I am signing this object:

View ffi-open.lua
local ffi = require 'ffi'
ffi.cdef[[
typedef int mode_t;
char *strerror(int errnum);
int open(const char *pathname, int flags);
int open(const char *pathname, int flags, mode_t mode);
ssize_t write(int fd, const char *buf, size_t count);
]]
@Mons
Mons / anyevent-scribe-server.pl
Created Jul 21, 2017
Simple debugging scribe server in perl
View anyevent-scribe-server.pl
#!/usr/bin/env perl
use 5.010;
use strict;
use DDP;
use Data::Dumper;
# use Thrift;
# use Scribe::Thrift::scribe;
use Thrift::XS::MemoryBuffer;
use Thrift::XS::BinaryProtocol;
@Mons
Mons / nginx-proxy-100-continue.patch
Created Jul 19, 2017
Disable local 100 continue response, proxy it from upstream
View nginx-proxy-100-continue.patch
diff -r -u nginx-1.10.3.orig/src/http/ngx_http_core_module.c nginx-1.10.3/src/http/ngx_http_core_module.c
--- nginx-1.10.3.orig/src/http/ngx_http_core_module.c 2017-01-31 18:01:11.000000000 +0300
+++ nginx-1.10.3/src/http/ngx_http_core_module.c 2017-02-13 15:37:11.505036520 +0300
@@ -626,6 +626,13 @@
offsetof(ngx_http_core_loc_conf_t, etag),
NULL },
+ { ngx_string("proxy_100_continue"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
+ ngx_conf_set_flag_slot,
View crawler-ex.pl
sub run {
my $url = shift;
my $cb = shift;
my @queue;
push @queue, $start_url;
my %seen;
my $cv = AE::cv; $cv->begin;
View strbench.pl
package Local::Metric;
use 5.010;
use strict;
use warnings;
# 1 2 3 4 5 6 7 8 9 10 11
our @fields = qw{foo bar foobar baz quux bat xyzzy plugh qwe asd zxc};
sub new {
return { map { $_ => "".rand(100) } @fields };
View aehandlewrap.pm
use AnyEvent::Handle;
BEGIN {
my $push_write = \&AnyEvent::Handle::push_write;
*AnyEvent::Handle::push_write = sub {
if (@_ > 2) {
goto &$push_write;
} else {
if(utf8::is_utf8 $_[1]) {
@_ = (@_);
$_[1] = "$_[1]";