Skip to content

Instantly share code, notes, and snippets.

View zobkiw's full-sized avatar

Joe Zobkiw zobkiw

View GitHub Profile
import lldb
import commands
def __lldb_init_module (debugger, dict):
debugger.HandleCommand('command script add -f LBRShortcut.window_description_command window_description')
debugger.HandleCommand('command script add -f LBRShortcut.json_data_command json_data')
debugger.HandleCommand('command script add -f LBRShortcut.fire_fault_command fire_fault')
def window_description_command(debbuger, command, result, dict):
@chockenberry
chockenberry / gist:11056920
Last active October 22, 2020 19:23
NSFont+SystemFont
//
// NSFont+SystemFont.h
// xScope
//
// Created by Craig Hockenberry on 4/17/14.
//
// Thanks to http://nshipster.com/method-swizzling/
#import <Cocoa/Cocoa.h>
@alexrrouse
alexrrouse / NSAttributedString+RZExtensions.h
Last active August 29, 2015 13:56
An Extension on NSAttributedString to allow for easier creation.
//
// NSAttributedString+RZExtensions.h
// Raizlabs
//
// Created by Alex Rouse on 12/13/13.
// Copyright 2014 Raizlabs and other contributors
// http://raizlabs.com/
//
// Permission is hereby granted, free of charge, to any person obtaining
@rickfillion
rickfillion / pre-commit-xcode5xib-check
Created October 25, 2013 17:33
git pre-commit hook for stopping you from commiting xibs that are in the new Xcode5 format that won't load in Xcode4. Surely there's a better way to find xibs that are in the new format than this, but it seems to work so far. To use: Save as .git/hooks/pre-commit.
#!/bin/sh
#
# Pre-Commit Hook that checks for Xcode5 format XIB files as they won't be
# openable in Xcode4
# Redirect output to stderr.
exec 1>&2
xcode5xibs=`find . -name *.xib -exec grep "<document.*type=\"com.apple.InterfaceBuilder3.Cocoa.XIB\"" {} + | sed -e 's/:.*//'`
@baphillips
baphillips / iOS-7-boundingRectWithSize-options-attributes-context.m
Last active July 26, 2018 15:26
iOS 7 dynamic UILabel frame adjustment for a given NSString and UIFont using boundingRectWithSize:options:attributes:context:.
NSString* string = @"Hello World";
UIFont *font = [UIFont fontWithName:@"Helvetica-BoldOblique" size:21];
CGSize constraint = CGSizeMake(300,NSUIntegerMax);
NSDictionary *attributes = @{NSFontAttributeName: font};
CGRect rect = [string boundingRectWithSize:constraint
options:(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading)
@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active March 10, 2024 19:23
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>
@ttscoff
ttscoff / itunesicon.rb
Last active January 13, 2022 10:07
Retrieve a 512 x 512px icon for an iOS app
#!/usr/bin/ruby
# encoding: utf-8
#
# Updated 2017-10-25:
# - Defaults to large size (512)
# - If ImageMagick is installed:
# - rounds the corners (copped from @bradjasper, https://github.com/bradjasper/Download-iTunes-Icon/blob/master/itunesicon.rb)
# - replace original with rounded version, converting to png if necessary
#
# Retrieve an iOS app icon at the highest available resolution
@hfossli-agens
hfossli-agens / gist:4676773
Created January 30, 2013 20:45
dispatch_after with repeat / loop
static void dispatch_repeated_internal(dispatch_time_t firstPopTime, double intervalInSeconds, dispatch_queue_t queue, void(^work)(BOOL *stop))
{
__block BOOL shouldStop = NO;
dispatch_time_t nextPopTime = dispatch_time(firstPopTime, (int64_t)(intervalInSeconds * NSEC_PER_SEC));
dispatch_after(nextPopTime, queue, ^{
work(&shouldStop);
if(!shouldStop)
{
dispatch_repeated_internal(nextPopTime, intervalInSeconds, queue, work);
}
@jboner
jboner / latency.txt
Last active May 24, 2024 16:18
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@zwaldowski
zwaldowski / NSObject+Blocks.h
Created May 4, 2011 12:08
Perform blocks with delays and cancellation
//
// NSObject+Blocks.h
// Filemator
//
// Created by Zachary Waldowski on 4/12/11.
// Copyright 2011 Dizzy Technology. All rights reserved.
//
@interface NSObject (Blocks)