Skip to content

Instantly share code, notes, and snippets.

@MarcoSantarossa
MarcoSantarossa / AsyncOperation.swift
Last active August 2, 2023 13:23
How to write and use an asynchronous operation
import Foundation
class AsyncOperation: Operation {
enum State: String {
case isReady, isExecuting, isFinished
}
override var isAsynchronous: Bool {
return true
}
@lattner
lattner / TaskConcurrencyManifesto.md
Last active September 21, 2026 22:06
Swift Concurrency Manifesto
@troyfontaine
troyfontaine / 1-setup.md
Last active September 9, 2026 13:46
Signing your Git Commits on MacOS

Methods of Signing Git Commits on MacOS

Last updated March 13, 2024

This Gist explains how to sign commits using gpg in a step-by-step fashion. Previously, krypt.co was heavily mentioned, but I've only recently learned they were acquired by Akamai and no longer update their previous free products. Those mentions have been removed.

Additionally, 1Password now supports signing Git commits with SSH keys and makes it pretty easy-plus you can easily configure Git Tower to use it for both signing and ssh.

For using a GUI-based GIT tool such as Tower or Github Desktop, follow the steps here for signing your commits with GPG.

@solancer
solancer / Install Ruby Gems on Mac OS X without sudo
Created January 3, 2017 15:21
Install Ruby Gems on Mac OS X without sudo
Install Ruby Gems on Mac OS X without sudo
1. Add GEM_HOME to your .bash_profile
For example, nano ~/.bash_profile and add
export GEM_HOME=/Users/srinivas/.gem where the path is to your own Home folder
2. Add the gem executables to your system path
Also in .bash_profile, add
@ipbastola
ipbastola / jq to filter by value.md
Last active May 22, 2026 18:53
JQ to filter JSON by value

JQ to filter JSON by value

Syntax: cat <filename> | jq -c '.[] | select( .<key> | contains("<value>"))'

Example: To get json record having _id equal 611

cat my.json | jq -c '.[] | select( ._id | contains(611))'

Remember: if JSON value has no double quotes (eg. for numeric) to do not supply in filter i.e. in contains(611)

@cbess
cbess / TimeParts.swift
Last active May 5, 2023 07:59
Swift: Seconds to minutes and hours parts
/// Represents parts of time
struct TimeParts: CustomStringConvertible {
var seconds = 0
var minutes = 0
/// The string representation of the time parts (ex: 07:37)
var description: String {
return NSString(format: "%02d:%02d", minutes, seconds) as String
}
}
@cbess
cbess / AppNotify.swift
Last active August 10, 2019 15:58
Simple NSNotificationCenter wrapper for Swift 4.x
//
// AppNotify.swift
//
// Created by Christopher Bess on 6/30/15.
// MIT License
//
import Foundation
/// Represents the app notification.
@robertknight
robertknight / hypothesis-webextensions.md
Last active January 23, 2018 18:57
Hypothesis Firefox WebExtensions Prototype Instructions

Hypothesis Firefox WebExtensions prototype

  1. Install Firefox Developer Edition from https://www.mozilla.org/en-GB/firefox/developer/ and run it
  2. Enter "about:config" in Firefox's URL bar and press Enter
  3. Search for "xpinstall.signatures.required" and double click the setting to toggle it to "false"
  4. Download the Firefox WebExtensions prototype build from https://s3.amazonaws.com/io.github.robertknight/hypothesis/prototypes/hypothesis-stage.xpi
  5. Open it in Firefox by going to File -> Open and selecting the downloaded extension

What works:

  • Annotation badge. Looks slightly more attractive than Chrome.
@nlutsenko
nlutsenko / yolo.sh
Last active June 16, 2026 22:44
Fast Xcode builds
defaults write xcodebuild PBXNumberOfParallelBuildSubtasks 4
defaults write xcodebuild IDEBuildOperationMaxNumberOfConcurrentCompileTasks 4
defaults write com.apple.xcode PBXNumberOfParallelBuildSubtasks 4
defaults write com.apple.xcode IDEBuildOperationMaxNumberOfConcurrentCompileTasks 4