Skip to content

Instantly share code, notes, and snippets.

View armadsen's full-sized avatar

Andrew Madsen armadsen

View GitHub Profile
@armadsen
armadsen / ORSSerialPort+Attributes.m
Last active July 11, 2018 13:44
Example code to get USB device properties for a given instance of ORSSerialPort. Will only work for USB-to-serial adapters, not internal serial ports. Based on https://gist.github.com/rhwood/4124251.
#import <Foundation/Foundation.h>
#import <IOKit/usb/USBSpec.h>
#import "ORSSerialPort.h"
@interface ORSSerialPort (Attributes)
@property (nonatomic, readonly) NSDictionary *ioDeviceAttributes;
@property (nonatomic, readonly) NSNumber *vendorID;
@property (nonatomic, readonly) NSNumber *productID;
@armadsen
armadsen / SceneKitCheatSheet.swift
Created November 2, 2015 01:17
Cheat sheet for SceneKit learning app (Swift)
// Configure the Scene View
self.sceneView.backgroundColor = .darkGrayColor()
// Create the scene
let scene = SCNScene()
@armadsen
armadsen / MIKMIDISynthesizer+Volume.swift
Created May 12, 2018 21:18
Extension to add a volume property to MIKMIDISynthesizer on iOS
//
// MIKMIDISynthesizer+Volume.swift
//
// Created by Andrew Madsen on 3/22/16.
// Copyright © 2016 Mixed In Key. All rights reserved.
//
import Foundation
import CoreAudio
import MIKMIDI
/* Compile this with:
clang -std=c99 -framework CoreMIDI -fed MIDIPacketNextTest.m
Run:
./a.out
*/
$ brew --config
HOMEBREW_VERSION: 0.9.5
ORIGIN: (none)
HEAD: (none)
Last commit: never
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://ia902307.us.archive.org/31/items/tigerbrew
CPU: single-core 32-bit g4e
@armadsen
armadsen / deletescreen.rb
Last active January 28, 2016 17:35
Ruby script using spaceship to delete all existing screenshots for an iOS app on iTunes Connect
#!/usr/bin/env ruby
require "spaceship"
Spaceship.login('yourusername', 'yourpassword')
Spaceship::Tunes.login('yourusername', 'yourpassword')
du = Spaceship::Tunes.client.du_client
app = Spaceship::Tunes::Application.find "app.bundle.id"
@armadsen
armadsen / MultipleClassExtensions.m
Last active January 4, 2016 11:59
Demonstration of multiple class extensions in Objective-C. For http://stackoverflow.com/a/21343983/344733
#import <Foundation/Foundation.h>
@interface TestClass : NSObject
@end
@interface TestClass ()
@property NSString *name;
@armadsen
armadsen / SeparateNSLocks.m
Last active December 25, 2015 21:49
Demo of separate instances of NSLock in response to this Stack Overflow question: http://stackoverflow.com/q/19451510/344733
#import <Foundation/Foundation.h>
@interface Test : NSObject
- (void)enqueue:(id)object;
- (id)dequeue;
@end
@implementation Test
@armadsen
armadsen / Reusable.m
Created June 21, 2013 17:49
Example of how I would do https://code.stypi.com/clifton/Objective-C/reusable.m if I were going to do it essentially the same way. In response to https://twitter.com/cliftonite/status/348133150880317440
- (void)makeGraphPopup:(NSString *)popupName {
/*
I want to pass a string (popupName) into this method and use it dynamically
for object names just like popupName.to_sym in Ruby.
Below you can see where I've insert {popupName} and how it would append itself
to various object names which are IBOutlets
*/
@armadsen
armadsen / CategoryPropertyDemo.m
Created March 14, 2013 21:42
Quick and dirty illustration of @Property declared (but not synthesized) in a category.
#import <Foundation/Foundation.h>
@interface MyClass : NSObject
@end
@implementation MyClass
@end
@interface MyClass (Properties)