Skip to content

Instantly share code, notes, and snippets.

#!perl
use strict;
use warnings;
use Device::Gsm;
$| = 1;
my $modem = Device::Gsm->new(
@ksurent
ksurent / tokenizer.q
Created December 8, 2011 12:38
(Buggy) tokenizer in Qore
#!/usr/bin/env qore
%new-style
%require-types
%enable-all-warnings
namespace OpenCorpora;
class OpenCorpora::Tokenizer {
private {
@ksurent
ksurent / pcap-viewer
Created March 5, 2012 20:32
Simple PCAP viewer
#!/usr/bin/env perl
use v5.14;
use UUID::Tiny;
use Mojolicious::Lite;
use Net::Frame::Simple;
use Net::Frame::Dump::Offline;
BEGIN {
@ksurent
ksurent / bf.pl
Last active June 15, 2016 15:58
Optimizing Brainfuck to Perl translator
#!/usr/bin/env perl
use v5.14;
#chomp(my $input = <STDIN>);
# Hello World!\n
#my $input = '++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.';
# Hello World!
@ksurent
ksurent / ae-http-aio.pl
Created January 23, 2013 10:14
AE::HTTP + AE::AIO combo
#!/usr/bin/env perl
use v5.14;
use List::Util qw(shuffle);
use Parse::CPAN::Packages::Fast;
use List::MoreUtils qw(uniq any);
use AE;
use IO::AIO;
@ksurent
ksurent / bucketise.go
Last active July 8, 2020 01:07
Distribute elements across given number of buckets (evenly and based on weights)
package main
import (
"encoding/csv"
"fmt"
"math/rand"
"os"
"strconv"
)
@ksurent
ksurent / ntp-packet-decoder.pl
Last active November 26, 2015 09:21
Silly ntpd packet decoder for my study group
#!/usr/local/bin/perl
use v5.14;
use warnings;
use IO::Socket 1.18;
use Digest::MD5 qw(md5 md5_hex);
use Time::HiRes qw(time);
# epoch = January 1, 1900
@ksurent
ksurent / moose-role-delegation.pl
Created June 15, 2016 14:54
A simple example of using Moose's ability to automagically install delegation by introspecting roles
package Role;
use Moose::Role;
requires "delegated_method";
has provided_attribute => (
is => "ro",
isa => "Str",
lazy => 1,
builder => "_build_provided_attribute",
);
use v5.14; [6/1836]
use warnings;
use IO::Socket;
use POSIX qw(:sys_wait_h);
my($ip, $host) = @ARGV;
my $sock = IO::Socket::INET->new(
PeerAddr => "$ip:80",
@ksurent
ksurent / strace.go
Last active February 2, 2020 22:36
A toy strace clone for my p2p study group
package main
// heavily inspired by https://blog.nelhage.com/2010/08/write-yourself-an-strace-in-70-lines-of-code/
import (
"errors"
"fmt"
"log"
"os"
"strconv"