This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView : View { | |
var body: some View { | |
Timeline() | |
} | |
} | |
// --- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Mac GUI code in Rust, testing out feasibility. April 2017. | |
fn create_window() -> id { | |
unsafe { | |
let screen = NSScreen::mainScreen(nil); | |
let window_frame = screen.visibleFrame(); | |
let window_frame = NSRect::new(NSPoint::new(window_frame.origin.x + 0.2 * window_frame.size.width, | |
window_frame.origin.y + 0.2 * window_frame.size.height), | |
NSSize::new(0.6 * window_frame.size.width, | |
0.6 * window_frame.size.height)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Unrelated Swift excerpt, circa 2017 | |
func addStrokePointForTouch(_ touch: UITouch) { | |
let loc = touch.location(in: self) | |
var radius = touch.majorRadius | |
if touch.type == .stylus { | |
radius = touch.force | |
touch.previousLocation(in: inputView) | |
} | |
let point = StrokePoint(point: loc, radius: radius) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Objective-C snippet circa 2015 | |
CMTime frameTime = CMTimeMake(timescale / self.frameRate, timescale); | |
NSUInteger frameStride = imageFilePaths.count; | |
NSUInteger maxIndex = frameStride - 1; | |
NSUInteger loopStride = frameStride * ((self.mirrorSequence) ? 2 : 1); | |
NSMutableArray *pixelBuffers = [NSMutableArray arrayWithCapacity:imageFilePaths.count]; | |
NSUInteger frameCount = loopStride * self.loopCount; | |
for (int i = 0; i < frameStride; ++i) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate bindgen; | |
use std::env; | |
use std::path::PathBuf; | |
fn main() { | |
let sdk_root = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk"; | |
let framework_root = format!("{}/System/Library/Frameworks", sdk_root); | |
let bindings = bindgen::Builder::default() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> 1. It's very slow on large, complicated layouts | |
True, but this can be mitigated by separating constraints into distinct sets, applied to subviews. Resolving a single set of constrainta on one view and its subviews is slower than resolving multiple distinct constraint sets applied to sifferent subviews as approriate. | |
> 2. Xcode's layout editor still sucks even though it's 100x better than it used to be. | |
I find it passable. How does it "suck" for you? | |
> 3. Runtime errors. No programming tool should create data that will cause runtime errors. | |
Might as well never use storyboards, or images, or data files, or… That simply isnt a reasonable position. | |
> 4. No way to diff layout changes in source code control because they're within the storyboard. Creating constraints in code is still pretty tedious, although better than it used to be. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE accesstokens2 ( | |
id integer PRIMARY KEY AUTOINCREMENT NOT NULL, | |
token text NOT NULL, | |
user_id integer NOT NULL, | |
client_id integer NOT NULL, | |
expires BIGINT NOT NULL, | |
FOREIGN KEY (user_id) REFERENCES users(id), | |
FOREIGN KEY (client_id) REFERENCES clients (id) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AccountManager { | |
static let sharedInstance:AccountManager = {() -> AccountManager in | |
var instance = AccountManager() | |
instance.restoreIfAny() | |
return instance | |
}() | |
func restoreIfAny() { | |
// deserialize saved accounts | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DocumentController: NSDocumentController { | |
@IBOutlet var toolsPanelController: NSWindowController! | |
@IBOutlet var timelinePanelController: NSWindowController! | |
@IBOutlet var layersPanelController: NSWindowController! | |
override init() { | |
super.init() | |
var topLevelObjects:NSArray? = [] | |
NSBundle.mainBundle().loadNibNamed("panels", owner: self, topLevelObjects:&topLevelObjects) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DocumentController: NSDocumentController { | |
@IBOutlet weak var toolsPanelController: NSWindowController? | |
@IBOutlet weak var timelinePanelController: NSWindowController? | |
@IBOutlet weak var layersPanelController: NSWindowController? | |
override init() { | |
super.init() | |
var topLevelObjects:NSArray? = [] | |
NSBundle.mainBundle().loadNibNamed("panels", owner: self, topLevelObjects:&topLevelObjects) |
NewerOlder