Skip to content

Instantly share code, notes, and snippets.

View shitchell's full-sized avatar

Shaun Mitchell shitchell

View GitHub Profile
@shitchell
shitchell / git-user-stats
Last active April 22, 2024 19:56
Show user stats in a git repo
#!/bin/bash
#
# Show user stats (commits, files modified, insertions, deletions, and total
# lines modified) for a repo
git_log_opts=( "$@" )
git log "${git_log_opts[@]}" --format='author: %ae' --numstat \
| tr '[A-Z]' '[a-z]' \
| grep -v '^$' \
@shitchell
shitchell / git-ignore
Last active December 21, 2021 17:08
a simple git subcommand for adding files to the .gitignore
#!/bin/bash
#
# This file is used to ignore files and folders in git.
#
# usage:
# git ignore
# git ignore <file1|pattern1> <file2|pattern2> ...
#
# - If no arguments are given, the .gitignore file will be opened in your
# default $EDITOR.
@shitchell
shitchell / hl.py
Last active November 30, 2021 19:28
a simple script for automatically playing games of higher/lower for the purpose of calculating the odds of winning using different methods
#!/usr/bin/env python
HIGHER: int = 3
EXACT: int = 2
LOWER: int = 1
AUTO: int = 0
def run(mode: int = AUTO, ceil: int = 100, repeat: int = 10):
"""
Runs a sequence of Higher/Lower games using the given answering method and
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@shitchell
shitchell / obnoxious-oneliners.py
Last active April 7, 2023 02:43
obnoxiously condensed solutions to codingbat and other python puzzles
### Prsteni ###
# https://open.kattis.com/problems/prsteni
#
# Input
# The first line of input contains an integer N(3≤N≤100), the number of rings.
# The next line contains N integers between 1 and 1000, the radii of Stanko’s
# rings, in the order they are laid out on the floor.
#
# Output
# The output must contain N−1 lines. For every ring other than the first, in the
@shitchell
shitchell / banks.txt
Created July 20, 2021 13:54
All United States Banks & Credit Unions (July 2021)
1880 Bank
1st Advantage Bank
1st Bank
1st Bank in Hominy
1st Bank of Sea Isle City
1st Bank & Trust
1st Bank Yuma
1st Cameron State Bank
1st Century Bank
1st Colonial Community Bank
We can't make this file beautiful and searchable because it's too large.
trail_id,name,area_name,city_name,state_name,country_name,_geoloc,popularity,length,elevation_gain,difficulty_rating,route_type,visitor_usage,avg_rating,num_reviews,features,activities,units
10020048,Harding Ice Field Trail,Kenai Fjords National Park,Seward,Alaska,United States,"{'lat': 60.18852, 'lng': -149.63156}",24.8931,15610.598,1161.8976,5,out and back,3,5,423,"['dogs-no', 'forest', 'river', 'views', 'waterfall', 'wild-flowers', 'wildlife']","['birding', 'camping', 'hiking', 'nature-trips', 'trail-running']",i
10236086,Mount Healy Overlook Trail,Denali National Park,Denali National Park,Alaska,United States,"{'lat': 63.73049, 'lng': -148.91968}",18.0311,6920.162,507.7968,3,out and back,1,4.5,260,"['dogs-no', 'forest', 'views', 'wild-flowers', 'wildlife']","['birding', 'camping', 'hiking', 'nature-trips', 'walking']",i
10267857,Exit Glacier Trail,Kenai Fjords National Park,Seward,Alaska,United States,"{'lat': 60.18879, 'lng': -149.631}",17.7821,2896.812,81.9912,1,out and back,3,4.5,224,"['dogs-no', 'part
@shitchell
shitchell / tt
Last active February 24, 2021 09:01
A script for quickly opening and attaching to tmux sessions
#!/bin/bash
# A script for quickly opening and attaching to tmux sessions
#
# It takes two optional arguments: a session name and directory.
# If no session name is provided, "main" is used. If no
# directory is provided, the current directory is used. Then
# it simply switches to that session. If that session doesn't
# exist, it creates it first and sets the default session. You'd
# think this would be trivial, but tmux requires many different
# options to create/attach a session based on the context.
@shitchell
shitchell / asciify.sh
Created July 28, 2020 14:24
Use a combination of jp2a and imagemagick to print any image as ascii
for path in "$@"; do
# Get the mime-type
MIMETYPE=$(file --mime-type -b "$path")
if [[ "$MIMETYPE" == "image/jpeg" ]]; then
# Use jp2a if image is jpg
jp2a "$path"
elif [[ "$MIMETYPE" =~ image/* ]]; then
# Convert image to temporary jpg
TMPPATH="/tmp/.$path.jpg"