Skip to content

Instantly share code, notes, and snippets.

View goonzoid's full-sized avatar
🎛️

Will Pragnell goonzoid

🎛️
View GitHub Profile
@pbrisbin
pbrisbin / input.rb
Last active December 15, 2015 10:19
Hide/capture input
class InputReader
def initialize
@thread = Thread.new do
check_input
end
end
def check_input
$stdin.each_line do |line|
process_input(line.chomp)
anonymous
anonymous / gist:4984847
Created February 19, 2013 10:51
Getting separate buffers of float data from CoreAudio
// Setup the output asbd
_outputFormat.mFormatID = kAudioFormatLinearPCM;
_outputFormat.mFormatFlags = kAudioFormatFlagsAudioUnitCanonical; // kAudioFormatFlagIsFloat | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked | kAudioFormatFlagIsNonInterleaved
_outputFormat.mSampleRate = inFormat.mSampleRate;
_outputFormat.mChannelsPerFrame = inFormat.mChannelsPerFrame;
_outputFormat.mFramesPerPacket = 1;
_outputFormat.mBytesPerFrame = 4;
_outputFormat.mBytesPerPacket = 4;
_outputFormat.mBitsPerChannel = 32;
@steipete
steipete / gist:3713233
Created September 13, 2012 09:39
I often use dispatch queues for locking, and this function just makes life SO MUCH EASIER. Accidental deadlocks in more complex code paths are a PITA otherwise. But Apple deprecated dispatch_get_current_queue with iOS6?
nline void pspdf_dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_block_t block) {
dispatch_get_current_queue() == queue ? block() : dispatch_sync(queue, block);
}
@danielctull
danielctull / ThreadedManagedObjectContext.h
Created July 25, 2012 14:04
NSManagedObjectContext for iOS 4. Maybe?
/*
ThreadedManagedObjectContext.h
ThreadedManagedObjectContext
Created by Daniel Tull on 25.07.2012.
Copyright (c) 2012 Daniel Tull. All rights reserved.
@alloy
alloy / Instructions.md
Created June 28, 2012 12:56
Run iOS unit tests (in a Xcode workspace) when a file changes and *only* those tests related to the changed file. Also trims otest output and colors test results.
@jboner
jboner / latency.txt
Last active April 25, 2024 11:20
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@0xced
0xced / Makefile
Created March 23, 2012 15:02
Experiment ->isa vs object_getClass()
OPTIONS = metaclass.m -o metaclass -std=c99 -framework Foundation -arch x86_64 -Os
isa:
clang -DUSE_ISA=1 $(OPTIONS)
./metaclass
object_getClass:
clang -DUSE_ISA=0 $(OPTIONS)
./metaclass
@jdelStrother
jdelStrother / git-autofix
Created June 23, 2011 13:42
Auto-fixup a previous git commit with the changes from your staging area
#!/bin/sh
# Auto-applies changes from the index to a previous commit
# eg
# git add foo
# git autofix HEAD~3
#!/bin/sh
target="$(git rev-parse $1)"