Skip to content

Instantly share code, notes, and snippets.


John Beppu beppu

View GitHub Profile
View t3.json
"created_at": "Mon Jan 01 16:02:46 +0000 2018",
"id": 947860662130110500,
"id_str": "947860662130110464",
"text": "Coin of the week;",
"display_text_range": [
"source": "<a href=\"\" rel=\"nofollow\">Twitter Web Client</a>",
View bot-output.txt
Tue Dec 26 13:59:51 +0000 2017 | officialmcafee 961445378 | Coin Of The Day:
[ 'Coin Of The Day: https',
index: 0,
input: 'Coin Of The Day:' ]
COIN OF THE DAY! Coin Of The Day: { found: false,
reason: 'Couldn\'t find https in currencies list.' }
{ found: false,
reason: 'Couldn\'t find https in currencies list.' }
View bot-output.txt
Mon Dec 25 13:59:59 +0000 2017 | officialmcafee 961445378 | Coin of the day: Humaniq (HMQ). In the spirit of Christmas, there is no better coin. Their mission is true to the v…
[ 'Coin of the day: Humaniq ',
'Humaniq ',
index: 0,
input: 'Coin of the day: Humaniq (HMQ). In the spirit of Christmas, there is no better coin. Their mission is true to the v…' ]
COIN OF THE DAY! Coin of the day: Humaniq (HMQ). In the spirit of Christmas, there is no better coin. Their mission is true to the v… { found: true, symbol: 'HMQ', name: 'Humaniq' }
attempting to buy HMQ
{ success: true,
message: '',
View session.txt
$ bin/repl
> bot.btcSpend
> bot.btcSpend = 0.25
> bot.adjustment = 0.05
> bot.init()
Promise {
beppu / FileSaver.min.js
Last active Dec 8, 2016
Using FileSaver
View FileSaver.min.js
/*! @source */
var saveAs=saveAs||function(e){"use strict";if(typeof e==="undefined"||typeof navigator!=="undefined"&&/MSIE [1-9]\./.test(navigator.userAgent)){return}var t=e.document,n=function(){return e.URL||e.webkitURL||e},r=t.createElementNS("","a"),o="download"in r,a=function(e){var t=new MouseEvent("click");e.dispatchEvent(t)},i=/constructor/i.test(e.HTMLElement)||e.safari,f=/CriOS\/[\d]+/.test(navigator.userAgent),u=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},s="application/octet-stream",d=1e3*40,c=function(e){var t=function(){if(typeof e==="string"){n().revokeObjectURL(e)}else{e.remove()}};setTimeout(t,d)},l=function(e,t,n){t=[].concat(t);var r=t.length;while(r--){var o=e["on"+t[r]];if(typeof o==="function"){try{,n||e)}catch(a){u(a)}}}},p=function(e){if(/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)){return new Blob([String.fromChar

Building Realtime Analytics Systems

Finding a solution

(Initially you might think…) Load all your data into Hadoop. Query it. Done

MapReduce/Hadoop has problems. It can be slow.

Not optimized for query latency

Need to introduce a query layer to make queries faster.

Making Queries Faster

What types of queries to optimize for?

View cold-timestamp
#!/usr/bin/env perl
use strict;
use warnings;
use JSON;
while (<>) {
my $relay = decode_json $_;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(int($relay->{coldTimestamp} / 1000));
my $date = sprintf('%d-%02d-%02d', $year+1900, $mon+1, $mday);
print "$date $_"
beppu / shell
Created Jul 4, 2015
an example of how to control a subprocess and communicate with it through stdin/stdout/stderr
View shell
#!/usr/bin/env perl
use strict;
use warnings;
use IPC::Open3;
use IO::Select;
use Symbol qw(gensym);
use POSIX qw(:sys_wait_h);
# Read as much as possible from a file handle and return the result.
beppu /
Created Apr 21, 2015
my most recent take on taming EventEmitter
events = require \events
EventEmitter = events.EventEmitter
P = require \bluebird
fifo = require \./app/shared/fifo
q = fifo.make!
ee = new EventEmitter
chain = P.resolve(true)
set-timeout (-> ee.emit \error, { +aaaa }), 500ms
beppu / random-replace
Created Feb 27, 2015
for educational purposes
View random-replace
use strict;
use warnings;
sub slurp {
my $file = shift;
open my $fh, '<', $file or die;
my @lines = <$fh>;
close $fh;
You can’t perform that action at this time.