Skip to content

Instantly share code, notes, and snippets.

View NQNStudios's full-sized avatar

Nat Quayle Nelson NQNStudios

View GitHub Profile
#! /usr/bin/env python3
import subprocess
import sys
from os.path import join, basename
import os
from pathlib import Path
app_bundle = sys.argv[1]
dry_run = '--dry' in sys.argv
@NQNStudios
NQNStudios / fishlogin
Last active May 29, 2018 23:41
Fish launch script that properly sources the bash profile
#!/bin/bash -l
exec -l fish "$@"
# NOTE THAT YOU ALSO NEED TO ADD THIS TO /etc/shells with the following command:
# echo ~/bin/fishlogin | sudo tee -a /etc/shells
# THEN SET IT AS THE DEFAULT SHELL
# chsh fishlogin
@NQNStudios
NQNStudios / gnim
Last active May 29, 2018 23:02
Runs vim and gvim with my person configuration
#! /bin/bash
gvim -u ~/.vim/customrc "$@"
#!/bin/bash
git status --porcelain | \
awk 'BEGIN {FS=" "}
{
xstat = substr($0, 1, 1);
ystat = substr($0, 2, 1);
f = substr($0, 4);
ri = index(f, " -> ");
if (ri > 0) f = substr(f, 1, ri);
if (xstat == " " && ystat ~ "M|D") stat = "not updated";
@NQNStudios
NQNStudios / lisp.py
Created December 6, 2017 00:08
Simple LISP parser.
# Return the given token as either a string, or the proper number type
def properType(token):
# This will throw an exception if it fails
try:
return int(token)
# Try again to return a float
except ValueError:
return float(token)
# Otherwise it's just a string.
finally:
#! /bin/bash
# Syntax: interval-screenshots [interval (seconds)]
# Takes screenshots periodically and saves them to the current directory
while [ 1 ];
do
vardate=$(date +%d\-%m\-%Y\_%H.%M.%S)
screencapture -t jpg -x ./$vardate.jpg
sleep $1;
#! /bin/bash
cd /Applications/PICO-8.app/Contents/MacOS
./pico8 "$@"
@NQNStudios
NQNStudios / stream-audio
Last active August 29, 2015 14:18
This script uses PulseAudio commands to create a unified audio stream for microphone and system sounds, for live streaming.
# create a virtual sink for both audio streams
SINK_ID=$(pactl load-module module-null-sink sink_name=StreamAudio sink_properties=device.description=StreamAudio)
# find microphone source ID
MIC_ID=$(pactl list short sources | grep "Snowball" | cut -f1)
# loop microphone to the new sink
MIC_LOOPBACK_ID=$(pactl load-module module-loopback sink=StreamAudio source=$MIC_ID)
# find stereo monitor ID
@NQNStudios
NQNStudios / dice
Last active August 29, 2015 14:13
A simple dice roller written in Python.
#! /usr/bin/env python3
import re
import random
import unittest
exit_commands = ( "quit", "exit", "stop" )
modifier_pattern = """
\s* # white space allowed between dice expression and modifier
@NQNStudios
NQNStudios / inputrc
Created November 29, 2014 18:54
This is my personal Linux terminal input configuration file. To use, copy its contents into the file ~/.inputrc
set editing-mode vi
set keymap vi-command