Skip to content

Instantly share code, notes, and snippets.

View jadeallenx's full-sized avatar

Jade Allen jadeallenx

View GitHub Profile
# coding=UTF-8
from __future__ import division
import re
# This is a naive text summarization algorithm
# Created by Shlomi Babluki
# April, 2013
class SummaryTool(object):
@jadeallenx
jadeallenx / permute.pl
Created May 3, 2013 16:59
Unzip, permute second list, rezip
#! perl
use List::Util qw(shuffle);
use Data::Dumper;
my @input = ( [ 'a', 1 ], [ 'b', 1 ], [ 'c', 2 ], [ 'd', 2 ] );
my @element_1s = map { $_->[0] } @input;
my @element_2s = map { $_->[1] } @input;
@jadeallenx
jadeallenx / kippt_import.pl
Created May 15, 2013 05:45
This is my silly little importer for clipboard.com exports. You will need a recent Perl ( >= 5.14 ) and updated HTTP::Tiny, IO::Socket::SSL and Path::Tiny CPAN modules. Get your clipboard.com export file, unzip it somewhere convenient (mkdir /tmp/cbexport; unzip {{UUID}}.zip; ./kippt-import.pl)
#!/usr/bin/env perl -C
# My ghetto clipboard.com clip importer for kippt.
#
# cpanm HTTP::Tiny IO::Socket::SSL Path::Tiny
use 5.014;
use Path::Tiny;
use HTTP::Tiny;
use JSON::PP;
@jadeallenx
jadeallenx / unicode_password.pl
Created June 3, 2013 03:40
My voice is my passport. Verify me.
#!/usr/bin/env perl
use 5.018;
use charnames ();
binmode(STDOUT, ":utf8");
my $upper_prefix = "CIRCLED LATIN CAPITAL LETTER";
my $lower_prefix = "CIRCLED LATIN SMALL LETTER";
@jadeallenx
jadeallenx / riemann.erl
Last active December 18, 2015 17:09
Calculate a Riemann approximation
-module(riemann).
-export([riemann/2]).
riemann(Function, Delta) when is_function(Function) andalso is_float(Delta) ->
I = fun(X) -> Function(X) * Delta end,
R = fun(X1, Acc) -> I(X1) + Acc end,
fun(A, B) -> lists:foldl(R, 0, seq_float(A, B, Delta)) end.
% https://gist.github.com/andruby/241489
@jadeallenx
jadeallenx / complex.pl
Created July 5, 2013 16:18
Perl complex data structures example
use 5.010;
use warnings;
use strict;
use Data::Dumper;
# If you have access to CPAN, check out Data::Printer
# https://metacpan.org/module/Data::Printer
## build a list of hashes
22> A1 = hashtree:compute(hashtree:generate(hashtree:test()), []). 
[<<229,160,31,238,20,224,237,92,72,113,79,34,24,15,37,173,
   131,101,181,63,151,121,247,157,196,163,215,233,...>>,
 <<191,254,11,52,219,161,107,198,250,193,124,8,186,197,93,
   103,108,222,213,164,173,228,31,226,201,146,74,...>>,
 <<63,121,187,123,67,91,5,50,22,81,218,239,211,116,205,
   198,129,220,6,250,166,94,55,78,56,51,...>>]
25> A2 = hashtree:compute(A1, []).
[<<20,237,229,232,233,122,217,55,35,39,114,143,80,153,185,
@jadeallenx
jadeallenx / grabthar.erl
Created December 11, 2013 05:56
Aggregator prototype
% By Grabthar's Hammer you will be avenged.
-module(grabthar).
-export([start_link/3]).
-record(state, {
customer_id,
timer,
threshold,
current = 1,
use strict;
use warnings;
{
package JSON::ObjectFactory;
use Carp;
use Class::Tiny { json => sub { 'JSON::PP'->new } };
use Import::Into;
use JSON::PP ();
@jadeallenx
jadeallenx / json_bench.pl
Created June 23, 2014 02:02
Do some primitive benchmarking on JSON serialization.
#!/usr/bin/env perl
use strict;
use warnings;
use Benchmark qw(:all);
use Data::Random::Structure;
use Data::Dumper;
use JSON::PP ();
use JSON::XS ();