#!/usr/bin/swift sh | |
import Foundation | |
import PromiseKit // @mxcl ~> 6.5 | |
import Swifter // @mattdonnelly == b27a89 | |
let swifter = Swifter( | |
consumerKey: "FILL", | |
consumerSecret: "ME", | |
oauthToken: "IN", | |
oauthTokenSecret: "https://developer.twitter.com/en/docs/basics/apps/overview.html" |
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.
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:
import Darwin | |
@dynamicMemberLookup | |
struct Environment { | |
subscript(dynamicMember name: String) -> String? { | |
get { | |
guard let value = getenv(name) else { return nil } | |
return String(validatingUTF8: value) | |
} |
The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).
My take-aways are:
-
You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.
-
Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

import Foundation | |
let size = MemoryLayout<Int16>.stride | |
let data = Data(bytes: [1, 0, 2, 0, 3, 0]) // little endian for 16-bit values | |
let int16s = data.withUnsafeBytes { (bytes: UnsafePointer<Int16>) in | |
Array(UnsafeBufferPointer(start: bytes, count: data.count / size)) | |
} | |
let length = data.count * MemoryLayout<Int16>.stride |
Author: Chris Lattner
import numpy as np | |
import matplotlib.pyplot as plt | |
from mpl_toolkits.mplot3d import Axes3D | |
from transforms3d import euler | |
fig = plt.figure() | |
ax = fig.gca(projection='3d') | |
p1 = np.zeros((3, 100)) | |
p1[0, :] = np.linspace(1, 3, 100) |
// | |
// Channel.swift | |
// Sessions | |
// | |
// Created by Robert Widmann on 2/27/17. | |
// Copyright © 2017 TypeLift. All rights reserved. | |
// | |
enum FakeError : Error { | |
case Error |