Skip to content

Instantly share code, notes, and snippets.

@mcgrew
mcgrew / Colors
Created March 21, 2009 10:14
Allows you to preview colors by moving 3 sliders and gives the hex value for the color you see.
#!/usr/bin/env python
import Tkinter
FONT = ('courier new',24,'bold')
def main():
mainWindow = Tkinter.Tk()
mainWindow.title("Color Preview")
mainFrame = Tkinter.Frame(mainWindow)
@mcgrew
mcgrew / png2tmx.go
Last active August 12, 2023 04:50
Convert a png to a TMX tile map
package main
import(
"image/png"
"image/draw"
"image"
"io"
"os"
"fmt"
"encoding/base64"
@mcgrew
mcgrew / view.sh
Created March 28, 2012 16:02
Script for changing monitor settings for the laptop dock
#!/bin/bash
LAPTOP="LVDS1"
DVI1="HDMI1"
DVI2="HDMI2"
DOCK_WIDTH=1680
DOCK_HEIGHT=1050
DOCK_LARGE_WIDTH=1280
DOCK_LARGE_HEIGHT=800
LAPTOP_WIDTH=1440
@mcgrew
mcgrew / ladder.py
Created October 13, 2021 15:28
Word ladder solver exercise
#!/usr/bin/env python3
from sys import argv
from collections import deque, defaultdict
DICTFILE = "/usr/share/dict/words"
def get_words(length):
words = []
with open(DICTFILE, 'r') as dictfile:
@mcgrew
mcgrew / etc_conf.d_routing
Created July 9, 2013 17:00
Systemd service to enable NAT routing.
wan_interface=ens32
lan_interface=ens33
@mcgrew
mcgrew / matrix.py
Created December 22, 2016 06:04
A matrix math implementation in python
"""
matrix.py
(c) 2007,2016 Thomas McGrew
"""
VERSION = "0.3-pre"
MATRIX_VALID_TYPES = (int, float, complex)
MATRIX_VALID_TYPENAMES = ('int', 'float', 'complex')
MATRIX_VALID_INTS = (int,)
@mcgrew
mcgrew / nesggcc.py
Created April 16, 2020 22:07
NES Game Genie code generator
#!/usr/bin/python
# This python script will generate game genie codes for NES
# Pass in the address and value, with an optional compare value
# in hexadecimal format and it will output a game genie code.
# This is quick and dirty and largely untested, so YMMV.
from sys import argv
if len(argv) < 3:
@mcgrew
mcgrew / lndupes.sh
Created January 19, 2011 19:57
Removes duplicate files in a directory, replacing them with hard links.
#!/bin/sh
dir=$1
if [ -z $dir ]; then
dir="."
fi;
# create a temporary file name
TMPFILE="/tmp/$(echo -n "$dir" | md5sum | awk '{print $1}' | tr -d '\n')_$(date +%Y.%m.%d.%H.%M)_dupes.txt"
@mcgrew
mcgrew / phonelookup.sh
Created July 7, 2010 18:20
Bash script for phone number reverse lookup
#!/bin/bash
userAgentList=(
"Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.86 Safari/533.4"
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3"
"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16"
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; InfoPath.2; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152;"
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)"
"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.17) Gecko/20061201 Firefox/2.0.0.17 (Ubuntu-feisty)"
@mcgrew
mcgrew / twitch_emote_lookup.py
Created October 13, 2018 21:56
Twitch emote lookup by code
#!/usr/bin/env python3
from json import loads
from sys import argv, exit
from urllib.request import Request, urlopen
if len(argv) < 2:
print("Usage: %s <emote_name>" % argv[0])
exit(-1)