Skip to content

Instantly share code, notes, and snippets.

View bradhowes's full-sized avatar
🏠
Working from home

Brad Howes bradhowes

🏠
Working from home
View GitHub Profile
@uriel1998
uriel1998 / style.css
Created November 25, 2012 17:08
CSS stylesheet for ePub
/* You may notice that my CSS file is organized in a fairly straightforward and */
/* static way. This is intentional, folks. You can do a LOT fancier - but I'm */
/* operating under a KISS principle here. Otherwise it's too easy to have more */
/* than one style applying to any line and making troubleshooting difficult. */
/* My goal is portability and it NEVER distracting from the text. */
/* Put any additional fonts you REQUIRE here. I recommend using additional fonts */
/* only when you MUST; and always define a fallback. Please note that if you have */
/* the font in a sub-directory, you must define it properly in the src portion */
@ole
ole / CharacterArray.swift
Last active June 11, 2023 10:13
Two options for converting character ranges into arrays
// We can't use `Character` or `String` ranges directly because they aren't countable
// Create a countable range of ASCII values instead
let range = UInt8(ascii: "a")...UInt8(ascii: "z") // CountableClosedRange<UInt8>
// Convert ASCII codes into Character values
range.map { Character(UnicodeScalar($0)) } // Array<Character>
// → ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
//
// MyMetalWaterfall.swift
// version 0.1.105 (updated for Swift 5)
//
// Demonstrates using a MetalKit compute shader to render a live waterfall RGB bitmap
// into a UIView
//
// This is a single file iOS app
//
// It includes AppDelegate for a minimal demonstration app
@andreaantonioni
andreaantonioni / ios-cell-registration-swift.md
Last active July 15, 2021 13:41 — forked from gonzalezreal/ios-cell-registration-swift.md
iOS Cell Registration & Reusing with Swift Protocol Extensions and Generics

iOS Cell Registration & Reusing with Swift Protocol Extensions and Generics

A common task when developing iOS apps is to register custom cell subclasses for both UITableView and UICollectionView. Well, that is if you don’t use Storyboards, of course.

Both UITableView and UICollectionView offer a similar API to register custom cell classes:

public func register(_ cellClass: AnyClass?, forCellReuseIdentifier identifier: String)
public func register(_ nib: UINib?, forCellReuseIdentifier identifier: String)
@zbstof
zbstof / remap.sh
Last active August 12, 2021 14:21
#!/usr/bin/env bash
# To run at startup:
# sudo defaults write com.apple.loginwindow LoginHook `pwd`/remap.sh
# https://developer.apple.com/library/content/technotes/tn2450/_index.html
CAPS_LOCK="0x700000039"
ESCAPE="0x700000029"
NON_US_BACKSLASH_PLUS_MINUS="0x700000064"
GRAVE_ACCENT_AND_TILDE="0x700000035"
SLASH_PIPE="0x700000031"
ENTER_RETURN="0x700000028"
@danieleggert
danieleggert / iOS_sysdiagnose.md
Created February 6, 2018 14:14
How to trigger a sysdiagnose on iOS

How To sysdiagnose on iOS:

  1. Hold volume up + volume down + power for 250 milliseconds.
  2. Wait (up to 5 minutes)
  3. Settings.app > Privacy > Analytics > Analytics Data
  4. Select the "sysdiagnose_" file and share via AirDrop to a Mac.
@luizmb
luizmb / Applicative Reader.swift
Last active December 14, 2019 16:38
Using Reader as Applicative vs Monad, in Swift
import Combine
import Foundation
import PlaygroundSupport
struct Reader<E, A> {
let run: (E) -> A
func map<B>(_ fn: @escaping (A) -> B) -> Reader<E, B> {
Reader<E, B> { e in
fn(self.run(e))
}