Skip to content

Instantly share code, notes, and snippets.

View nickmain's full-sized avatar

Nick Main nickmain

View GitHub Profile
import Foundation
func appendTo<each T, E>(tuple: (repeat each T), element: E) -> (repeat each T, String, E) {
(repeat each tuple, "DIVIDER", element)
}
let firstTuple = appendTo(tuple: 1, element: "two")
let appendedTuple = appendTo(tuple: firstTuple, element: 3.3)
print(appendedTuple) // (1, "DIVIDER", "two", "DIVIDER", 3.3)
print(type(of: appendedTuple)) // (Int, String, String, String, Double)
@nickmain
nickmain / OCaml.plist
Created January 23, 2025 20:41 — forked from GPHemsley/OCaml.plist
OCaml Codeless Language Module for TextWrangler and BBEdit syntax highlighting
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BBEditDocumentType</key>
<string>CodelessLanguageModule</string>
<key>BBLMLanguageCode</key>
<string>OCml</string>
@nickmain
nickmain / zshrc
Created April 16, 2024 16:46
Current zshrc
export PATH="$HOME/Developer/tools/bin:$PATH"
PS1='%1d 🔸 '
RPROMPT="%F{blue}%B%*%b%f"
alias la='ls -la'
alias now='date +"%s"'
alias ded="rm -rf ~/Library/Developer/Xcode/DerivedData;rm -rf ~/Library/Caches/org.swift.swiftpm"
alias ..='cd ..'
alias branch='git branch'
@nickmain
nickmain / Subscriptions-iCloud.opml
Created November 10, 2023 00:41
NetNewsWire Subscriptions
<?xml version="1.0" encoding="UTF-8"?>
<!-- OPML generated by NetNewsWire -->
<opml version="1.1">
<head>
<title>Subscriptions-iCloud.opml</title>
</head>
<body>
<outline text="Reddit" title="Reddit">
<outline text="Forth - The programming language for low-fat computing." title="Forth - The programming language for low-fat computing." description="" type="rss" version="RSS" htmlUrl="https://www.reddit.com/r/Forth/" xmlUrl="http://www.reddit.com/r/Forth/.rss"/>
<outline text="Programming in Logic :- Prolog" title="Programming in Logic :- Prolog" description="" type="rss" version="RSS" htmlUrl="https://www.reddit.com/r/prolog/" xmlUrl="http://www.reddit.com/r/prolog/.rss"/>
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------
Process: Python [16800]
Path: /Library/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python
Identifier: org.python.python
Version: 3.10.2 (3.10.2)
Code Type: X86-64 (Native)
Parent Process: zsh [3556]
@nickmain
nickmain / tryToSendFocus.swift
Created January 11, 2022 00:29
Forced focus targetting
// Focus management
private var targetFocusEnv: UIFocusEnvironment?
override var preferredFocusEnvironments: [UIFocusEnvironment] {
if let target = targetFocusEnv {
return [target]
} else {
return []
}
}

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@nickmain
nickmain / MiniHTTPServer.swift
Created April 11, 2016 03:28
Minimal Swift HTTP server for unit testing
//: Playground - noun: a place where people can play
import Foundation
class ServerSocket {
private var sockAddrLen = socklen_t(sizeof(sockaddr_in))
private var serverSocket = socket(AF_INET, SOCK_STREAM, 0)
init?(_ port: UInt16) {
var option: UInt32 = 1

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

#lang racket
(define (run-length n)
(let ([run-char #f]
[run-len 0])
(λ(c)
(if (equal? c run-char)
(set! run-len (+ run-len 1))
(begin (set! run-len 1)
(set! run-char c)))