Skip to content

Instantly share code, notes, and snippets.

@acoomans
acoomans / fastenum.m
Created June 16, 2015 21:16
Modern Fast enumeration
// cfr FastEnumerationSample
// https://developer.apple.com/library/mac/samplecode/FastEnumerationSample/Listings/EnumerableClass_mm.html#//apple_ref/doc/uid/DTS40009411-EnumerableClass_mm-DontLinkElementID_4
#pragma mark - NSFastEnumeration
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state
objects:(id __unsafe_unretained [])buffer
count:(NSUInteger)len {
@acoomans
acoomans / Makefile
Last active September 3, 2015 16:29
iOS simulator command line executable
sdk = /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk
all: t
%: %.m
clang \
-x objective-c \
-miphoneos-version-min=7.0 \
-arch i386 \
-fobjc-arc \
@acoomans
acoomans / hello.s
Last active August 29, 2015 14:13
x86 asm "hello"
// hello world example
// llvm/gas x86 assembly (AT&T syntax)
//
// http://cs.lmu.edu/~ray/notes/gasexamples/
// http://tigcc.ticalc.org/doc/gnuasm.html
//
// https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/LowLevelABI/Mac_OS_X_ABI_Function_Calls.pdf
//
// syscalls
// http://www.opensource.apple.com/source/xnu/xnu-2782.1.97/bsd/kern/syscalls.master
@acoomans
acoomans / hello.s
Last active August 29, 2015 14:13
ARM asm "hello"
// hello world example
// llvm ARM assembly
//
// https://developer.apple.com/library/ios/documentation/Xcode/Conceptual/iPhoneOSABIReference/iPhoneOSABIReference.pdf
// http://www.opensource.apple.com/source/xnu/xnu-2782.1.97//bsd/kern/syscalls.master
//
// void p();
.data
message:
@acoomans
acoomans / autoexec.cfg
Last active May 23, 2024 14:56
Quake 3 configuration
// for ioquake for mac, this file lives under /Applications/ioquake3/baseq3/
// $ wget https://gist.githubusercontent.com/acoomans/a0de33bc82cbb5bd1024/raw/autoexec.cfg -O $HOME/Library/Application\ Support/Quake3/baseq3/autoexec.cfg
unbindall
bind TAB "+scores"
bind ESCAPE "togglemenu"
bind ` "toggleconsole"
bind ~ "toggleconsole"
bind + "sizeup"
@acoomans
acoomans / build-clang.sh
Last active August 18, 2016 06:06
Build LLVM+Clang scripts
#!/bin/bash -e
# http://clang.llvm.org/docs/ClangTools.html
# Clang and llvm, separate directories
# Xcode project file for Clang
git clone http://llvm.org/git/llvm.git
cd llvm/projects
@acoomans
acoomans / python.md
Last active August 29, 2015 14:08
Python Cheat Sheet

Python Cheat Sheet

Code style

check with

pip install pep8
pep8 DIR

fix with

@acoomans
acoomans / git.md
Last active September 3, 2015 16:30
Git cheat sheet

Git

Author fix

rebase, mark the commit as 'edit'

amend:

git commit --amend --reset-author
@acoomans
acoomans / hmerge.py
Created August 9, 2014 23:24
Objective-C headers merge tool
#!/usr/bin/python
# Merges objc headers.
# See WARNs for limitations
import sys
import re
all_contents = [] # contents
all_scopes = dict() # definition -> content
@acoomans
acoomans / mac.txt
Last active August 29, 2015 14:02
How to calculate a MAC without leaking computation-time (side channel) info
// Everything you need to know about cryptography in 1 hour
// http://www.daemonology.net/papers/crypto1hr.pdf
for (x = i = 0; i < MACLEN; i++) {
x |= MAC_computed[i] − MAC_received[i];
}
return (x ? MAC_GOOD : MAC_BAD);