Skip to content

Instantly share code, notes, and snippets.

View aviolette's full-sized avatar

Andrew Violette aviolette

View GitHub Profile
@aviolette
aviolette / chicagorestaurants.md
Last active June 11, 2023 17:33
Chicago Restaurants

Chicago-area Restaurants/Bars I'd Recommend

2013/03/20

Wicker Park

  • Taxim - Greek
  • Cumin - Indian
  • Piece - Pizza
  • Antique Taco - Tacos
  • Neon Wilderness - drinks
@aviolette
aviolette / timed.py
Last active June 25, 2020 13:26
timer wrapper
def timed(logger):
def timed_inner(func):
@wraps(func)
def with_timing(*args, **kwargs):
start_time = datetime.now()
logger.debug(f"Executing {func.__name__}")
result = func(*args, **kwargs)
end_time = datetime.now()
td = end_time - start_time
@aviolette
aviolette / invoke.sh
Last active January 11, 2020 17:01
Invokes a lambda function by name and takes the JSON file as an argument
#!/bin/sh
#
# usage: invoke.sh <method name> <input file>
#
tmpfile=$(mktemp /tmp/invoke.XXXXXX)
foo=$(jq -c -M . $2)
aws lambda invoke --function-name $1 --payload $(printf "%s" $foo) $tmpfile 1>&2
cat $tmpfile
rm $tmpfile
@aviolette
aviolette / awsinstances.txt
Created September 27, 2019 20:45
List aws instances
aws ec2 describe-instances --filters "Name=tag-key,Values=Name" --query 'Reservations[*].Instances[*].{Instance:InstanceId,Instance:PrivateIpAddress,AZ:Placement.AvailabilityZone,Name:Tags[?Key==`Name`]|[0].Value}' --output table
public abstract class BaseObject
{
public override int GetHashCode()
{
return SignificantAttributes()
.Aggregate(17, (current, obj) => current + (13 * obj.GetHashCode()));
}
public override bool Equals(object obj)
@aviolette
aviolette / foo.sh
Created February 18, 2018 11:52
See outgoing commits
alias outgoing='git log @{u}.. --pretty=oneline'
@aviolette
aviolette / Cache.java
Last active February 12, 2018 20:56
Interview question: Build a Cache
import org.junit.*;
import org.junit.runner.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
JUnitCore.main("Solution");
}
@aviolette
aviolette / bashrc
Last active February 19, 2019 13:13
GIT Bash Stuff
#Just some stuff for the old bashrc
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working tree clean" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
@aviolette
aviolette / angleAt.js
Created December 19, 2017 16:05
Clock Angle
var assert = require('assert');
function angleAt(hour, minute) {
hour = hour > 11 ? 12 - hour : hour;
var minute_hand = 6 * minute,
// 720 minutes in one 12 hour period. 360 degrees / 720 minutes = 0.5 degrees per minute
hour_hand = 0.5 * (60 * hour + minute);
var solution = Math.abs(hour_hand - minute_hand);
return solution > 180 ? 360 - solution : solution;
}