Skip to content

Instantly share code, notes, and snippets.

View mitchellporter's full-sized avatar

Mitchell Porter mitchellporter

  • Seattle, WA
View GitHub Profile
@mitchellporter
mitchellporter / jason.m
Created July 7, 2016 21:57
audio snippet
- (void) audioPCMFrameWasCaptured:(nonnull const AudioStreamBasicDescription *)pcmASBD bufferList:(nonnull const AudioBufferList *)bufferList time:(CMTime)time sampleRate:(Float64)sampleRate {
int16_t *fdata = bufferList->mBuffers[0].mData;
for (int i = 0; i < bufferList->mBuffers[0].mDataByteSize/sizeof(*fdata); i++) {
*fdata = (int16_t)(*fdata * 0.1);
/**
`ZebraPrinterStatus` is a list of status responses we handle from the printer or during a connection attempt with the printer.
*/
enum ZebraPrinterStatus {
case Ready
case NotReady([ZebraPrinterError])
case Unknown
func message() -> String {
switch self {
@mitchellporter
mitchellporter / ResponseParser.swift
Created July 25, 2016 22:30 — forked from NSExceptional/ResponseParser.swift
A simple class to automate the parsing of an NSURLSessionTask response.
import Foundation
typealias ResponseParserBlock = (ResponseParser) -> Void
class ResponseParser {
// MARK: Response information
private(set) var response: NSHTTPURLResponse?
private(set) var data: NSData?
@mitchellporter
mitchellporter / build_tvvlckit.sh
Created August 2, 2016 23:49 — forked from lg/build_tvvlckit.sh
Building MobileVLCKit for AppleTV: TVVLCKit
# note these instructions are as of Dec 28, 2015
# the vlc and vlckit repos are super complex and have thousands of dependencies from everywhere on the internet.
# so, you'll need to mess with things a bit
git clone http://code.videolan.org/videolan/VLCKit.git
cd VLCKit
./buildMobileVLCKit.sh -t
@mitchellporter
mitchellporter / getting-started.md
Created August 10, 2016 15:33 — forked from joepie91/getting-started.md
Getting started with Node.js

"How do I get started with Node?" is a commonly heard question in #Node.js. This gist is an attempt to compile some of the answers to that question.

And if this list didn't quite answer your questions, I'm available for tutoring and code review! A donation is also welcome :)

Javascript refresher

Especially if you normally use a different language, or you only use Javascript occasionally, it's easy to misunderstand some of the aspects of the language.

These links will help you refresh your knowledge of JS, and make sure that you understand the OOP model correctly.

@mitchellporter
mitchellporter / periscope.sh
Created August 19, 2016 02:36 — forked from dardo82/periscope.sh
Save Periscope Videos
#!/bin/zsh
cd "${0%/*}/../conf/url/"
for user in $(cat ../users.list); do
TWEETS=$(t search timeline -d -l user "#Periscope:" | grep -v " RT @")
OLDIFS=$IFS; IFS=$'\n'
for tweet in $(echo $TWEETS); do
DATE=$(echo $tweet | cut -d\ -f2-6)
OLD_LC_ALL=$LC_ALL; export LC_ALL="POSIX"
SEC=$(($(date +%s) - $(date -j -f ' %b %e %H:%M ' "$DATE" +%s)))
@mitchellporter
mitchellporter / fix-homebrew-npm.md
Created August 31, 2016 21:17 — forked from DanHerbert/fix-homebrew-npm.md
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

Solution

This solution fixes the error caused by trying to run npm update npm -g. Once you're finished, you also won't need to use sudo to install npm modules globally.

Before you start, make a note of any globally installed npm packages. These instructions will have you remove all of those packages. After you're finished you'll need to re-install them.

@mitchellporter
mitchellporter / gist:366958b8d0efb88ca04f8f29c04ffc01
Created August 31, 2016 21:24 — forked from tonymtz/gist:d75101d9bdf764c890ef
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@mitchellporter
mitchellporter / Heroku_Staging.md
Created September 5, 2016 23:44 — forked from stevenyap/Heroku_Staging.md
Staging workflow on Heroku

This describes the workflow to use Heroku as a staging environment. It assumes you already have an existing heroku app in production.

# rename your git remote heroku to something else like production
git remote rename heroku production

# so now you will push as: git push production master

# create the staging app
heroku apps:create staging-appname
@mitchellporter
mitchellporter / promise.js
Created October 8, 2016 22:08 — forked from wavded/promise.js
Promise A+ Implementation
"use strict"
var Promise = function () {
this.state = 'pending'
this.thenables = []
}
Promise.prototype.resolve = function (value) {
if (this.state != 'pending') return
this.state = 'fulfilled'