Skip to content

Instantly share code, notes, and snippets.

View kristopherjohnson's full-sized avatar
💭
Huh?

Kristopher Johnson kristopherjohnson

💭
Huh?
View GitHub Profile
@kristopherjohnson
kristopherjohnson / code_search.ipynb
Last active February 1, 2023 17:00
Search code using OpenAI API
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kristopherjohnson
kristopherjohnson / argparsetest.py
Created July 9, 2022 18:00
Simple example of using the Python argparse module
#!/usr/bin/env python3
"""Tests/examples for the argparse module.
Run "python3 argparsetest.py -h" for help.
"""
from argparse import ArgumentParser
def main():
@kristopherjohnson
kristopherjohnson / Makefile
Created February 22, 2022 23:51 — forked from MLKrisJohnson/Makefile
Makefile for processing Mermaid files in the current directory
# Makefile for Mermaid files in this directory
#
# `make all` - build all targets
# `make png` - build PNGs for all source files
# `make svg` - build SVGs for all source files
# `make pdf` - build PDFs for all source files
# `make clean` - delete all targets
# `make listsources` - print list of all files to be processed
# `make listtargets` - print list of all output files
@kristopherjohnson
kristopherjohnson / dirs_to_markdown.py
Last active September 19, 2021 20:49
Python script to create a Markdown representation of a directory tree
#!/usr/bin/env python3
# Walks a directory tree, creating a Markdown representation of it.
#
# First command line argumaent is root directory. Defaults to current directory.
import os
import sys
if len(sys.argv) > 1:
@kristopherjohnson
kristopherjohnson / Makefile
Created August 9, 2020 19:14 — forked from MLKrisJohnson/Makefile
Makefile that runs GraphViz Dot utility on all *.gv files in the current directory
# Makefile for GraphViz files in this directory
#
# `make all` - build all targets
# `make clean` - delete all targets
# `make listtargets` - print list of all targets
# `brew install graphviz`, or download from <http://graphviz.org/download/>
# to get the `dot` utility.
DOT?=dot
@kristopherjohnson
kristopherjohnson / Play White Noise.applescript
Created February 15, 2020 00:54
AppleScripts for using SoX to play white noise
-- Choose a white noise generator and play.
--
-- Requires installation of SoX <http://sox.sourceforge.net>
-- With Homebrew: brew install sox
--
-- Starts a background process. Kill it with command "killall play" or by running the "Stop Playing" script.
set theSynth to ¬
choose from list {"pinknoise", "whitenoise", "brownnoise"} ¬
with prompt ¬
@kristopherjohnson
kristopherjohnson / FontsView.swift
Created January 4, 2020 22:12
SwiftUI view that displays all available fonts in a scrolling list
import SwiftUI
import UIKit
/// Displays all available fonts in a vertically scrolling view.
struct FontsView: View {
private static let fontNames: [String] = {
var names = [String]()
for familyName in UIFont.familyNames {
names.append(contentsOf: UIFont.fontNames(forFamilyName: familyName))
}
@kristopherjohnson
kristopherjohnson / DecodeGlass.swift
Last active December 27, 2019 20:10
Decoding the "binary codes" on a beer glass gift
import Foundation
let codes: [UInt8] = [
0b01101001,
0b01101100,
0b01101111,
0b01110110,
0b01100101,
0b01111001,
0b01101111,
@kristopherjohnson
kristopherjohnson / Set Terminal Background Colors.applescript
Created December 12, 2019 00:21 — forked from MLKrisJohnson/Set Terminal Background Colors.applescript
AppleScript that sets background colors of terminal windows to different colors, for easier identification
-- Set background colors of terminal windows to different colors, for easier identification
tell application "Terminal"
set window_colors to {¬
{8192, 0, 0}, ¬
{0, 8192, 0}, ¬
{0, 0, 8192}, ¬
{4096, 4096, 0}, ¬
{0, 4096, 4096}, ¬
{4096, 0, 4096}, ¬
@kristopherjohnson
kristopherjohnson / Hello.applescript
Created November 14, 2019 22:33
Friendly AppleScript
tell application "SpeechRecognitionServer"
set possibleResponses to {¬
"hello", ¬
"good bye", ¬
"good morning", ¬
"good afternoon", ¬
"good night", ¬
"nice to meet you", ¬
"pleased to meet you", ¬
"how are you", ¬