Skip to content

Instantly share code, notes, and snippets.

@humblehacker
humblehacker / version.rb
Created September 27, 2012 16:23
Ruby script to update version numbers in iOS projects
#!/usr/bin/env ruby
$: << File.expand_path(File.dirname(File.realpath(__FILE__)) + './../lib')
require 'gli'
require 'version'
require 'versionomy'
include GLI::App
#version Version::VERSION
==> MachTimer.h <==
//
// MachTimer
// Tout
//
// Code sourced from http://zpasternack.org/high-resolution-timing-in-cocoa/
//
#import <Foundation/Foundation.h>
#include <mach/mach_time.h>
@humblehacker
humblehacker / dot.py
Created March 20, 2015 23:06
LLDB python script to render TKStateMachines
#!/usr/bin/python
#----------------------------------------------------------------------
# Be sure to add the python path that points to the LLDB shared library.
#
# # To use this in the embedded python interpreter using "lldb" just
# import it with the full path using the "command script import"
# command
# (lldb) command script import /path/to/dot.py
#----------------------------------------------------------------------
@humblehacker
humblehacker / wish.m
Created May 24, 2016 16:00
Variable declaration of concrete class and protocol conformance
UIViewController<SomeProtocol> *vc = ...;
/** I wish I could do this in Swift.
let vc: UIViewController, SomeProtocol = ...
*/
@humblehacker
humblehacker / CVPixelBufferDeepCopy.swift
Last active February 13, 2022 20:35
Creates a deep copy of a CVPixelBuffer. Compatible with Swift 2.3.
extension CVPixelBuffer
{
/// Deep copy a CVPixelBuffer:
/// http://stackoverflow.com/questions/38335365/pulling-data-from-a-cmsamplebuffer-in-order-to-create-a-deep-copy
func copy() -> CVPixelBuffer
{
precondition(CFGetTypeID(self) == CVPixelBufferGetTypeID(), "copy() cannot be called on a non-CVPixelBuffer")
var _copy: CVPixelBuffer?
// Based on https://github.com/T-Pham/NoOptionalInterpolation
import Foundation
public
protocol Unwrappable
{
func unwrap() -> Any?
}
@humblehacker
humblehacker / Sequence_associateBy.swift
Created June 27, 2017 23:11
Swift 3 implementation of Kotlin's associateBy for transforming a Sequence to a Dictionary
public
extension Sequence
{
/// Returns a Dictionary using the result of `keySelector` as the key, and the result of `valueTransform` as the value
public func associateBy<T, K: Hashable, V>(_ keySelector: (T) -> K, _ valueTransform: (T) -> V) -> [K:V] where T == Iterator.Element
{
var dict: [K:V] = [:]
for element in self {
dict[keySelector(element)] = valueTransform(element)
}
@humblehacker
humblehacker / mutablelivedata.md
Last active October 4, 2024 19:17
Don't expose MutableLiveData
@humblehacker
humblehacker / KeychainItem.swift
Last active September 28, 2019 22:27
Chris Eidhof's KeychainItem property wrapper made generic
//
// KeychainItem.swift
//
// Created by David Whetstone on 9/28/19.
//
// Original code by Chris Eidhof
// https://github.com/objcio/keychain-item
// As yet unlicensed
@humblehacker
humblehacker / George
Created November 12, 2019 23:25
George holder
george