Skip to content

Instantly share code, notes, and snippets.

#import <Foundation/Foundation.h>
@interface NSMutableDictionary (ValueHolding)
- (void)setDouble:(double)number forKey:(NSString *)key;
- (double)doubleForKey:(NSString *)key;
- (void)setCGFloat:(CGFloat)number forKey:(NSString *)key;
- (CGFloat)CGFloatForKey:(NSString *)key;
@qwzybug
qwzybug / xcrun.scpt
Last active August 29, 2015 13:55
osascript xcrun.scpt <path to project> <scheme name>
on run argv
set projectPath to item 1 of argv
set projectScheme to item 2 of argv
tell application "Xcode"
open projectPath
activate
tell application "System Events"
tell application process "Xcode"
click menu item "Stop" of menu 1 of menu bar item "Product" of menu bar 1
click menu item projectScheme of menu 1 of menu item "Scheme" of menu 1 of menu bar item "Product" of menu bar 1
@qwzybug
qwzybug / gist:8360717
Created January 10, 2014 19:19
obj-c simulator register debugging
c objc lldb register
arg1 self *(int *)($ebp+8)
arg2 CMD *(int *)($ebp+12)
arg3 arg1 *(int *)($ebp+16)
arg4 arg2 *(int *)($ebp+20)
arg5 arg3 *(int *)($ebp+24)
...etc...
Sep 10 20:42:08 Eva Knock[1277] <Notice>: TestFlight: Crash Handlers are installed
Sep 10 20:42:08 Eva Knock[1277] <Warning>: -[HBBluetoothPeripheralController setupService] [Line 94] Setting up services
Sep 10 20:42:08 Eva Knock[1277] <Warning>: -[HBBluetoothPeripheralController peripheralManager:didAddService:error:] [Line 243] Error: (null)
Sep 10 20:42:08 Eva Knock[1277] <Warning>: -[HBBluetoothPeripheralController stopAdvertising] [Line 132]
Sep 10 20:42:08 Eva Knock[1277] <Warning>: -[HBBluetoothPeripheralController startAdvertising] [Line 111]
Sep 10 20:42:08 Eva Knock[1277] <Warning>: -[HBBluetoothPeripheralController peripheralManagerDidStartAdvertising:error:] [Line 238] Error: (null)
Sep 10 20:42:09 Eva Knock[1277] <Notice>: TestFlight: Started Session
Sep 10 20:42:09 Eva Knock[1277] <Notice>: TestFlight: App Token is recognized
9/10/13 8:33:29.598 PM Knock[41670]: -[HBBluetoothCoexistanceManager init] [Line 50] Opening interface: 0
9/10/13 8:33:29.598 PM Knock[41670]: -[HBBluetoothCoexistanceManager init] [Line 53] Binding interface: -3900
9/10/13 8:33:29.600 PM Knock[41670]: -[HBBluetoothCentralController isLEAvailable] [Line 150] State: 0
9/10/13 8:33:29.601 PM Knock[41670]: -[HBBluetoothCentralController isLECapableHardware] [Line 169] State: 0
9/10/13 8:33:29.601 PM Knock[41670]: -[HBBluetoothCentralController startScan] [Line 241] Couldn't start scan!
9/10/13 8:33:29.605 PM Knock[41670]: -[HBBluetoothCentralController isLEAvailable] [Line 150] State: 2
9/10/13 8:33:29.605 PM Knock[41670]: -[HBBluetoothCentralController isLECapableHardware] [Line 169] State: 2
9/10/13 8:33:29.616 PM Knock[41670]: NSAlert is being used from a background thread, which is not safe. This is probably going to crash sometimes. Break on void _NSAlertWarnUnsafeBackgroundThreadUsage() to debug. This will be logged only once. This may break in the futu
#!/usr/bin/env ruby
require 'strscan'
class SoundCloudTagParser
def self.scan string
tags, scanner = [], StringScanner.new(string)
until scanner.eos?
//
// NSObject_ShutUpNSNull.h
// Typewriter
//
// Created by Devin Chalmers on 8/16/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
# add this to PS1: \$(parse_git_branch)\$(parse_git_dirty)
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
parse_git_dirty() {
if [[ -d .git ]]; then
[[ $(git status | tail -n1) != "nothing to commit, working directory clean" ]] && echo "* "
fi
@qwzybug
qwzybug / sample1.m
Created December 9, 2011 21:18
Sample code for blog post on exploding iPhone apps.
NSMutableArray *layersToWalk = [NSMutableArray arrayWithObject:someView.layer];
while (layersToWalk.count > 0)
{
CALayer *parent = [layersToWalk objectAtIndex:0];
for (CALayer *layer in parent.sublayers)
{
CALayer *myCopy = [CALayer layer];
myCopy.bounds = layer.bounds;
myCopy.position = [self.explodedLayer convertPoint:layer.position fromLayer:layer.superlayer];
myCopy.contents = layer.contents;
-- most widely-stocked liquors
sqlite> select bottles.description, bottles.size, stocks.count from (select bottle_id, count(*) as count from stocks group by bottle_id) as stocks join bottles on (bottles.id == stocks.bottle_id) order by "count" desc limit 50;
JACK DANIELS #7 BL LABEL|750 ML|94
JACK DANIELS #7 BL LABEL|375 ML|94
JACK DANIELS #7 BL LABEL|1.75 L|94
CANADIAN CLUB|750 ML|94
SEAGRAMS V O|750 ML|94
MACNAUGHTON|750 ML|94
CANADIAN RICH & RARE|750 ML|94