Skip to content

Instantly share code, notes, and snippets.

View Sonictherocketman's full-sized avatar

Brian Schrader Sonictherocketman

View GitHub Profile
@Sonictherocketman
Sonictherocketman / Rocket.py
Last active August 29, 2015 14:00
A piece of a Rocket simulation I made for AE 530 "Rocket Propulsion"
##
# RocketSolver.py
#
# Created by Brian Schrader on 4/25/14.
#
#
##
import Point
@Sonictherocketman
Sonictherocketman / spoilers.regex
Last active December 11, 2017 15:14
Mute Filter for Star Wars Spoilers and Leaks in Tweetbot
(?i)(star wars)|spoil(er|ing)?|((JJ)? Abrams)|(Jar Jar)|((L)(uke|eia))|Skywalker|(Han Solo)|(The)? (Force)|Darth|Jedi|Sith
@Sonictherocketman
Sonictherocketman / install_mc_server.sh
Last active March 1, 2016 07:08
Set up a Minecraft server on a blank Linode instance.
#! /bin/bash
# Set up a Minecraft server on a blank Linode instance.
# Usage:
# $ wget https://gist.githubusercontent.com/Sonictherocketman/221c6fad8ea76657d2b2/raw/1b565e1b5ed8b8b38efbf6d987da8986666857b8/install_mc_server.sh
# $ sh install_mc_server <version>
#
# author: Brian Schrader
# since: 2016-02-29
set -e
@Sonictherocketman
Sonictherocketman / NetworkService.swift
Last active May 24, 2016 23:13
A service for managing remote models fetched via a Django REST API.
// NetworkService.swift
import Alamofire
import AlamofireObjectMapper
import ObjectMapper
/*!
* A service that abstracts the underlying network calls and stores data
* to the data store, or returns them in the completion handler.
*/
@Sonictherocketman
Sonictherocketman / BackgroundModelUpdater.swift
Created August 10, 2016 17:02
An example of an NSNotificationCenter driven background updater.
/**
* A protocol that handles listening to notifications and updating model data asycronously.
*
* To use: create a class that fulfills the protocol and fill in the updateData method.
*/
@objc protocol BackgroundModelUpdater {
/**
* A notification identifier to be used to tell the updater to begin processing updates.
*/
var updateNotification: String { get set }
@Sonictherocketman
Sonictherocketman / guarding.swift
Last active August 18, 2016 01:14
An example of guard statement awesomeness.
class MyViewController : UITableViewController {
// ...
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let activity = self.activities
// If anything isn't right, deselect the row and exit.
guard activity.openable else {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
return
}
guard let task = self.getTask(activity) else {
@Sonictherocketman
Sonictherocketman / export.js
Last active August 23, 2016 01:23
Exporting raw character data from Adventurer's Codex.
/**
* A script to export raw character data from Adventurer's Codex.
*
* Usage:
* 1. open the dev console in your prefered browser under the old Adventurer's Codex domain.
* 2. Copy this entire file into the console line.
* 3. Follow the prompts on the page.
*
*/
@Sonictherocketman
Sonictherocketman / Array+Functional+Extension.swift
Created February 6, 2017 19:48
A set of functional methods for Swift arrays.
// Array+Functional+Extension.swift
// A set of functional methods for arrays.
// Created by Brian Schrader on 2/6/17.
import Foundation
extension Array {
/**
* Determine if all elements in the array are true.
@Sonictherocketman
Sonictherocketman / todolist.sh
Last active February 1, 2024 16:15
Create a continuously updated todo list from code comments. https://brianschrader.com/archive/todolist/
#! /bin/bash
# Given the current working directory, find all of the files of the
# type given and search for TODO comments in them and return a list
# of these items.
#
# Usage: todolist <dir> '*.py'
DIR=$1
if [ -z "$DIR" ]; then
DIR="."
@Sonictherocketman
Sonictherocketman / cleanup-git-branches.sh
Created October 10, 2017 22:50
Interactively remove branches in a given git repository.
#! /bin/bash
# Interactively clean up branches in a given repository.
#
# author: Brian Schrader
# Usage: cd /path/to/repo && ./cleanup-git-branches
BRANCHES="$(git branch | sed 's/[ \*]//g')"
for BRANCH in $BRANCHES; do
CONFIRM_MSG=">>> Delete $BRANCH? [y/n, default: n]: "
read -en 1 -p "$CONFIRM_MSG";