Skip to content

Instantly share code, notes, and snippets.

View bunker-inspector's full-sized avatar

Ted Kassen bunker-inspector

View GitHub Profile

Keybase proof

I hereby claim:

  • I am bunker-inspector on github.
  • I am tedgkassen (https://keybase.io/tedgkassen) on keybase.
  • I have a public key ASDcAhBl8Wj7lkmSzvm9A4aWL3xvVfVKbRNisLRKduI-ygo

To claim this, I am signing this object:

@bunker-inspector
bunker-inspector / secrethitler.go
Created December 2, 2019 00:02
Slackbot functions I wrote at Streamlabs for setting up games of "Secret Hitler" since we could never do it correctly.
package mugman
import (
"bytes"
"fmt"
slackbot "github.com/BeepBoopHQ/go-slackbot"
"github.com/nlopes/slack"
"math/rand"
"strings"
"time"
@bunker-inspector
bunker-inspector / twitter_auth.go
Created November 3, 2019 23:44
Simple Twitter API Auth
package twitter
import (
"github.com/BurntSushi/toml"
"os"
"fmt"
"sync"
"bufio"
"net/http"
"io/ioutil"
@bunker-inspector
bunker-inspector / blotmap.py
Created October 9, 2019 17:48
Creates bitmaps of simple simulated blots of ink
import sys
import imageio
from datetime import datetime
def gen_map(blots, rows, cols, normal):
grid = [[255] * cols for _ in range(rows)]
def blot_and_bleed(blot, grid, rows, cols, normal):
row,col,dark = blot
class Trie:
def __init__(self):
self.prefix_tree = {}
def add(self, new_word):
curr_pfxs = self.prefix_tree
for char in new_word:
if char not in curr_pfxs:
curr_pfxs[char] = {}
@bunker-inspector
bunker-inspector / merge_sorted_linked_lists.clj
Created July 17, 2019 05:32
Leetcode Problem for Merging Sorted Linked Lists
(def input '((1 4 5 9 9 9 9 9 9)
(1 3 4 12 13)
(2 6)
(58)))
(defn- list->indexed-map
[ls]
(->> ls
(map-indexed (fn [idx ls*] [idx ls*]))
(into {})))
@bunker-inspector
bunker-inspector / ecto_json_encoder.ex
Last active December 21, 2018 21:35
Helper module for more ergonomic ecto model json encoding
defmodule EctoEncoder do
def encode(struct, opts \\ []) do
struct
|> Map.from_struct
|> (fn x -> if opts[:take] !== nil, do: Map.take(x, opts[:take]), else: x end).()
|> Map.drop([:__meta__|(opts[:drop] || [])])
|> Enum.reduce(%{}, fn
{_, %Ecto.Association.NotLoaded{}}, acc -> acc
{key, value}, acc -> Map.put(acc, key, value)
end)