Skip to content

Instantly share code, notes, and snippets.

@cookbrianj
cookbrianj / BCNeonImageUtils.h
Created May 30, 2012 20:45
ARM NEON Helpers
//
// BCNeonImageUtils.h
// IRStudio
//
// Created by Brian Cook on 5/30/12.
// Copyright (c) 2012 All rights reserved.
//
#ifndef IRStudio_BCNeonImageUtils_h
#define IRStudio_BCNeonImageUtils_h
//
// PixelBufferUtils.h
// IRStudio
//
// Created by Brian Cook on 5/30/12.
// Copyright (c) 2012 All rights reserved.
//
#import <Accelerate/Accelerate.h>
#import "BCNeonImageUtils.h"
@cookbrianj
cookbrianj / UIImage+IRHelpers
Created June 4, 2012 20:44
UIImage Category to help with IR photo processing tasks
//
// UIImage+IRHelpers.m
// RedStudio
//
// Created by Brian Cook on 6/4/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "UIImage+IRHelpers.h"
#import <Accelerate/Accelerate.h>
extension String {
func Base64Encode() -> String? {
let asciiString = self.dataUsingEncoding(NSASCIIStringEncoding, allowLossyConversion: true)
guard let base64String = asciiString?.base64EncodedStringWithOptions(NSDataBase64EncodingOptions()) else { return nil }
return base64String
}
}
public class PowerSchoolServiceWrapper {
static let sharedInstance = PowerSchoolServiceWrapper()
@cookbrianj
cookbrianj / SimpleLinearRegression.swift
Created September 21, 2016 02:19
A simple, naive implementation of gradient descent/linear regression in Swift using capacity loss vs mileage of Nissan Leaf
import UIKit
var milesDriven:[Double] = [0,100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500,1600,1700,1800,12000,16000,20000,13633,25000,11383,10200,15700,12734,14278,24000,25500,10052,21085,21451,21000,20300,20100,16000,17500,15000,20490,34173,31510,22900,23800,19000,10500,14000,19200,16500,22700,18300,19345,20791,16500,15868,13884,11275,10300,14180,23652,14900,16800,13365,32500,20651,27177,31473,15472,27435,26797,50600,41972,25725,15900,23000,44733,33700,35989,21649,34500,73205,53171,41000,30000,44263,54661,44076,39700,44897,34900,26495,28190,43520,28700,53600,55475,58078,40755,39801,34000,86400,52600,129300,61150,59983,48168,50952,55800,56000]
var barsLost:[Double] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4]
var minMileage:Double = milesDriven.min()!
var maxMileage:Double = milesDriven.max()!
var milesDrivenSc