Skip to content

Instantly share code, notes, and snippets.

@steverichey
steverichey / xoshiroPRNG.swift
Created November 21, 2018 03:20
Not thoroughly tested, needs update for some Random changes in Swift
import Foundation
// http://xoshiro.di.unimi.it/xoshiro256starstar.c
protocol PseudoRandomNumberGenerator {
associatedtype ReturnValue
mutating func next() -> ReturnValue
}
struct Arc4Random: PseudoRandomNumberGenerator {
//: Playground - noun: a place where people can play
import Cocoa
let caseLookup: [Character: Character] = [
"a": "A", "b": "B", "c": "C", "d": "D", "e": "E", "f": "F", "g": "G", "h": "H", "i": "I", "j": "J", "k": "K", "l": "L", "m": "M", "n": "N",
"o": "O", "p": "P", "q": "Q", "r": "R", "s": "S", "t": "T", "u": "U", "v": "V", "w": "W", "x": "X", "y": "Y", "z": "Z"
]
extension Dictionary where Value: Equatable {
@steverichey
steverichey / allow_ios_firewall.sh
Created July 30, 2018 13:33
In theory, allows the iOS simulator to bypass the firewall. May no longer be needed, or it works so well I no longer get the dialog prompt.
#!/bin/sh
# requires sudo
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off
/usr/libexec/ApplicationFirewall/socketfilterfw --add /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
@steverichey
steverichey / gifopt.sh
Created July 13, 2018 14:16
GIF creation with some optimization options
#!/bin/sh
# this was created for an admittedly specialized purpose but has some neat settings i want to remember
palette="/tmp/palette.png"
cropped="/tmp/cropped.mp4"
width="275"
filters="fps=15,scale=${width}:-1:flags=lanczos"
@steverichey
steverichey / Camera.playground
Created June 29, 2018 21:20
Camera edge detection demo for Realities 360
import Cocoa
import AVFoundation
import AVKit
import QuartzCore
import PlaygroundSupport
import AppKit
import CoreGraphics
import CoreImage
let playgroundView = NSView(frame: NSRect(x: 0.0, y: 0.0, width: 640.0, height: 480.0))
@steverichey
steverichey / start_adapt.sh
Last active October 11, 2017 15:08
Start adapt
#!/bin/sh
# exit early on errors
set -eu
# from: brew.sh, install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# latest node via homebrew is borked, install 6.x instead
brew install node@6
@steverichey
steverichey / icons.sh
Created July 17, 2017 18:50
decent script to make android icons from PDF files, supports transparency
#!/bin/sh
usage ()
{
echo "Usage:\nsh icons.sh standard_icon.pdf debug_icon.pdf"
exit 1
}
# usage: iconize input/file.pdf some/output/path/file.png 256
# where `256` is the size to generate
@steverichey
steverichey / zipify.sh
Created July 17, 2017 13:44
this is just a good script with things i might want later
#!/bin/sh
set -eu
ZIP_FILENAME="experience.zip"
JS_FILENAME="template.js"
WTC_FILENAME="tracker.wtc"
DATENAME=`date +"%Y-%m-%d-%H%M%S"`
OUTPUT_JS_DIR="scripts"
OUTPUT_WTC_DIR="augmentation-trackers/4.1"
@steverichey
steverichey / trim_screen.sh
Created March 15, 2017 21:47
chop up an Android screenshot real nice
#!/bin/sh
filename="${1%.*}"
convert $1 -gravity North -chop 0x72 ${filename}-trimmed.png
convert ${filename}-trimmed.png -gravity South -chop 0x96 ${filename}-trimmed-both.png
@steverichey
steverichey / eject_trash_images.py
Last active December 28, 2016 16:15
Python script used in Automator workflow to eject trashed images
# Python script to eject disk images passed as args
# Create a new Folder Action in Automator and add a Run Shell Script step
# Set the shell to /usr/bin/python *AND* set "Pass input:" to "as arguments"
# Paste this script and save! Images moved to the trash are now auto-ejected
# Mostly based on http://www.guidingtech.com/26874/eject-delete-dmg-files-automatically/
import os, sys
# Bail if we didn't wipe a DMG