Skip to content

Instantly share code, notes, and snippets.

View chefnobody's full-sized avatar

Aaron Connolly chefnobody

View GitHub Profile
@chefnobody
chefnobody / gluestick-terms-definitions.md
Created May 22, 2017 17:23
consumer-frontend and Gluestick 1.x

consumer-frontend and GlueStick 1.0

Overview

consumer-frontend is a Gluestick project built using gluestick-cli�—a thin wrapper application for helping you build and manage Gluestick projects. gluestick is a package that is part of the gluestick-cli monorepo. The gluestick-cli is available on npm and is comprised of several modules or "packages."

Terms & Definitions

  • Gluestick is a monorepo. It is published to npm with Learna and contains depdent modules or "packages" for building Gluestick apps. The Gluestick repo uses Lerna 1,2 to help break what would otherwise be a potentially large code base in to smaller, versioned packages.
  • gluestick-cli - A package in the Gluestick monorepo that acts as a thin wrapper for managing Gluestick apps from the command-line. With it you can create an app, destroy it,
@chefnobody
chefnobody / keybase.md
Created October 5, 2017 13:11
Keybase claim

Keybase proof

I hereby claim:

  • I am chefnobody on github.
  • I am aaronconnolly (https://keybase.io/aaronconnolly) on keybase.
  • I have a public key ASAXmxs_SZiDcz92qU0BJveaP0BaCJ6Sv7B12qvMbtPf8go

To claim this, I am signing this object:

@chefnobody
chefnobody / subscript-with-int-string-extension.swift
Created February 2, 2018 16:14
Swift String extension for subscripting with `Int` rather than `String.Index`
// This doesn't consider multi-code Unicode characters like 🤖
extension String {
subscript(range: Range<Int>) -> String {
// Convert Int range to String.Index-based range
let begin = String.Index(encodedOffset: range.lowerBound)
let end = String.Index(encodedOffset: range.upperBound)
return String(self[begin...end])
}
}
extension String {
// Subscript with an integer that returns the character
subscript(index: Int) -> Character {
return self[String.Index(encodedOffset: index)]
}
/*
Levenshtein Distance
https://en.wikipedia.org/wiki/Levenshtein_distance
@chefnobody
chefnobody / BitManipulation.swift
Created March 2, 2018 15:19
Playing around a little w/ binary representations of 8 bit numbers, bitwise operations and shifting.
import Foundation
/*
Bit manipulation in Swift
https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/AdvancedOperators.html
*/
var zero: UInt8 = 0b00000000
var one: UInt8 = 0b00000001
@chefnobody
chefnobody / FizzBuzz.swift
Created March 6, 2018 15:52
Playing with ways to do fizz-buzz in Swift.
//: Playground - noun: a place where people can play
import Foundation
func fizzable(_ num: Int) -> Bool {
return num % 3 == 0
}
func buzzable(_ num: Int) -> Bool {
return num % 5 == 0
@chefnobody
chefnobody / Conflict-Free Replicated Data Type
Last active March 12, 2018 14:53
Notes from reading through Peer-to-Peer white boarding article from Black Pixel.
import Foundation
/*
Peer-to-Peer white boarding application:
https://medium.com/bpxl-craft/building-a-peer-to-peer-whiteboarding-app-for-ipad-2a4c7728863e
Conflict-Free Replicated Data Type
CRDT
@chefnobody
chefnobody / QuickSort.swift
Created March 18, 2018 17:41
A Quick Sort implementation in Swift
//: Playground - noun: a place where people can play
import UIKit
extension Array where Element: Comparable {
mutating func quickSort() -> Array<Element> {
// Recursive function that works out where our next pivots will be.
func qSort(start startIndex: Int, _ pivot: Int) {
if (startIndex < pivot) {
@chefnobody
chefnobody / StringPermutations.swift
Created March 18, 2018 17:43
Find all permutations of a string in Swift
//: Playground - noun: a place where people can play
import Foundation
func stringPermutations(s: String) -> [String] {
return ["?"]
}
/*
Avoid using C++'s std::next_permutation or similar features in other languages to solve this challenge. Implement the algorithm yourself, since this is what you would be asked to do during a real interview.
@chefnobody
chefnobody / FindFirstSubstring.swift
Created March 18, 2018 17:45
Finds the position of a substring in another string if available.
//: Playground - noun: a place where people can play
import Foundation
/*
Avoid using built-in functions to solve this challenge. Implement them yourself.
Implement a function that takes two strings, s and x, as arguments and finds the first occurrence of the string x in s. The function should return an integer indicating the index in s of the first occurrence of x. If there are no occurrences of x in s, return -1.
Example