Skip to content

Instantly share code, notes, and snippets.

@steverichey
steverichey / Iconizer.sh
Last active February 23, 2022 17:40
Create iOS application icons from one PDF file. Requires ImageMagick.
#!/bin/sh
#
# Iconizer shell script by Steve Richey (srichey@floatlearning.com)
#
# This is a simple tool to generate all necessary app icon sizes and the JSON file for an *EXISTING* Xcode project from one file.
# To use: specify the path to your vector graphic (PDF format) and the path to your Xcode folder containing Images.xcassets
# Example: sh iconizer.sh MyVectorGraphic.pdf MyXcodeProject
#
# Requires ImageMagick: http://www.imagemagick.org/
@steverichey
steverichey / AndroidManifest-Common
Created January 28, 2015 21:56
Just some AndroidManifest values. I forget these a lot I guess.
<!-- Camera -->
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<!-- GPS -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
@steverichey
steverichey / SafeFloat.js
Created April 21, 2015 18:15
An Ember helper that prevents user-facing NaN values.
/**
* Prevents displaying NaN to the user. Defaults to 0.
*/
Ember.Handlebars.helper("safefloat", function(value, options) {
if (Ember.isEmpty(value) || isNaN(value)) {
value = 0;
}
return new Ember.Handlebars.SafeString(value);
});
@steverichey
steverichey / execfix
Created April 29, 2015 16:05
Fix for OSX Yosemite "can't be opened" bug
#!/bin/sh
# Fixes "*.app can't be opened" errors
# Run `chmod +x` on this file and then
# move it to /usr/bin/ to make it GLOBAL
if [ $# -eq 0 ]
then
echo "No arguments supplied! Expected a path to a .app file"
elif [ -z "$1" ]
@steverichey
steverichey / icns.sh
Created August 25, 2015 02:46
A shell script to convert a single image of arbitrary size to an ICNS file in OS X.
#!/bin/sh
# exit on error
set -e
if [ "$#" -ne 1 ]; then
echo "Usage: icns myicon.png"
exit 0
fi
@steverichey
steverichey / install.sh
Last active October 27, 2015 17:48
Shell script to install HaxeFlixel and dependencies on a Wercker instance
#!/bin/bash
# Install script for application setup on Wercker boxes
# Exit script on error
set -e
echo "Updating apt-get"
# Without updating, apt-get won't find curl
apt-get update
@steverichey
steverichey / NeuralPlayground.swift
Created March 17, 2016 03:21
NeuralSwift - A very simple neural network written in Swift.
// see http://lumiverse.io/series/neural-networks-demystified
import Foundation
let startTime = NSDate()
defer {
let endTime = NSDate()
print("Total time \(endTime.timeIntervalSinceDate(startTime))")
}
@steverichey
steverichey / SequenceType+Multifilter.swift
Created April 21, 2016 17:36
A Swift extension to perform two filters simultaneously.
extension SequenceType {
/**
Filter a single sequence into two "buckets", each an array containing objects of this collection's element type.
- parameter includeElementInFirstCollection: A method that returns true for elements to include in the first collection.
- parameter includeElementInSecondCollection: A method that returns true for elements to include in the second collection.
- returns: A tuple of two arrays containing the elements in their respective buckets.
*/
@warn_unused_result
public func multifilter(@noescape includeInFirst includeElementInFirstCollection: (Self.Generator.Element) throws -> Bool, @noescape includeInSecond includeElementInSecondCollection: (Self.Generator.Element) throws -> Bool) rethrows -> ([Self.Generator.Element], [Self.Generator.Element]) {
var firstCollection: [Self.Generator.Element] = []
@steverichey
steverichey / install_cuda.sh
Created June 15, 2016 16:24
CUDA ARM Setup (Ubuntu 14.04)
# install CUDA
sudo apt-get update
wget "http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.5-18_amd64.deb"
sudo dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb
sudo apt-get update
sudo apt-get install cuda -y
export PATH=/usr/local/cuda-7.5/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-7.5/lib64:$LD_LIBRARY_PATH
# install MPI (optional, for some samples)
@steverichey
steverichey / csv_to_bitmap.swift
Created June 28, 2016 16:40
Convert CSV of luminance to PNG
// swiftlint:disable line_length
// swiftlint:disable variable_name
import Foundation
import Cocoa
struct PixelData {
var a: UInt8 = 255
var r: UInt8
var g: UInt8