Skip to content

Instantly share code, notes, and snippets.

zadr / tttt.swift
Last active Feb 9, 2020
terminal's tiny todo tool
View tttt.swift
// 1. copy file to $PATH somewhere
// 2. chmod a+x it
// 3. run with `tttt` or `tttt [task to track]`
// 4. check out ~/Desktop/todo.txt
#!/usr/bin/env swift
import Foundation
let dateFormatter = DateFormatter()
zadr /
Last active Jun 22, 2020
objc framework diffing for all .frameworks in xcode
set -x
set -k INTERACTIVE_COMMENTS=1 # treats everything after # as being a comment
# vars
export XCODE_RELEASE_PATH="/Applications/"
export XCODE_BETA_PATH="/Applications/"
export XCODE_FRAMEWORKS_PATH="Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks"
export OUTPUT="${HOME}/Desktop/iosapidiff"
mkdir "${OUTPUT}"
View UIBezierPath+Smoothing.swift
import UIKit
extension UIBezierPath {
// reference:
var points: [CGPoint] {
var bezierPoints = [CGPoint]()
cgPath.applyWithBlock { (element: UnsafePointer<CGPathElement>) in
if element.pointee.type != .closeSubpath {
zadr / steps.txt
Last active Feb 16, 2022
MacPorts install without root privileges
View steps.txt
# fetch MacPorts sources
curl -LO
# extract them and get into the dir
tar -jxf MacPorts-2.4.1.tar.gz
cd MacPorts-2.4.1
# configure things
## If you want MacPorts to run in a custom prefix, pass in the following arguments: --prefix=/usr/local --with-unsupported-prefix --with-applications-dir=/Applications
./configure --with-no-root-privileges --with-install-user=$USER --with-install-group=staff --silent
zadr / ??.swift
Last active Apr 26, 2017
Ternary-ish operators without an else clause
View ??.swift
infix operator ?? : Branching
precedencegroup Branching {
associativity: left
lowerThan: ComparisonPrecedence // also accounts for NilCoalescingPrecedence
/// Ternary-y operators without an else clause
/// - Parameter lhs: The Boolean value to evaluate
zadr / icons.jsx
Last active Mar 30, 2017
one-off Adobe Illustrator script to export a document with one artboard to iOS app icons
View icons.jsx
var originalDocumentSize = 1024
var folder = Folder.selectDialog();
var document = app.activeDocument;
if (document && document.artboards[0]) {
// Icons for Universal Apps;
scaleArtboardAndSave((512 / originalDocumentSize) * 100);
View A.h
@interface WObject : NSObject <NSCopying, NSSecureCoding>
+ (instancetype) objectWithJSONRepresentation:(NSDictionary *) JSONRepresentation;
+ (instancetype) objectWithJSONRepresentation:(NSDictionary *) JSONRepresentation excludingKeys:(NSArray *__nullable) keys;
+ (NSString *__nullable) replacementKeyForKey:(NSString *__nonnull) key;
+ (NSFormatter *__nullable) formatterForKey:(NSString *__nonnull) key;
+ (NSValueTransformer *__nullable) transformerForKey:(NSString *__nonnull) key;
View Demo.m
@interface NSUserDefaults (idk)
@property (nonatomic, copy) NSString *jam;
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
[NSUserDefaults standardUserDefaults].jam = @"strawberry";
NSLog(@"%@", [NSUserDefaults standardUserDefaults].jam);
zadr / CV.m
Created Mar 8, 2017
UIImage from CMSampleBuffer
View CV.m
#import <CoreMedia/CoreMedia.h>
#import <CoreVideo/CoreVideo.h>
#import <UIKit/UIKit.h>
+ (UIImage * _Nullable)imageWithSampleBuffer:(CMSampleBufferRef _Nonnull)sampleBuffer {
UIImage *returnValue = nil;
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
CVPixelBufferLockBaseAddress(imageBuffer, 0); {
View beep.swift
fileprivate protocol SectionData {
static func numberOfRows(expanded: Bool) -> Int
func cell(from tableView: UITableView) -> UITableViewCell
fileprivate enum Section: Int {
case x
case y