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 / 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 / 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 / json_query.py
Created May 9, 2018 21:06
Get values from nested structures in Python.
def query(q, data, default=None, should_raise=False):
""" This method allows for a simple recursive queries on JSON fields,
including Python's native dictionary.
Sample query:
data = {
'user' {
'aliases': [
{
@Sonictherocketman
Sonictherocketman / xmpp_oauth_authentication.py
Created October 24, 2017 22:05
Use OAuth tokens as XMPP passwords given an OAuth Provider.
#! /usr/bin/python
# https://docs.ejabberd.im/developer/guide/#toc_8
import sys, os
from struct import *
from requests import get
BASE_URL = os.environ['BASE_URL']
DJANGO_AUTH = os.environ['DJANGO_AUTH']
DJANGO_IS_USER = os.environ['DJANGO_IS_USER']