Skip to content

Instantly share code, notes, and snippets.

View WayneWeiZhang's full-sized avatar

Wayne Zhang WayneWeiZhang

View GitHub Profile
@0xced
0xced / CopyLaunchedApplicationsInFrontToBackOrder.c
Created August 7, 2009 14:06
Get an array of running applications ordered by last use
#import <Carbon/Carbon.h>
#import <dlfcn.h>
/*
* Returns an array of CFDictionaryRef types, each of which contains information about one of the processes.
* The processes are ordered in front to back, i.e. in the same order they appear when typing command + tab, from left to right.
* See the ProcessInformationCopyDictionary function documentation for the keys used in the dictionaries.
* If something goes wrong, then this function returns NULL.
*/
CFArrayRef CopyLaunchedApplicationsInFrontToBackOrder(void)
static id _commonInit(MyView *self)
{
// common init stuff like so...
self.opaque = YES;
self->_scale = 1.0;
return self;
}
- initWithFrame:(CGRect)frame;
// Copyright (c) 2012-2013 Peter Steinberger (http://petersteinberger.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
@0xced
0xced / unprefixed_classes.py
Created July 10, 2012 14:16
List all unprefixed Objective-C classes for a given SDK
#!/usr/bin/env python
import argparse, os, re, subprocess
parser = argparse.ArgumentParser()
parser.add_argument('--sdk', default='', help='OS X or iOS SDK directory')
parser.add_argument('--no-frameworks', action='store_true', default=False, help='do not print frameworks, only unprefixed classes')
args = parser.parse_args()
print_frameworks = not args.no_frameworks
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@nfarina
nfarina / UIView+FrameAdditions.h
Created August 21, 2012 06:40
UIView Frame helper getter/setter category methods
#import <UIKit/UIKit.h>
@interface UIView (SMFrameAdditions)
@property (nonatomic, assign) CGPoint $origin;
@property (nonatomic, assign) CGSize $size;
@property (nonatomic, assign) CGFloat $x, $y, $width, $height; // normal rect properties
@property (nonatomic, assign) CGFloat $left, $top, $right, $bottom; // these will stretch the rect
@end
@sserye
sserye / UIImage+Retina4.h
Created September 14, 2012 03:27 — forked from bstahlhood/UIImage+Retina4.h
Swizzled UIImage imageNamed for iPhone 5
//
// UIImage+Retina4.h
// StunOMatic
//
// Created by Benjamin Stahlhood on 9/12/12.
// Copyright (c) 2012 DS Media Labs. All rights reserved.
//
#import <UIKit/UIKit.h>
@krzysztofzablocki
krzysztofzablocki / gist:4396302
Last active November 24, 2021 19:17
Set symbol breakpoint on objc_msgSend then setup this debug command to log all methods called in iOS Simulator. If you want to do device debugging change esp+4 register to r0, esp+8 to r1 Found long ago somewhere on stackoverflow.
expr -- (void)printf("[%s, %s]\n",(char *) object_getClassName(*(long*)($esp+4)), (char *) *(long *)($esp+8) )
@phughes
phughes / image.py
Last active March 5, 2023 21:58
An Xcode precompilation script to turn your images into auto-completeable, type-checkable symbols.
import os.path as path
import string
import argparse
import glob
import re
def basename(filename):
base = filename
if filename.find('@2x') > 0:
base = filename[:filename.find('@2x')]
@steipete
steipete / AppDelegate.m
Last active December 13, 2015 17:29
Hook onto NSNotificationCenter to see all notifications.
[[NSNotificationCenter defaultCenter] addObserverForName:nil object:nil queue:nil usingBlock:^(NSNotification *note) {
NSLog(@"%@: %@", note.name, note.userInfo);
}];