Skip to content

Instantly share code, notes, and snippets.

View jadeallenx's full-sized avatar

Jade Allen jadeallenx

View GitHub Profile
@jadeallenx
jadeallenx / todo.go
Created August 19, 2012 04:07
Solution for #83 learngo
package main
import (
"fmt"
"io/ioutil"
"strings"
"log"
)
func main() {
@jadeallenx
jadeallenx / todo.go
Created August 20, 2012 04:56
Solution for #84 learngo
package main
import (
"fmt"
"io/ioutil"
"strings"
"log"
"flag"
)
@jadeallenx
jadeallenx / t.erl
Created August 22, 2012 21:33
binary search in erlang
-module(t).
-export([chop/2]).
chop(Key, List) ->
chop(Key, List, 0).
chop(Key, List, Acc) ->
Mid = length(List) div 2,
{List1, List2} = lists:split(Mid, List),
%io:format("List1> ~p~nList2> ~p~n Mid> ~p~n Acc> ~p~n", [List1, List2, Mid, Acc]),
@jadeallenx
jadeallenx / fizzbuzz.erl
Created September 6, 2012 16:00
Fizzbuzz for Erlang
-module(fizzbuzz).
-export([t/0, t/1]).
t() ->
t(100).
t(Limit) when Limit > 0 ->
fizzbuzz(lists:seq(1, Limit));
@jadeallenx
jadeallenx / gist:3694498
Created September 10, 2012 22:41
tunes.io downloader oneliner
perl -MMojo::UserAgent -MFile::Path=make_path -C -S -E 'my $ua=Mojo::UserAgent->new; chomp(my $date=`date +%Y%m%d`); my $path=$ENV{HOME} . "/Dropbox/tunes.io/$date"; make_path( $path ); $ua->get("http://tunes.io")->res->dom->html->body->div->ul->find('a')->each( sub { say "Getting " . $_->text; $ua->max_redirects(5)->get($_->{href})->res->content->asset->move_to($path."/".$_->text().".mp3") } )'
@jadeallenx
jadeallenx / ow ith ojo
Created September 11, 2012 19:50 — forked from tempire/ow ith ojo!
tunes.io downloader oneliner
perl -C -S -MTime::Piece -Mojo -E '$i=1; mkdir $dir=$ENV{HOME}."/Dropbox/tunes.io/".localtime->ymd; say $_->text and g($_->attrs("href"))->max_message_size(25600000)->content->asset->move_to("$dir/${\$i++} ${\$_->text}.mp3") for g("tunes.io")->dom("ul a")->each'
@jadeallenx
jadeallenx / summary-test.pl
Last active December 10, 2015 15:19
Playing around with Text::Summarize::En
use 5.014;
use strict;
use warnings;
use Text::Summarize::En;
use Data::Dump qw(dump);
my $summarizerEn = Text::Summarize::En->new();
my $text =<<_EOF;
Ok,
there's no way to do this gracefully, so I won't even try. I'm going to
just hunker down for some really impressive extended flaming, and my
@jadeallenx
jadeallenx / base62.erl
Last active December 13, 2015 21:48
Base36 / 62 encoding for Erlang
-module(base62).
-export([encode62/1, decode/1, encode36/1]).
%% can call it as:
%%
%% base62:encode62(crypto:rand_bytes(8)).
nthchar(N) when N =< 9 -> $0 + N;
nthchar(N) when N =< 35 -> $A + N - 10;
nthchar(N) -> $a + N - 36.
@jadeallenx
jadeallenx / moox-types-demo.pl
Created March 11, 2013 16:15
MooX::Types::MooseLike::Base demo
use 5.016;
package Example {
use Moo;
use MooX::Types::MooseLike::Base qw(Int Str);
has 'foo' => ( is => 'ro', isa => Str, default => sub { 'bar' } );
has 'qux' => ( is => 'ro', isa => Int, default => sub { 123 } );
1;
@jadeallenx
jadeallenx / pool_namer.pl
Last active December 15, 2015 12:59
Generate pool stanzas for erl.config files. Use with https://github.com/dizzyd/erlang-mysql-driver
use 5.010;
my $user = 'root';
my $pass = 'pass';
my $host = '10.1.2.3';
my $port = '3306';
my %names = (
pool1 => 'db_foo',
pool2 => 'db_bar',