Skip to content

Instantly share code, notes, and snippets.

View justbuchanan's full-sized avatar

Justin Buchanan justbuchanan

View GitHub Profile
@justbuchanan
justbuchanan / sources.list
Created September 16, 2015 20:21
/etc/apt/sources.list from an Ubuntu 14.04 installation
#deb cdrom:[Ubuntu 14.04.3 LTS _Trusty Tahr_ - Beta amd64 (20150805)]/ trusty main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ trusty main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
@justbuchanan
justbuchanan / ParameterByValueVsByRef.md
Last active May 26, 2022 20:26
Performance test of passing a small struct by value vs by reference in C++

Comparison of passing a small struct by value vs by reference in C++

Below are the results from running this on my 2011 MacBook Pro with an Intel Core i7-2635QM CPU @ 2.00GHz.

With no compiler optimizations turned on:

$ make compare
time ./by-ref
 7.07 real 7.05 user 0.00 sys
@justbuchanan
justbuchanan / readme.md
Last active March 1, 2021 17:21
Show icons for open programs in i3's status bar. See a demo here: http://gfycat.com/AfraidAmusingCoyote
@justbuchanan
justbuchanan / i3style2xresources.py
Last active February 22, 2021 01:18
Convert i3-style themes to xresources format
#!/usr/bin/env python3
import yaml
import sys
from collections import OrderedDict
"""
This script converts i3-style themes into xresources format.
i3-style can be found here: https://github.com/acrisci/i3-style.
@justbuchanan
justbuchanan / tree.py
Created November 14, 2020 09:59
recursive tree-building in python
# Creates a binary tree of depth `d`. Each node is represented as a python `dict`,
# with the value of the key "leaf" as a boolean indicating whether or not the node is a leaf node.
def make_tree(d):
assert d > 0
if d == 1: return {"leaf": True}
else: return {"leaf": False, "left": make_tree(d-1), "right": make_tree(d-1)}
make_tree(1)
# {'leaf': True}
@justbuchanan
justbuchanan / .bazelrc
Last active October 13, 2020 19:23
Use github.com/kythe/kythe as a bazel dependency
# Ensure clang is used, by default, over any other C++ installation (e.g. gcc).
build --client_env=CC=clang
# We require C++17, but bazel defaults to C++0x (pre-C++11).
build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 --client_env=BAZEL_CXXOPTS=-std=c++17
@justbuchanan
justbuchanan / .gitignore
Last active December 4, 2018 04:26
Example of bazel analysis failure related to kythe's llvm setup
/bazel-*
@justbuchanan
justbuchanan / BUILD
Last active November 9, 2018 20:35
Example of bug with rules_go + cgo + bazel aspects. https://github.com/bazelbuild/rules_go/issues/1821
load("@io_bazel_rules_go//go:def.bzl", "go_binary")
go_binary(
name = "main",
srcs = ["main.go"],
cgo = True,
)
action_listener(
name = "my_action_listener",
@justbuchanan
justbuchanan / GTwifi
Last active March 26, 2018 12:53
Arch Linux netctl config for GTwifi at Georgia Tech
# This netctl profile is for connecting to Georgia Tech's GTwifi network
# Usage:
# 1. Copy/download it to /etc/netctl/GTwifi
# 2. Set the 'identity' and 'password' fields appropriately
# 3. Set file permissions and ownership:
# chown root:root /etc/netctl/GTwifi
# chmod 0600 /etc/netctl/GTwifi
Description='GTwifi'
Interface=wlan0
@justbuchanan
justbuchanan / trump_tax.py
Created November 10, 2017 17:33
How does your income tax compare now vs with the new GOP/Trump tax brackets?
#!/usr/bin/env python3
# data from: https://smartasset.com/taxes/heres-how-the-trump-tax-plan-could-affect-you
# note: this applies to single filers only
import matplotlib.pyplot as plt
import numpy as np
brackets_old = [
(9325.0, .1),