Skip to content

Instantly share code, notes, and snippets.

Leland Batey lelandbatey

Block or report user

Report or block lelandbatey

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lelandbatey
lelandbatey / held_up.py
Created Feb 15, 2020
Show what cards you could be holding up in MTGA
View held_up.py
import json
'''
Show the cards you could be holding up in MTGA at instant speed.
TODOs:
1. Make it color sensitive
2. Account for cards with flash
3. Make a UI (like at ALL)
'''
@lelandbatey
lelandbatey / collection_access_tracker.py
Created Feb 5, 2020
Python class for tracking access to members of collections. Great for legacy code were we wonder "what's being accessed in this big dict and where is it being accessed?"
View collection_access_tracker.py
from __future__ import print_function
import inspect
import six
def fmt_stack(frames):
s = ""
for f in frames[::-1]:
s += "{}:{}: {}\n".format(f[1], f[2], '\\n'.join([x.replace('\n', '') for x in f[4]]))
return s
@lelandbatey
lelandbatey / histogram_timestamps.py
Last active Nov 9, 2019
A tool for viewing streams of timestamps as histograms. Uses Matplotlib and Pandas
View histogram_timestamps.py
#!/usr/bin/env python3
'''
A tool for viewing streams of timestamps as histograms.
'''
import matplotlib.pyplot as plt
from datetime import datetime
import matplotlib.dates as mdates
import pandas as pd
import itertools
import argparse
@lelandbatey
lelandbatey / load_arena_cards.py
Created Oct 15, 2019
Read and process MTGA log events
View load_arena_cards.py
import json
def arena_card_db():
carddb = dict()
with open("AllCards.json", 'r') as mtgjsonf:
carddb = json.load(mtgjsonf)
arena_cards = list()
for card_name, card in carddb.items():
@lelandbatey
lelandbatey / sane_text_formatter.go
Created Oct 1, 2019
Sane text formatter. Formats text in a 'nice' way, though very basic.
View sane_text_formatter.go
package main
import (
"bufio"
"bytes"
"fmt"
"io"
"io/ioutil"
"os"
"strings"
@lelandbatey
lelandbatey / json_schema_stats
Last active Jul 12, 2019
A tool for examining statistics about JSON object structures. A great way to examine documents in a MongoDB collection for consistency.
View json_schema_stats
#! /usr/bin/env python3
# Downloaded from here: https://gist.github.com/lelandbatey/64e7c7d3d86b4a1b455a93f593562d68
from collections import Sequence
from operator import itemgetter
from codecs import escape_encode
import argparse
import json
import math
import sys
@lelandbatey
lelandbatey / treeify.py
Created May 23, 2019
Turn an indented block of text into a 'tree' view with unicode lines
View treeify.py
#!/usr/bin/env python3
'''
Treeify takes a file (on stdin or passed as the first argument) and converts
it's indentation into a 'tree' representation. As an example:
what
is
this
thing
that's
@lelandbatey
lelandbatey / assign_struct_field_by_tag_name.go
Last active Apr 29, 2019
Golang reflection; assign to struct field by tag name
View assign_struct_field_by_tag_name.go
package main
import (
"fmt"
"reflect"
"strings"
)
// The goal: allow assignment to a go struct field based on the name that field
// is tagged with (specifically it's json-tagged name).
@lelandbatey
lelandbatey / mexican-tomato-rice-and-beans.md
Created Mar 16, 2019
A recipe for spanish-style rice with tomato, rice, and beans
View mexican-tomato-rice-and-beans.md
@lelandbatey
lelandbatey / index.html
Created Mar 11, 2019
A demonstration of the importance of correct RGB color interpolation
View index.html
<!DOCTYPE html>
<html lang="en">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.11/lodash.min.js"></script>
<body style="margin: 0;">
<div>
<canvas id='canvas1' width='800' height='200'></canvas>
</div>
<div>
You can’t perform that action at this time.