Skip to content

Instantly share code, notes, and snippets.

View OneSadCookie's full-sized avatar

Keith Bauer OneSadCookie

View GitHub Profile
@OneSadCookie
OneSadCookie / edid-decode source URL
Created October 22, 2010 23:24
EDID decoding on the Mac, to find out what resolutions and rates the Mac is seeing reported.
http://cgit.freedesktop.org/xorg/app/edid-decode/plain/edid-decode.c
compile with:
gcc edid-decode.c -o edid-decode
get EDID from IORegistryExplorer (mine, an old 24" Apple Cinema Display, is attached).
Convert to binary with this command:
ruby -e 'File.open("edid", "wb").write(File.read("edid.txt").split.map { |s| ("0x"+s).to_i(16) }.inject("", "<<"))'
codesign -dvvvvvv /Applications/QuickPick.app/
Executable=/Applications/QuickPick.app/Contents/MacOS/QuickPick
Identifier=com.araeliumgroup.macappstore.quickpick
Format=bundle with Mach-O universal (i386 x86_64)
CodeDirectory v=20100 size=2168 flags=0x200(kill) hashes=101+3 location=embedded
Hash type=sha1 size=20
CDHash=5893876f1e6cbe9fa5f1abb790b515d244f931d0
Signature size=4169
Authority=Apple Mac OS Application Signing
Authority=Apple Worldwide Developer Relations Certification Authority
@OneSadCookie
OneSadCookie / gist:960764
Created May 7, 2011 19:36
Rectangle#intersects
intersects: (other) ->
((other.x >= @x &&
other.x <= @x + @width) ||
(other.x + other.width >= @x &&
other.x + other.width <= @x + @width)) &&
((other.y >= @y &&
other.y <= @y + @height) ||
(other.y + other.height >= @y &&
other.y + other.height <= @y + @height))
@OneSadCookie
OneSadCookie / gist:962092
Created May 9, 2011 05:16
coffeescript example for sam
MoveCircles: (deltaY) ->
for circle, i in circles # assuming numCires = circles.length, anyway...
do (circle) =>
if circle[1] - circle[2] > height
circle[0] = Math.random() * width
circle[2] = Math.random() * 100
circle[1] = 0 - circle[2]
circle[3] = Math.random() / 2
else
circle[1] += deltaY
@OneSadCookie
OneSadCookie / gist:1015790
Created June 9, 2011 00:37
Uglyfugly table view code
// TODO use bindings for this, once I figure out the data model...
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
{
return [[[self document] attributes] count];
}
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
assert(tableView == attributeTable);
all: stuff
stuff: stuff.c
cc $< -o $@
install: stuff
install -S $< /usr/local/bin
me:
KatieHuber> it's not particularly hard to get OpenGL into a state where it requires more VRAM *at once* than is available (eg. an 8192x8192 FP32 texture is already 1GB), try drawing one of those to an 8192x8192 FP32 framebuffer and undefined behavior will result)
<Oddity007> Who in their right mind would allocate a texture that big?
<KatieHuber> but if your total VRAM required for one draw call is less than the total VRAM available on the card, that draw call should succeed
<Oddity007> MUST HAVE MOAR PIXELZZZZ
<KatieHuber> Oddity007: well, that was an example :P
<KatieHuber> people hit it on low VRAM cards with regular old 32-bit 4096x4096 textures (64M each) reasonably regularly
<KatieHuber> I think most cards have 512 now so hitting it with 4096 textures is pretty hard these days
<TheBunny> " in their right mind "
<TheBunny> Oh you assume so much about the average coder there...
<Oddity007> lol
// clang __block_later.m -o __block_later -framework Foundation
// ./__block_later
#import <Foundation/Foundation.h>
static void (^ the_block)(void);
static void make_the_block(void)
{
__block int n = 0;
@OneSadCookie
OneSadCookie / MacOSX.supp
Created September 4, 2011 17:38
Mac suppressions
{
gleUpdateState cond
Memcheck:Cond
fun:gleUpdateState
}
{
gleUpdateLightColorChangeFunc cond
Memcheck:Cond
fun:gleUpdateLightColorChangeFunc
@OneSadCookie
OneSadCookie / blockinvoke.m
Created September 20, 2011 18:21
block hilarity
#import <objc/runtime.h>
#import <Foundation/Foundation.h>
int main()
{
Class c = [^(){} class];
BOOL ok = class_addMethod(
c,
@selector(invoke),
imp_implementationWithBlock(^(void (^self)(void)){