Skip to content

Instantly share code, notes, and snippets.

View TimOliver's full-sized avatar
😆
Out for a byte. Back in a bit.

Tim Oliver TimOliver

😆
Out for a byte. Back in a bit.
View GitHub Profile
@TimOliver
TimOliver / libdsm-build-macos.sh
Last active March 28, 2019 04:00
A modified version of the libdsm build script for macOS
#!/bin/bash
# Global build settings
export SDKPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
export MIN_MACOS_VERSION=10.10
export HOST=x86_64-apple-darwin
export LDFLAGS_NATIVE="-isysroot $SDKPATH"
export TASN1_CFLAGS="-Ilibtasn1/include"
export TASN1_LIBS="-Llibtasn1 -ltasn1"
export ARCH="x86_64"
@TimOliver
TimOliver / CopyRealmFileToLibrary.swift
Last active February 28, 2017 05:24
A quick code snippet showing how to make an already-created Realm file private
let fileManager = FileManager.default
var configuration = Realm.Configuration()
let defaultRealmURL = configuration.fileURL!
// Get the path to the Library directory and append 'default.realm' to it
let libraryDirectoryPath = NSSearchPathForDirectoriesInDomains(.libraryDirectory, .userDomainMask, true).first!
let libraryDirectoryURL = URL(fileURLWithPath: libraryDirectoryPath)
let newRealmURL = libraryDirectoryURL.appendingPathComponent(defaultRealmURL.lastPathComponent)
// There is a user-created default.realm in the Documents directory
######################
# Build Script for
# Producing a fat
# Cocoa framework binary
######################
PROJECT_NAME="MyAppExample"
SCHEME_NAME="MyAppFramework"
FRAMEWORK_NAME="MyApp"
BUILD_DIR="Builds"
@TimOliver
TimOliver / TrackingDocumentIDs.m
Created September 29, 2019 03:50
The necessary code to set up access to the document identifier of files in the iOS file system
#import <sys/stat.h>
chflags(filePath.UTF8String, UF_TRACKED);
NSURL *url = [NSURL fileURLWithPath:filePath];
id value = nil;
[url getResourceValue:&value forKey:NSURLDocumentIdentifierKey error:nil];
NSLog(@"%@", value);
@TimOliver
TimOliver / String+FilePathSort.swift
Created May 4, 2020 13:20
An algorithm I wrote to sort a list of file paths in varying levels of directories into ascending order
extension String {
/// Compares the current string value as a file path against a second
/// file path string in order to determine which comes first.
///
/// Rules:
/// * Item names are only compared if they are in the same directory
/// * Items in higher parent directories always take priority
/// * Files prefixed with "_" are automatically downgraded (Since files prefixed like that are usually ads)
///