Skip to content

Instantly share code, notes, and snippets.

import Foundation
/// A type representing an concrete part of an application, such that it can be
/// identified in logs.
///
/// A typical use is as a nested type:
///
/// extension MyViewController {
/// enum Log: Error {
/// case user
@CodaFi
CodaFi / Channel.swift
Created February 27, 2017 22:45
[WIP] Session Types as good as I could get em. Ported from the Rust implementation by Philip Munksgaard.
//
// Channel.swift
// Sessions
//
// Created by Robert Widmann on 2/27/17.
// Copyright © 2017 TypeLift. All rights reserved.
//
enum FakeError : Error {
case Error
@nevyn
nevyn / GFASLProxy.m
Created November 30, 2015 23:41
Capturing ASL on Mac/iOS
// See also https://github.com/CocoaLumberjack/CocoaLumberjack/blob/master/Classes/DDASLLogCapture.m
#import "GFASLProxy.h"
#include <asl.h>
#include <notify.h>
#include <notify_keys.h>
#include <sys/time.h>
@implementation GFASLProxy
@eriwen
eriwen / cors.js
Created May 26, 2012 15:54
Simple cross-domain Javascript function
/**
* Make a X-Domain request to url and callback.
*
* @param url {String}
* @param method {String} HTTP verb ('GET', 'POST', 'DELETE', etc.)
* @param data {String} request body
* @param callback {Function} to callback on completion
* @param errback {Function} to callback on error
*/
function xdr(url, method, data, callback, errback) {
@dulacp
dulacp / Overlay_iOS_app_version_on_icon_README.md
Last active November 19, 2017 11:18
Overlay the iOS application version on top of the icon

Usage

Requirements

Install the two dependencies, ImageMagick and Ghostscript.

$ brew install imagemagick
$ brew install ghostscript
@rnystrom
rnystrom / RN3DTouchGestureRecognizer.swift
Last active February 3, 2018 22:58
RN3DTouchGestureRecognizer
//
// RN3DTouchGestureRecognizer.swift
//
// Created by Ryan Nystrom on 10/10/15.
// Copyright © 2015 Ryan Nystrom. All rights reserved.
//
import UIKit.UIGestureRecognizerSubclass
class RN3DTouchGestureRecognizer: UIGestureRecognizer {
@Eradash
Eradash / osxvpnrouting.markdown
Last active October 4, 2018 18:23 — forked from taldanzig/osxvpnrouting.markdown
Routing tips for VPNs on OS X

Routing tips for VPNs on OS X

When VPNs Just Work™, they're a fantastic way of allowing access to a private network from remote locations. When they don't work it can be an experience in frustration. I've had situations where I can connect to a VPN from my Mac, but various networking situations cause routing conflicts. Here are a couple of cases and how I've been able to get around them.

Specific cases

Case 1: conflicting additional routes.

In this example the VPN we are connecting to has a subnet that does not conflict with our local IP, but has additional routes that conflict in some way with our local network's routing. In my example the remote subnet is 10.0.x.0/24, my local subnet is 10.0.y.0/24, and the conflicting route is 10.0.0.0/8. Without the later route, I can't access all hosts on the VPN without manually adding the route after connecting to the VPN:

@grorg
grorg / gist:6732841
Last active November 30, 2018 18:52
Why does animating left paint more often than translateX?
As asked by John on Twitter: https://twitter.com/johnallsopp/status/383461909640384512
"wow. Animate change to left via CSS, ~500 paint/reflow events. Animate translateX - 16!"
Answering here because it's a long response and I'm too slack to have a
blog/tumble/plus/facebook/myspace.
NOTE: This answer is out of date. See comment below.
The easy answer is that changing left causes relayout, which triggers a repaint, while
@lukhnos
lukhnos / pbkdf2test.c
Created July 19, 2012 05:25
An example of using CommonCrypto's PBKDF2 function
// an example of using CommonCrypto's PBKDF2 function
//
// build with:
//
// clang -o pbkdf2test pbkdf2test.c
//
// test with:
//
// ./pbkdf2test <some plaintext password here>
//
// main.swift
// OptionParser
//
// Created by Chris Eidhof on 28.02.19.
// Copyright © 2019 objc.io. All rights reserved.
//
import Foundation