Skip to content

Instantly share code, notes, and snippets.

View zachwhaley's full-sized avatar
🐳
Hi!

Zachary Whaley zachwhaley

🐳
Hi!
View GitHub Profile

Code Review Workflow

Start Your Work

Before starting any work, create a new branch off of the base branch your changes will be submitted to.

E.g. if you are working on a bug, your base branch would be main; if you are working on a feature, your base branch would be that feature's branch.

It is good practice to give the branch a name that is relevant to the work being done.

@zachwhaley
zachwhaley / zachwhaley:ignore-tf-datadir
Last active June 5, 2020 18:58
Terragrunt: Ignore Terraform data directories when running *-all commands https://github.com/gruntwork-io/terragrunt/pull/1208
=== RUN TestTerragruntConfigAsCtyDrift
--- PASS: TestTerragruntConfigAsCtyDrift (0.00s)
=== RUN TestRemoteStateAsCtyDrift
--- PASS: TestRemoteStateAsCtyDrift (0.00s)
=== RUN TestTerraformConfigAsCtyDrift
--- PASS: TestTerraformConfigAsCtyDrift (0.00s)
=== RUN TestPathRelativeToInclude
=== PAUSE TestPathRelativeToInclude
=== RUN TestPathRelativeFromInclude
=== PAUSE TestPathRelativeFromInclude
@zachwhaley
zachwhaley / page.cpp
Last active July 31, 2018 21:33
Dumb pager program
#include <sys/ioctl.h>
#include <unistd.h>
#include <termios.h>
#include <iostream>
#include <fstream>
#include <string>
#include <cstdio>
int main(int argc, char* argv[])
@zachwhaley
zachwhaley / quicksort.cpp
Last active March 13, 2024 09:06
C++ quicksort with iterators
#include <algorithm>
#include <iostream>
#include <list>
template<typename Iter>
void print(const Iter& beg, const Iter& end)
{
std::for_each(beg, end, [](auto& i) { std::cout << i << " "; });
std::cout << std::endl;
}
@zachwhaley
zachwhaley / mergesort.cpp
Last active March 13, 2024 09:07
C++ mergesort with iterators
#include <algorithm>
#include <iostream>
#include <list>
#include <vector>
template<typename Iter>
void print(const Iter& beg, const Iter& end, bool new_line = true)
{
std::for_each(beg, end, [](auto& i) { std::cout << i << " "; });
if (new_line) {
@zachwhaley
zachwhaley / rcv.py
Last active October 3, 2017 21:44
Ranked Choice Voting script
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import json
def tally(voters):
results = {}
for votes in voters.itervalues():
if votes:
@zachwhaley
zachwhaley / bears.py
Created February 19, 2015 13:21
Pair mating bears and avoid common ancestors
import sys
import re
class Bear:
def __init__(self, attrs):
self.parents = []
self.name = attrs[0]
if len(attrs) > 1:
self.sex = attrs[1]
self.parents = attrs[2:4]
@zachwhaley
zachwhaley / mktags
Last active February 1, 2017 17:22
Make cscope C/C++ tags
#!/usr/bin/env bash
[[ $# -eq 1 ]] && cd $1
find `pwd` -name "*.[ch]" -o -name "*.[ch]pp" -o -name "*.cc" -o -name "*.hh" > cscope.files
cscope -b -q -u
cat cscope.files | xargs ctags
@zachwhaley
zachwhaley / p4_completion.sh
Created April 1, 2014 15:41
perforce bash completion
#!/bin/bash
function _p4()
{
local cmds='add annotate attribute branch branches change changes changelist changelists client clients copy
counter counters cstat delete depot depots describe diff diff2 dirs edit filelog files fix fixes flush fstat grep
group groups have help info integrate integrated interchanges istat job jobs key keys label labels labelsync list
lock logger login logout merge move open opened passwd populate print protect protects reconcile rename reopen
resolve resolved revert review reviews set shelve status sizes stream streams submit sync tag tickets unlock
unshelve update user users where workspace workspaces'
@zachwhaley
zachwhaley / slurp.cpp
Last active July 12, 2016 01:09
File slurping, C++ stye
std::string slurp(const std::string& filename)
{
// Open the file into an input file stream
std::ifstream ifile(filename, std::ios::in | std::ios::binary | std::ios::ate);
// Check that the file exists
if (ifile) {
std::string str;
// Move to the end of the file
ifile.seekg(0, std::ios::end);