Skip to content

Instantly share code, notes, and snippets.

View armadsen's full-sized avatar

Andrew Madsen armadsen

View GitHub Profile
@armadsen
armadsen / LabelDimensions.csv
Created March 4, 2013 18:49
CSV file containing dimensions information for various Avery label sheets.
labelTypeName labelSheetWidth labelSheetHeight topMargin bottomMargin leftMargin rightMargin numberOfRows numberOfColumns horizontalGutter verticalGutter
Avery 2160 Bottom 8.5 11 5.5 0.5 0.81 0.81 4 1 0 0
Avery 2160 Top 8.5 11 0.5 5.5 0.81 0.81 4 1 0 0
Avery 2162 Bottom 8.5 11 5.5 0.5 0.125 0.125 3 1 0 0
Avery 2162 Top 8.5 11 0.5 5.5 0.125 0.125 3 1 0 0
Avery 2163 Bottom 8.5 11 5.5 0.5 0.125 0.125 2 1 0 0
Avery 2163 Top 8.5 11 0.5 5.5 0.125 0.125 2 1 0 0
Avery 2164 Bottom 8.5 11 5.844 0.844 0.125 0.125 1 1 0 0
Avery 2164 Top 8.5 11 0.844 5.844 0.125 0.125 1 1 0 0
Avery 5159 8.5 11 0.25 0.25 0.156 0.156 7 2 0.188 0
@armadsen
armadsen / CommitSubmodules.sh
Created July 19, 2017 02:18
Quick and dirty bash script to recursively commit submodules
if [[ "$#" -ne 1 ]]; then
echo "You must specify a commit message as an argument."
exit 1
fi
COMMIT_MESSAGE="$1"
git submodule foreach "echo 'Adding all files.'; git add ."
git submodule foreach "echo 'Stashing.'; git stash"
git submodule foreach "echo 'Checking out master branch.'; git checkout master"
git submodule foreach "echo 'Applying stash.'; git stash apply"
@armadsen
armadsen / FunctionPointerFromMethod.m
Created May 19, 2012 18:50
Simple example of getting a function pointer to an Objective-C method and calling it
// To compile and test this from the command line:
//
// $> clang FunctionPointerFromMethod.m -ObjC -framework Foundation -fobjc-arc
// $> ./a.out
#import <Foundation/Foundation.h>
@interface MyClass : NSObject
- (void)someMethodThatTakesOneStringArgument:(NSString *)string;
@end
@armadsen
armadsen / OpenAndReceiveFromSerialPort.c
Created October 12, 2015 17:45
Simple demo of opening and reading data from a serial port in pure C in OS X.
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include <dispatch/dispatch.h>
int main(int argc, char *argv[]) {
int fd = open("/dev/cu.usbmodem1421", O_RDWR | O_NOCTTY | O_EXLOCK | O_NONBLOCK);
if (fd < 1) { return printf("Error opening port: %i\n", errno); }
@armadsen
armadsen / openssl-build.sh
Last active April 17, 2022 22:14 — forked from Norod/openssl-build.sh
A shell script to build openssl for iOS and Mac. >>>>> It currently builds: Mac (i386, x86_64) >>>>> iOS (armv7, arm64) >>>>> iOS Simulator (i386, x86_64) >>>>> Updated to work with Xcode 7 and produce bitcode enabled binaries >>>>> Minimum deployment target can be easily configured
#!/bin/bash
# This script builds the iOS and Mac openSSL libraries with Bitcode enabled
# Download openssl http://www.openssl.org/source/ and place the tarball next to this script
# Credits:
# https://github.com/st3fan/ios-openssl
# https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh
# Peter Steinberger, PSPDFKit GmbH, @steipete.
# Doron Adler, GlideTalk, @Norod78
@armadsen
armadsen / 2019_apps_using_swift.csv
Created February 17, 2019 06:29
Data generated by analysis of the top 110 iOS apps as of January 15, 2019
app_name bundle_id sdk deployment_target uses_swift percentage_swift main_binary_uses_swift is_game executable
30 Day Fitness com.vigorapps.30DayFitness iphoneos12.0 10 TRUE 31% TRUE FALSE ThirtyDaysFitness
8 Ball Pool com.miniclip.8ballpoolmult iphoneos11.3 8 FALSE 0% FALSE TRUE pool
Amazon com.amazon.Amazon iphoneos11.4 9 FALSE 0% FALSE FALSE Amazon
Amazon Alexa com.amazon.echo iphoneos11.2 10 TRUE 28% TRUE FALSE AlexaMobileiOS-prod
Astro Palmistry & Horoscope com.gfb.horoscope iphoneos12.1 8 FALSE 0% FALSE FALSE horoscope
Ball Blast com.nomonkeys.ball-blast iphoneos12.1 9 FALSE 0% FALSE TRUE ball-blast
BetterMen com.betterme.bettermen iphoneos12.0 10 TRUE 74% TRUE FALSE BetterMen
BitLife com.wtfapps.apollo16 iphoneos12.1 8 FALSE 0% FALSE TRUE Apollo16
Bitmoji com.bitstrips.imoji iphoneos11.4 10 TRUE 20% TRUE FALSE imoji
@armadsen
armadsen / SceneKitCheatSheet.m
Last active October 28, 2021 08:06
Cheat sheet for SceneKit learning app (Objective-C)
// Configure the Scene View
self.sceneView.backgroundColor = [UIColor darkGrayColor];
// Create the scene
SCNScene *scene = [SCNScene scene];
@armadsen
armadsen / UploadBuild.sh
Last active October 12, 2021 18:00
Simple script for creating a zip and DMG, uploading to S3, and posting a new build to an Appcaster instance.
#!/bin/sh
# UploadBuild.sh
# Aether
#
# Created by Andrew Madsen on 11/7/15.
# Copyright © 2015 Open Reel Software. All rights reserved.
S3BucketName=<redacted>
username="<redacted>"
@armadsen
armadsen / analyze_apps.py
Created February 15, 2019 19:14
Script to analyze Swift usage in iOS or Mac apps
from pathlib import Path
import plistlib
import subprocess
import re
import csv
def app_uses_swift(path):
libswiftPath = path / 'Frameworks' / 'libswiftCore.dylib'
return libswiftPath.exists()
@armadsen
armadsen / MIKMIDISequence+BarBeatTime.m
Created July 1, 2016 16:17
Quick (untested) example of getting bar-beat time for a particular timestamp in an MIKMIDISequence.
@interface MIKMIDISequence (BarBeatTime)
- (CABarBeatTime)barBeatTimeForTimeStamp:(MusicTimeStamp)timeStamp error:(NSError **)error;
@end
@implementation MIKMIDISequence (BarBeatTime)
- (CABarBeatTime)barBeatTimeForTimeStamp:(MusicTimeStamp)timeStamp error:(NSError **)error
{
error = error ?: &(NSError *__autoreleasing){ nil };
UInt32 timeResolution = 0;