Skip to content

Instantly share code, notes, and snippets.

Build Swift first using utils/build-script -R, other settings will need different directories below. Add these lines to ~/.bashrc, call with run-test path/to/test:

LLVM_DIR="/path/to/Swift/llvm"
SWIFT_BUILD_DIR="/path/to/Swift/build/Ninja-ReleaseAssert/swift-macosx-x86_64"

run-validation-test() {
    $LLVM_DIR/utils/lit/lit.py -a --param swift_site_config=$SWIFT_BUILD_DIR/validation-test-macosx-x86_64/lit.site.cfg $1
}
@dtorres
dtorres / NSURLBackgroundSessionBits.m
Created November 2, 2015 21:18
Storing Info in background requests.
/*
Basically what we are going to do is use and profit from NSURLRequests being conformant to NSCoding,
and a little known API from NSURLProtocol which allows us attach info to requests.
*/
//Step 0: For the purpose of this gist, we'll already have a background session setup and assume a bunch of stuff.
NSURLSession *bgSession = [NSURLSession magicMethodWhichGivesMeTheAlreadySetupSession]; //Geeez, Methods are long in Obj-C.
//IMPORTANT: Request must be mutable in order for this to work. Got an immutable one. Make a copy. Can't? Well, Make it so!.
//Step 1: Setup your basic request.
@beccadax
beccadax / Example.swift
Last active March 6, 2020 16:10
Elegant handling of localizable strings in Swift. Note: This code is in Swift 2 and would need updates to be used in modern Swift.
let color = "blue"
let num = 42
localized("Colorless green ideas sleep furiously.")
localized("Colorless \(color) ideas sleep furiously.")
localized("\(num.formatted("%05d")) colorless green ideas sleep furiously.")
@Ben-G
Ben-G / GenerateEquatable.swift
Last active October 13, 2016 18:19
Generate Equatable in terms of member fields
import Foundation
struct Term {
let offset: Int
let value: String
}
let term = Term(offset: 0, value: "")
let output = generateEquatable(term)
print(output)
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active May 2, 2024 05:55
OS X Screencast to animated GIF

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: