Skip to content

Instantly share code, notes, and snippets.

@RomanTruba
RomanTruba / Synchronization_test_iOS_SDK10
Last active December 28, 2017 13:06
Swift 3, Xcode 8 updated. Also test os_unfair_lock. Much more real life example: working with an array
import XCTest
final class LockingTests: XCTestCase {
// Unsafe in iOS, may cause priority inversion
// But fastest
func testSpinLock() {
var spinLock = OS_SPINLOCK_INIT
executeLockTest { (block) in
OSSpinLockLock(&spinLock)

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.

@wbotelhos
wbotelhos / libreadline_6_not_found.sh
Created November 29, 2016 20:42
Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
ln -s /usr/local/opt/readline/lib/libreadline.7.0.dylib /usr/local/opt/readline/lib/libreadline.6.dylib
@simme
simme / debounce-throttle.swift
Created December 20, 2016 10:04
Swift 3 debounce & throttle
//
// debounce-throttle.swift
//
// Created by Simon Ljungberg on 19/12/16.
// License: MIT
//
import Foundation
extension TimeInterval {
@harv
harv / cross_and_static_compile_shadowsocks-libev.sh
Last active February 18, 2024 12:05
cross & static compile shadowsocks-libev
#!/bin/sh
# cross & static compile shadowsocks-libev
PCRE_VER=8.41
PCRE_FILE="http://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-$PCRE_VER.tar.gz"
MBEDTLS_VER=2.6.0
MBEDTLS_FILE="https://tls.mbed.org/download/mbedtls-$MBEDTLS_VER-gpl.tgz"
@shnhrrsn
shnhrrsn / urlsession-mitmproxy.swift
Created March 12, 2017 20:02
URLSession + MITM Proxy
fileprivate class NetworkingDelegate: NSObject, URLSessionDelegate {
fileprivate func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
completionHandler(.useCredential, URLCredential(trust: challenge.protectionSpace.serverTrust!))
}
}
private let proxySessionDelegate = NetworkingDelegate()
@LokoSoloGames
LokoSoloGames / SlicedFilledImage.cs
Last active July 22, 2025 09:29 — forked from yasirkula/SlicedFilledImage.cs
Combining UI Image's Sliced+Filled features together in Unity
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
#if UNITY_2017_4 || UNITY_2018_2_OR_NEWER
using UnityEngine.U2D;
#endif
using Sprites = UnityEngine.Sprites;
#if UNITY_EDITOR