Skip to content

Instantly share code, notes, and snippets.

@andrewsardone
andrewsardone / ExampleTests.m
Created February 1, 2012 16:00
Fake a neighboring class method for the object in test. Stolen from https://gist.github.com/1038034 with a clearer (to me) interface and example.
#import <SenTestingKit/SenTestingKit.h>
#import "SenTestCase+MethodSwizzling.h"
#pragma mark Fakes for Tests
@interface FakeMyObject : NSObject
/**
* A fake, or "stub," implementation of MyObject's +doSomething method.
*/

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@andrewsardone
andrewsardone / gist:3740504
Created September 17, 2012 23:58
CGRectDivide

CGRectDivide is handy for slicing up a rectangle.

Example of getting a slice and the remaining area of a rectange.

CGRect rect = CGRectMake(0, 0, 240, 150);
  
CGRect remainder, slice;
    
CGRectDivide(rect, &amp;slice, &amp;remainder, 120, CGRectMinYEdge);
@ndarville
ndarville / business-models.md
Last active February 27, 2025 10:00
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@n-b
n-b / selfcompile.m
Last active April 29, 2019 03:43
A simple self-compiling objective-c file
/*/../bin/ls > /dev/null
COMPILED=${0%.*}
clang $0 -o $COMPILED -framework Foundation;
$COMPILED; rm $COMPILED; exit;
*/
#import <Foundation/Foundation.h>
int main(int argc, char *argv[])
@orta
orta / gist:6138581
Last active April 19, 2020 15:52
Objective-C Documentation discussion
TLDR
If you want the simplest option just start /** [content] */ slashes in your header files. Do it before the @implementation for class comments and above methods for method documentation.
Doing this is the minimal for support in LLVM and Appledoc, which means you get CocoaDocs & XCode support.
Not TLDR
Good examples:
https://github.com/marcransome/MRBrew/blob/master/MRBrew/MRBrew.h
https://github.com/AFNetworking/AFNetworking/blob/master/AFNetworking/AFHTTPClient.h
@mattt
mattt / UIImageForSwatchOfColorWithSize.h
Created September 27, 2013 01:25
Create a UIImage swatch of a color with a specified size.
static UIImage * UIImageForSwatchOfColorWithSize(UIColor *color, CGSize size) {
UIImage *image = nil;
CGRect rect = CGRectMake(0.0f, 0.0f, size.width, size.height);
UIGraphicsBeginImageContext(rect.size);
{
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(c, [color CGColor]);
@detro
detro / 1password.conf
Created August 10, 2015 21:19
1PasswordAnywhere + Dropbox + Upstart = 1Password for Ubuntu
description "Starts a SimpleHTTPServer to host 1 Password Anywhere"
author "Ivan De Marino <[email protected]>"
version "1.0.0"
# When to start/stop
start on runlevel [2345]
stop on runlevel [016]
# Keep it running
respawn
@CMCDragonkai
CMCDragonkai / memory_layout.md
Last active April 7, 2025 13:55
Linux: Understanding the Memory Layout of Linux Executables

Understanding the Memory Layout of Linux Executables

Required tools for playing around with memory:

  • hexdump
  • objdump
  • readelf
  • xxd
  • gcore
@kastiglione
kastiglione / beta-run.sh
Last active July 30, 2019 15:26
Build & Run iPhone simulator code outside of Xcode
#!/bin/bash
set -e
_xcrun() {
DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer \
xcrun -sdk iphonesimulator \
"$@"
}