Skip to content

Instantly share code, notes, and snippets.


Nathan Borror nathanborror

View GitHub Profile
View entity.go
Package entity implements functions to store and manipulate entity records
in a schema-less database. The current implementation supports Postgres only.
Inspired by:
Example implementation:
type Account struct {
ID string
Name string
View startapp.go
package main
//go:generate esc -o static.go -prefix "/" static
import (
View TextViewCell.swift
class TextViewCell: UITableViewCell {
var onTap: ((URL) -> Void)?
lazy var textView: UITextView = {
let view = UITextView()
view.translatesAutoresizingMaskIntoConstraints = false
view.backgroundColor = UIColor(red: 1.0, green: 0, blue: 0, alpha: 0.1)
view.textContainer.lineFragmentPadding = 0
view.textContainerInset = .zero
# Generate RSA certificate and key
# The 'host' is the host on which the server is listening and 'prefix' is just
# used to prefix the output files.
# $ <host> <prefix>
View Using Swift Package Manager with

Using Swift Package Manager with iOS

Step 1:

File > New > Project...

Step 2:

Create a Package.swift file in your root project directory, add dependencies, then run swift package fetch on the command line in the same directory. We’re not going to run swift build because it will just complain.

View PagerController.swift
// PagerController.swift
import UIKit
open class PagerController: BaseViewController {
let scrollView = UIScrollView()
let viewControllers: [UIViewController]
View ViewModel.swift
// Table Cells
protocol TableCell {
associatedtype A: Any
associatedtype Cell: UITableViewCell
static func cell(for items: [A], at indexPath: IndexPath, of tableView: UITableView, configure: (cell: Cell, item: A) -> Void) -> Cell
View NSAttributedString.swift
extension NSMutableAttributedString {
func add(attribute: Attribute, range: NSRange) throws {
guard (range.location + range.length) <= length else {
throw AttributedStringError.InvalidRange(range: range)
addAttribute(, value: attribute.value, range: range)


Capturing traffic

Capture some traffic and save in ‘pcap’ format:

$ tshark -w capture.pcap

Reading captured data

View draft.go
// Markup (based on Draft.js:
package draft
import (
type Markup struct {
Blocks []Block `json:"blocks"`