Skip to content

Instantly share code, notes, and snippets.

View richy486's full-sized avatar
🐶
Experimenting

Richard Adem richy486

🐶
Experimenting
View GitHub Profile
@verticalgrain
verticalgrain / chip-flashing-guide-nov-2018.md
Last active April 10, 2024 09:47
NextThingCo C.H.I.P. Flashing guide as of November, 2018

Below are the steps required to flash a NextThingCo CHIP or PocketCHIP from the command line, as of November 2018. The web flasher no longer works, and there are numerous errors when flashing from the command line, mostly due to broken dependencies. The following method works for flashing a CHIP as of November 2018:

Note: Flashing must be done on Linux. Tested on Ubuntu and Rasparian. Mac OS seems to not work.

  1. Download and unpack the CHIP-SDK.zip from one of the following:
  1. Download and unpack CHIP-tools.zip from one of the following:
@cellularmitosis
cellularmitosis / EmojiPointersDemo.swift
Created August 15, 2018 18:11
Representing pointer values as emoji can be useful for "visually" debugging certain issues, like cell reuse, etc.
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let window = UIWindow(frame: UIScreen.main.bounds)
@joncardasis
joncardasis / UIViewController+StatusBar.swift
Created July 10, 2018 19:12
A swizzling method which introduces a `statusBarStyle` to control the display of the status bar on a view controller.
//
// UIViewController+StatusBar.swift
// StatusBarTesApp
//
// Created by Jonathan Cardasis (C) on 7/10/18.
// Copyright © 2018 Jonathan Cardasis. All rights reserved.
//
import UIKit
import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
NSLayoutConstraint.activate([
tableView.topAnchor.constraint(equalTo: view.topAnchor),
@lattner
lattner / TaskConcurrencyManifesto.md
Last active May 16, 2024 15:15
Swift Concurrency Manifesto
@khanlou
khanlou / Enum+CaseCountable.swift
Created November 15, 2016 18:19
count and allValues on Int-based enums
protocol CaseCountable { }
extension CaseCountable where Self : RawRepresentable, Self.RawValue == Int {
static var count: Int {
var count = 0
while let _ = Self(rawValue: count) { count+=1 }
return count
}
@andymatuschak
andymatuschak / States-v3.md
Last active May 1, 2024 12:32
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

@bishboria
bishboria / springer-free-maths-books.md
Last active April 25, 2024 06:27
Springer made a bunch of books available for free, these were the direct links
@qmchenry
qmchenry / gist:4bf7c7734e3df5f2ccc4
Last active September 24, 2015 14:56
highlight cmd line syntax for keynote presenatiosn
My version of https://gist.github.com/jimbojsb/1630790 which amazingly still works four years later
highlight -O rtf File.swift --line-numbers --font-size 32 --font SourceCodePro-Regular -V -J 96 -j 2 --syntax swift --style darkslategray | pbcopy
@JadenGeller
JadenGeller / Swift Dictionary Map Filter Reduce.swift
Created March 27, 2015 04:24
Swift Dictionary Map/Filter/Reduce
extension Dictionary {
init(_ elements: [Element]){
self.init()
for (k, v) in elements {
self[k] = v
}
}
func map<U>(transform: Value -> U) -> [Key : U] {
return Dictionary<Key, U>(Swift.map(self, { (key, value) in (key, transform(value)) }))