Skip to content

Instantly share code, notes, and snippets.

View shitchell's full-sized avatar

Shaun Mitchell shitchell

View GitHub Profile
@shitchell
shitchell / github-clone
Last active July 7, 2020 01:00
Clone a github repository with just the username and repository name: github-clone shitchell qrng
#!/bin/bash
usage() {
echo "usage: $(basename $0) github-user github-repository"
echo " $(basename $0) github-user/github-repository"
}
if [[ "$#" -ne 1 && "$#" -ne 2 ]]; then # require exactly 1 or 2 arguments
usage && exit
elif [[ "$#" -eq 1 && "$1" != *"/"* ]]; then # if one argument provided, require a slash
@shitchell
shitchell / bak
Created July 7, 2020 01:04
Easily create backups of files with a .bak extension (also adds a trailing number if the file already exists)
#!/bin/bash
for filepath in $@; do
if [[ -f "$filepath" ]]; then
filepath_bak=$filepath.bak
if [[ -f "$filepath_bak" ]]; then
i=1
filepath_bak_i=$filepath_bak".$i"
while [[ -f "$filepath_bak_i" ]]; do
((i++))
@shitchell
shitchell / dupes
Created July 7, 2020 01:06
Python script to scan directories / files for duplicates and optionally remove them
#!/usr/bin/env python3
import re
import os
import sys
import time
import hashlib
import optparse
parser = optparse.OptionParser()
@shitchell
shitchell / pysock
Created July 7, 2020 01:35
Python script resembling ncat that allows you to send invisible characters using their unicode values
#!/usr/bin/env python3
import sys
import time
import socket
import _thread
import readline
if len(sys.argv) < 3:
print('usage: pysock [options] server port')
@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"
@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.
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 / 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
@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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.