Skip to content

Instantly share code, notes, and snippets.

@PaulChana
PaulChana / ArchFromBinary.sh
Last active May 12, 2016 06:30
Get arch from binary
lipo -info /usr/lib/libiodbc.a
@PaulChana
PaulChana / LLDB Hardware Watchpoints
Created April 26, 2016 09:20
LLDB Hardware Watchpoints
watch set expression (int *)0x12345678 (or w s e (int *)0x12345678)
@PaulChana
PaulChana / functionTiming.cpp
Created April 14, 2016 08:05
Timing function C++11
#include <iostream>
#include <cmath>
#include <iomanip>
#include <chrono>
int fun(const int a, const int b, const int c) {
return a * b * c;
}
int main(int argc, const char * argv[]) {
@PaulChana
PaulChana / LLDB Printf
Last active December 1, 2016 17:21
LLDB Printf
expr (int) printf("%f %d %f %d", x, y, z, q)
@PaulChana
PaulChana / average.sh
Created February 3, 2016 16:39
Find average file size
# Thanks to http://vivekjain10.blogspot.co.uk/2008/02/average-file-size-within-directory.html
find . -type f -name *.wav -print0 | xargs -0 ls -l | awk '{sum += $5; n++;} END {print sum/(n-1)/1024/1024;}'
@PaulChana
PaulChana / UnhideLibrary
Created December 9, 2015 11:58
Unhide user library
/usr/bin/chflags nohidden ~/Library
@PaulChana
PaulChana / RelToAbs.sh
Created July 24, 2015 13:06
Relative To Abs Path in Bash using Python
the_path=$(python -c "import os,sys; print os.path.realpath(sys.argv[1])" "../../some/relative/path")
@PaulChana
PaulChana / StringToURL.m
Created July 22, 2015 20:54
NSString path to NSURL
[NSURL fileURLWithPath:nsstringPath];
@PaulChana
PaulChana / NSButtonDownDraw.m
Last active August 29, 2015 14:25
Is NSButton in down state during drawing
- (void)drawRect:(NSRect)dirtyRect {
if ([self isHighlighted]) {
// Mouse is down
}
else {
// Nope, mouse is either down and outside our area, or not down
}
}
@PaulChana
PaulChana / AutoDMG.sh
Last active July 4, 2023 21:50
Make a DMG auto open
dmg_vol_name="name"
dmg_path="/path/to/final/dmg/$dmg_vol_name.dmg" # Final DMG that you will be shipping
dmg_build_path="/path/to/temp/dmg/$dmg_vol_name.dmg" # Temporary DMG that will be worked on and then deleted
dmg_volume="/Volumes/$dmg_vol_name" # Should match the mounted name of your DMG. Be sensible and make it the name ;-P
hdiutil attach -owners on "dmg_build_path" -shadow
bless "$dmg_volume/" --openfolder "$dmg_volume" # This actually makes the change to auto open the DMG in finder
hdiutil detach "$dmg_volume"
hdiutil convert -format UDZO -o "$dmg_path" "$dmg_build_path" -shadow