Skip to content

Instantly share code, notes, and snippets.

@twonds
twonds / run_ngrok.sh
Created June 9, 2020 16:13
A script to check ngrok and reset if necessary.
#!/usr/bin/env bash
#
#
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
set -xe
NGROK_DIR=${SCRIPT_DIR}/ngrok
mkdir -p $NGROK_DIR || true
NGROK_CONFIG=${NGROK_DIR}/ngrok.yml
which ngrok || brew install ngrok
@twonds
twonds / huffman.py
Last active July 12, 2019 16:57
Code that compresses data using variable length encoding: https://www.techiedelight.com/huffman-coding/
import argparse
import bisect
from collections import defaultdict
import sys
class HuffmanNode:
"""
A node class for encoding data. It provides a way to created a weighted tree
and then produced an encoded string from the tree.
@twonds
twonds / pr_template.md
Last active October 10, 2019 19:06
PR template

Summary

  • What:
  • Why:
  • Ticket:
  • Discussion:

Testing

Documentation

Demos

Checklist

  • I manually verified the change in my local environment
#!/bin/bash
PGSQL_DIR=/usr/local/pgsql
export PGDATA=${PGSQL_DIR}/data
if [ ! -e ${PGDATA}/PG_VERSION ]
then
initdb -D ${PGDATA}
fi
echo ${PGSQL_DIR}
postgres -D ${PGDATA} > ${PGSQL_DIR}/logfile 2>&1 &
echo $! > ${PGSQL_DIR}/pg.pid
@twonds
twonds / .emacs
Created October 13, 2015 04:02
save my emacs file
;;Required plugins:
;Erlang OTP, color-theme, distel, auto-complete-distel
;
;; Erlang
(setq load-path (cons "/otp/17.4/lib/tools-2.7.1/emacs" load-path))
(setq erlang-root-dir "/otp/17.4/")
(setq inhibit-splash-screen t)
(setq exec-path (cons "/otp/R15B/lib/erlang/bin" exec-path))

call the following:

api.create_dashboard(
                  title, description,
                  graphs, template_vars)

where the values are the following:

title="pubsub-bench"
-module(ets_update).
-compile(export_all).
setup() ->
ets:new(test, [public, named_table]),
ets:insert(test, {test, 0}).
lookup(N) ->
ets:lookup(test, N).
@twonds
twonds / twistd.log
Created September 18, 2014 23:10
datadog debugging events
2014-09-18 22:57:54+0000 [DispatcherFromUDPLogProtocol (UDP)] {
"category": "hullabaloo_chaos",
"node": "rte_v1_v2_test@ip-10-33-16-217",
"nodes": [
"rte_v1_v2_test@ip-10-33-16-217",
"rte_v1_v2_test@ip-10-41-64-106"
],
"result": true,
"timestamp": 1411081075,
"what": "kill_process"
@twonds
twonds / README.md
Last active January 21, 2019 11:39
Datadog stream parser for json

dd-udpstream

Parse json events into data dog events

Testing

-module(same_string).
-export([test/0,
is_re_message_the_same/2,
is_message_the_same/2]).
%% XXX - make sure this works with unicode
non_word() ->
[$\n, $\r, $\t,$!,$",$#,$$,$%,$&,$',$(,
$),$*, $+,$,, $\\, $-,