Skip to content

Instantly share code, notes, and snippets.

@justinmakaila
justinmakaila / README.md
Created July 12, 2023 20:33
New computer applications and niceities
@justinmakaila
justinmakaila / button_box.ido
Last active November 6, 2020 16:20
Button box for Arduino WIP
#include <Joystick.h>
#include <Keypad.h>
#define ENABLE_PULLUPS
#define NUMROTARIES 4 // Number of rotary encoders
#define NUMBUTTONS 18 // Number of buttons
#define NUMROWS 6 // Number of rows in matrix
#define NUMCOLS 3 // Number of columns in matrix
byte row_pins[NUMROWS] = {6, 7, 8, 9, 10, 16};
@justinmakaila
justinmakaila / detectCommitRange.sh
Created August 27, 2019 17:36
Detects the commit range of a PR on CircleCI since the last successful status check
# Build what's changed in the HEAD commit by default
COMMIT_RANGE="$CIRCLE_SHA1"
# If this is a PR, diff the changes over time against ther commit status
# according to the Github API.
# TODO: This should move to a Circle Orb cause OSS is sweet.
if ! [[ -z ${CIRCLE_PULL_REQUEST+x} ]];
then
GITHUB_USER=wellth-app
GITHUB_REPO_NAME=react-components
@justinmakaila
justinmakaila / AppDelegate.swift
Created November 20, 2017 18:19
React Native App Delegate in Swift 4.0
import UIKit
let CodeLocation = "index"
let ModuleName = "<ProjectName>"
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(
@justinmakaila
justinmakaila / main.swift
Created May 1, 2017 18:49
Lunar Initialization
import Apollo
import Lunar
let apollo: ApolloClient = {
let cache = try! LunarCache() /// try! since any failure would be considered catastrophic
let store = ApolloStore(cache: cache)
let networkTransport: NetworkTransport = // Set up your network
return ApolloClient(
import CoreData
public final class LunarRecord: NSManagedObject {
/// The primary key for the object.
public let key: String
/// The JSON string that represents the object.
public let record: String
}
@justinmakaila
justinmakaila / NormalizedCache.swift
Created May 1, 2017 16:23
NormalizedCacheSnapshot
public protocol NormalizedCache {
/// Loads records corresponding to the given keys.
/// - returns: A promise that fulfills with an array, with each index containing either the
/// record corresponding to the key at that index or nil if not found.
func loadRecords(forKeys keys: [CacheKey]) -> Promise<[Record?]>
/// Merges a set of records into the cache.
/// - returns: A promise that fulfills with a set of keys corresponding to *fields* that have
/// changed (i.e. QUERY_ROOT.Foo.myField). These are the same type of keys as are
import GraphQL
import JSONMapping
/// Provides a GraphQL update mutation and variables
protocol UpdateRequestProvider {
var updateMutation: GraphQL.Mutation { get }
var updateVariables: JSONObject { get }
}
@justinmakaila
justinmakaila / UIKit+ReactiveCocoa.swift
Created December 29, 2015 19:10
UIKit extensions for adding Reactive Cocoa Support
import UIKit
import ReactiveCocoa
// MARK: - UIControl
extension UIControl {
func producerForEvent<T where T: UIControl>(controlEvent: UIControlEvents) -> SignalProducer<T, NoError> {
return self.rac_signalForControlEvents(controlEvent)
.toSignalProducer()
.map { (object: AnyObject?) -> T? in
// Protocol oriented design example
protocol Endpoint {
var method: String { get }
var path: String { get }
var body: [String: AnyObject] { get }
}
func request(endpoint: Endpoint) {
APIClient.request(endpoint.path, method: endpoint.method);