Skip to content

Instantly share code, notes, and snippets.

@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);
@acoomans
acoomans / chspecs.sh
Created May 1, 2014 15:21
Change Xcode build specs by merging OSX's specs in iPhone Simulator's specs
#!/bin/bash
# Change Xcode build specs by merging OSX's specs in iPhone Simulator's specs
# This allows to build dynamic libraries for the simulator
PLISTBUDDY="/usr/libexec/PlistBuddy"
ROOT=`xcode-select -print-path`
SIM_SPECS_DIR="$ROOT/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/Specifications"
OSX_SPECS_DIR="$ROOT/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifications"
@acoomans
acoomans / macrostr.h
Last active August 29, 2015 13:57
C Pre-processor macro Stringification
// http://gcc.gnu.org/onlinedocs/cpp/Stringification.html
#define xstr(s) str(s)
#define str(s) #s
@acoomans
acoomans / swizzling.m
Created February 2, 2014 04:18
Objective-C Method Swizzling
// source: https://www.mikeash.com/pyblog/friday-qa-2010-01-29-method-replacement-for-fun-and-profit.html
#import <objc/runtime.h>
void __attribute__((weak)) MethodSwizzle(Class c, SEL origSEL, SEL overrideSEL) {
Method origMethod = class_getInstanceMethod(c, origSEL);
Method overrideMethod = class_getInstanceMethod(c, overrideSEL);
if (class_addMethod(c, origSEL, method_getImplementation(overrideMethod), method_getTypeEncoding(overrideMethod))) {
class_replaceMethod(c, overrideSEL, method_getImplementation(origMethod), method_getTypeEncoding(origMethod));
} else {
@acoomans
acoomans / 360.rb
Last active December 30, 2015 02:19
CapitalOne 360 cafe login script
# 360 script
# This script (re)login automatically on the wifi of CapitalOne 360 cafe in San Francisco
# created by: unknown
# adapted by: acoomans
require 'net/http'
require 'uri'
puts "<" * 80
@acoomans
acoomans / fb.h
Created November 21, 2013 23:55
Headers of Facebook's internal frameworks: FBUIKit, FBBase, FBAppKit, FBFoundation
/** FBUIKit */
@interface UIImageView (FBUIKit)
+ (id)imageViewWithImageNamed:(id)arg1;
@end
@interface UITableView (FBUIKit)
- (id)indexPathForLastRowInSection:(int)arg1;
- (id)indexPathForLastRow;
@end