Skip to content

Instantly share code, notes, and snippets.

🕶
Encrypting Bits

Richard Stelling rjstelling

🕶
Encrypting Bits
Block or report user

Report or block rjstelling

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rjstelling
rjstelling / PrintIntegerAsBinaryString.swift
Created May 24, 2019
A generic function to print the "binary string" of any `FixedWidthInteger`.
View PrintIntegerAsBinaryString.swift
func print<T: FixedWidthInteger>(asBinary val: T) {
let bitCount = MemoryLayout<T>.size * 8
let binaryStr = String(val, radix: 2)
let zeroPadding = String(repeating: "0", count: bitCount - binaryStr.count)
print("0b\(zeroPadding)\(binaryStr)")
}
@rjstelling
rjstelling / iOS Support Matrix Text (english)
Created Dec 3, 2012
This is the text that needs translating so we can release localised versions of the iOS Support Matrix. Feel free to fork and translate: http://www.empiricalmagic.com/post/34832825209/ios-support-matrix-v2-0-winter-2012
View iOS Support Matrix Text (english)
iOS Support Matrix
Winter 2012 Edition - v2.0
iPhone June 2007
iPod touch Sept 2007, Feb 2008 (32GB only)
iPhone 3G July 2008
iPod touch (2nd Generation) Sept 2008 Sept 2009 - (8GB only)
iPhone 3GS June 2009
iPod touch (3rd Generation) Sept 2009
iPad April 2010
iPhone 4 June 2010
@rjstelling
rjstelling / BaseFunctions.swift
Last active Jan 9, 2019
Simple base encoding and decoding in Swift.
View BaseFunctions.swift
import Foundation
enum StringSearchError: Swift.Error {
case didNotFind(Character)
}
extension String {
fileprivate static let DefaultDigits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
fileprivate static let DefaultEmoji = "🤖❤️☠️🤓🦁🍆🧀😎🙄🤢🧠🧶🙈🙉🙊🔥🥕⚽️💊🎶🧶"
View iOS Device Model Names.markdown

iOS Device Model List

iPhone

  • iPhone1,1 — iPhone
  • iPhone1,2 — iPhone 3G
  • iPhone2,1 — iPhone 3GS
  • iPhone3,1 — iPhone 4 (GSM)
  • iPhone3,3 — iPhone 4 (CDMA/Verizon/Sprint)
  • iPhone4,1 — iPhone 4S
  • iPhone5,1 — iPhone 5 (model A1428, AT&T/Canada)
@rjstelling
rjstelling / TwoLabelButton.swift
Created May 31, 2017
A simple Auto Layout solution for a UIButton with 2 labels.
View TwoLabelButton.swift
class CustomButton: UIButton {
internal required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
internal override init(frame: CGRect) {
super.init(frame: frame)
}
}
@rjstelling
rjstelling / Data+FNV32.swift
Created May 4, 2018
Data Extension for Fowler–Noll–Vo hash function
View Data+FNV32.swift
import Foundation
extension Data {
public var fnv32Hash: UInt32 {
return UInt32( self.reduce(0x811c9dc5) { 0x00000000FFFFFFFF & ($0 * 16777619) ^ UInt64($1) } )
}
public func fnv32HashString() -> String {
return String(format: "%08x", self.fnv32Hash)
@rjstelling
rjstelling / Suggestions
Created Dec 9, 2016
When Host.swift was started, it was before we new too much about Swift 3.0, now it has arrived we have a problem... NSHost has been renamed Host when imported into Swift 3.x. We don't want to be a bad Swift citizen and iOS still doesn't have (NS)Host. so we need to rename the project. At this point I am open to any suggestions... the simpler the…
View Suggestions
When Host.swift was started, it was before we new too much about Swift 3.0, now it has arrived we have a problem...
NSHost has been renamed Host when imported into Swift 3.x. We don't want to be a bad Swift citizen and iOS still doesn't have (NS)Host. so we need to rename the project.
At this point I am open to any suggestions... the simpler the better IMHO.
Add your suggestions here:
@rjstelling
rjstelling / SwiftCastingBug.swift
Created Jun 15, 2016
A Playground that demos a bug where a cast using `as` causes a, "fatal error: can't unsafeBitCast between types of different sizes".
View SwiftCastingBug.swift
//: Playground - Demos a bug where a cast using `as` causes a, "fatal error: can't unsafeBitCast between types of different sizes"
import UIKit
protocol Thingable {
func getStuff()
}
enum MyList: Thingable {
case One
@rjstelling
rjstelling / cs_xproj_validate.sh
Last active May 3, 2016
SEE: https://github.com/rjstelling/Xcode-Project-Validate. A very simple shell script to read .xcodeproj files and check if there are issues with the CODE_SIGN_IDENTITY. Having multiple entries can cause build errors (especially when Archiving or command line building). Link to StackOverflow question answering some questions about when and why t…
View cs_xproj_validate.sh
# /bin/bash
#Usage: $ ./cs_xproj_validate.sh path/to/xcode/project/file/theproject.xcodeproj
#More info: http://stackoverflow.com/q/13962341/89035
PROJECT_FILE="$1/project.pbxproj"
PREVIOUS_LINE=-1
for LINE in `cat "$PROJECT_FILE" | grep -n CODE_SIGN_IDENTITY | grep -o -E '^([0-9]*)'`
View Apple News Website Wish list
1. No coverage of Stock price... ever.
2. No coverage of carrier contracts or offers... Unless John Legere joins the Apple board I don't want to read his name.
3. Never publish patents as news.
4. I dont care about US only Apple Pay roll outs.
5. Do not commission renderings of UI designs of unreleased products.
6. No wish lists.
You can’t perform that action at this time.