Skip to content

Instantly share code, notes, and snippets.

@swillits
swillits / AGBinaryDataStream.h
Created April 26, 2017 00:42
AGBinaryStream Obj-C
//
// AGBinaryDataStream.h
// AraeliumFoundation
//
// Created by Seth Willits on 11/15/09.
// Copyright 2009 Araelium Group. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "AGBinaryStream.h"
import Foundation
import CoreGraphics
/*
Usage:
Interpolate(.linear).between(x, and: y, progress: progress) // progress is 0 to 1
*/
#!/usr/bin/ruby
# Keith Bauer made this.
require 'find'
require 'getoptlong'
EXTS = Regexp.compile('^.*\.(' + %w[
h hh hpp H
c cc cpp cxx C
m mm M
struct DataStructure {
var x: Int
var s: String
}
// Create a "convenience" namespace to separate properties and functions which we
// don't want confused with being actual properties of the original structure.
@swillits
swillits / appledev.html
Created February 11, 2017 06:11
Useful Apple Dev
<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
body {
margin: 0;
padding: 0;
background: white;
font-family: 'Helvetica Neue', Helvetica, Arial, Geneva, sans-serif;
@implementation NSWindow (Additions)
typedef NS_ENUM(NSUInteger, AGEndTextEditingOption) {
AGEndTextEditingAndClearFirstResponder = 0,
AGEndTextEditingAndMaintainFirstResponder,
};
//! Returns YES if the field editor voluntarily gives up first responder status. Also returns YES if nothing was being edited.
//! If the maintain option is used, the first responder is set to the field editor's text field.
//! Returns NO if the field didn't want to give up first responder, probably because of some validation issue. In this case, use ag_forcefullyEndTextEditing if needed.
// Using https://gist.github.com/swillits/93206997e7d1bff4d08e24e23173820e
extension AVPlayer {
private struct AssociatedKeys {
static var statusChangeHandler = "ag_statusChangeHandler"
static var statusReceptionist = "ag_statusReceptionist"
}
var statusChangeHandler: ((AVPlayerStatus) -> ())? {
class Receptionist: NSObject {
typealias KVOReceptionistBlock = (Info) -> ()
private var opQueue: OperationQueue? = nil
private var kvoHandler: KVOReceptionistBlock! = nil
private var kvoObject: NSObject! = nil
private var kvoKeyPath: String! = nil
private var kvoContext: Int? = nil
private var activeLock = QueueLock()
@swillits
swillits / .swift
Last active December 6, 2016 20:49
Swift property 'shouldSet'
// -------------------------------------
// Want to do this
// -------------------------------------
var selectable = false {
willSet {
if !newValue {
selected = false
}
@swillits
swillits / Keycodes.swift
Last active May 21, 2024 10:09
Swift Keyboard Keycodes
struct Keycode {
// Layout-independent Keys
// eg.These key codes are always the same key on all layouts.
static let returnKey : UInt16 = 0x24
static let enter : UInt16 = 0x4C
static let tab : UInt16 = 0x30
static let space : UInt16 = 0x31
static let delete : UInt16 = 0x33
static let escape : UInt16 = 0x35