Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Madsen armadsen

View GitHub Profile
@armadsen
armadsen / SceneKitCheatSheet.swift
Created Nov 2, 2015
Cheat sheet for SceneKit learning app (Swift)
View SceneKitCheatSheet.swift
// Configure the Scene View
self.sceneView.backgroundColor = .darkGrayColor()
// Create the scene
let scene = SCNScene()
@armadsen
armadsen / openssl-build.sh
Last active Dec 8, 2020 — 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
View openssl-build.sh
#!/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 / OpenAndReceiveFromSerialPort.c
Created Oct 12, 2015
Simple demo of opening and reading data from a serial port in pure C in OS X.
View OpenAndReceiveFromSerialPort.c
#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 / PublicKeyDecryptUsingCSSM.m
Last active Oct 12, 2015
Demonstrates the use of CSSM for decrypting using a public key, which is not supported by the Security Transforms API on Mac OS X.
View PublicKeyDecryptUsingCSSM.m
NSData *ORSDecryptDataWithPublicKey(NSData *dataToDecrypt, SecKeyRef publicKey)
{
const CSSM_KEY *cssmPubKey = NULL;
SecKeyGetCSSMKey(publicKey, &cssmPubKey);
CSSM_CSP_HANDLE handle;
SecKeyGetCSPHandle(publicKey, &handle);
CSSM_DATA inputData = {
.Data = (uint8_t *)[dataToDecrypt bytes],
.Length = [dataToDecrypt length],
@armadsen
armadsen / AdvancedArduino.md
Last active Aug 29, 2015
Deckset Markdown file for my presentation, "Arduino and iOS" at CocoaHeads SLC, May 5, 2015.
View AdvancedArduino.md

build-lists: true autoscale: true

#Advanced Arduino ###(or Arduino and iOS)

####Andrew Madsen ####CocoaHeads SLC - May 5, 2015

@armadsen
armadsen / responds.m
Last active Aug 29, 2015
Tiny demo of -respondsToSelector:
View responds.m
/* Compile and run with:
$> clang responds.m -ObjC -std=c99 -framework Foundation
$> ./a.out
*/
#import <Foundation/Foundation.h>
@interface Foo : NSObject
- (int)bar;
@end
@armadsen
armadsen / EventCellDrawRect.m
Created Mar 16, 2015
-[EventCell drawRect] for CustomDesignedAgenda (DevMountain Lesson 25 - Custom Interfaces)
View EventCellDrawRect.m
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
UIColor *color = [UIColor colorWithWhite:1.0 alpha:0.2];
[color setFill];
[color setStroke];
// Draw stripe on right
CGRect sideLineRect = CGRectMake(CGRectGetMidX(self.marker.frame) - 1.5,
@armadsen
armadsen / Lesson17.m
Last active Aug 29, 2015
DevMountain Lesson 17 (Submodules, AVFoundation, CocoaPods) copy/paste blocks
View Lesson17.m
git submodule add https://github.com/AFNetworking/AFNetworking.git External/AFNetworking
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.timeapi.org/utc/now"]];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.responseSerializer = [AFHTTPResponseSerializer serializer];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, NSData *responseObject) {
NSString *response = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
NSLog(@"response: %@", response);
@armadsen
armadsen / FakePeople
Last active Aug 29, 2015
Fake People
View FakePeople
+ (NSArray *)allTheFakePeople {
return @[
@{imageNameKey: @"1",
nameKey: @"Some Dude",
phoneNumberKey: @"888-888-8888",
jobKey: @"Garbage Collection"},
@{imageNameKey: @"2",
nameKey: @"Chris Sacca",
phoneNumberKey: @"920-558-1033",
@armadsen
armadsen / PersonController.m
Created Feb 23, 2015
PersonController for DevMountain Lesson 13
View PersonController.m
// For PersonController.h:
#import "Person.h"
@interface PersonController : NSObject
@property (nonatomic, strong, readonly) NSArray *personList;
+ (PersonController *)sharedInstance;