Author: Chris Lattner
| 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 |
| 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 |
This grammar allows you to parse command lines for program execution into their various components - specifically: environment variables, the executable itself and any arguments passed to the executable.
It will take an input like the following:
ENV_X=true ENV_Y="yes please" ./test/my_exec arg1 -f1 "arg with spaces" 'another arg' --flag2 yet\ another\ arg --flag=10| 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 |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <!-- iOS 10, macOS Sierra, and friends bring a new logging subsystem that's | |
| supposed to scale from the kernel, up to frameworks, and up to apps. It defaults | |
| to a more regimented, privacy-focused approach that large apps and complex | |
| systems need. | |
| It, along with Activity Tracing introduced in iOS 8 and macOS Yosemite and the | |
| Console app in macOS Sierra, hope to help you graduate from caveman debugging to |
| // | |
| // Activity.swift | |
| // | |
| // Created by Zachary Waldowski on 8/21/16. | |
| // Copyright © 2016 Zachary Waldowski. Licensed under MIT. | |
| // | |
| import os.activity | |
| private final class LegacyActivityContext { |
State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?
There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.
Here I present a composable pattern for pure state machiness with effects,