Skip to content

Instantly share code, notes, and snippets.

@albertz
albertz / gist:903436
Created April 5, 2011 11:24
brew pil-1.1.7.tar.gz fails
%brew install -v pil
==> Downloading http://effbot.org/downloads/Imaging-1.1.7.tar.gz
File already downloaded and cached to /Users/az/Library/Caches/Homebrew
/usr/bin/tar xf /Users/az/Library/Caches/Homebrew/pil-1.1.7.tar.gz
==> python setup.py build_ext
python setup.py build_ext
running build_ext
--- using frameworks at /System/Library/Frameworks
building '_imaging' extension
creating build
@albertz
albertz / gist:903944
Created April 5, 2011 16:29
brew portaudio fails
Last login: Tue Apr 5 16:48:19 on ttys002
az@Albert-Zeyers-MacBook-Pro 1006 (~) %brew update
remote: Counting objects: 17, done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 12 (delta 10), reused 0 (delta 0)
Unpacking objects: 100% (12/12), done.
From http://github.com/mxcl/homebrew
* branch master -> FETCH_HEAD
Updated Homebrew from b5fad2cd to 7e7d6edb.
No formulae were updated.
@albertz
albertz / gist:920050
Created April 14, 2011 17:50
Python functions
def testfunc0(): print "testfunc0"
def testfunc1(a1): print "testfunc1", a1
def testfunc2(a1,a2): print "testfunc2", a1, a2
class A:
def func0(): print "func0"
def func1(a1): print "func1", a1
def func2(a1,a2): print "func2", a1, a2
varfunc0 = testfunc0
varfunc1 = testfunc1
@albertz
albertz / gist:922622
Last active October 22, 2015 10:38
better_exchook.py output, see https://github.com/albertz/py_better_exchook
$ python better_exchook.py
EXCEPTION
Traceback (most recent call last):
File "better_exchook.py", line 478, in <module>
line: f()
locals:
f = <local> <function f at 0x107f1de60>
File "better_exchook.py", line 477, in f
line: x, 42, sys.stdin.__class__, sys.exc_info, y, z
locals:
@albertz
albertz / memoization.py
Created April 21, 2011 21:37
memoization implementation with simple limit. some thoughs [here](http://www.az2000.de/docs/memoization/)
class Entry:
def __init__(self, x, y):
self.x = x
self.y = y
self.leftEntry = None
self.rightEntry = None
def pop(self):
if self.leftEntry is not None:
self.leftEntry.rightEntry = self.rightEntry
if self.rightEntry is not None:
@albertz
albertz / gist:1206010
Created September 9, 2011 11:46
Python function name mangling
In [1]: class Test:
...: def __foo(self): pass
...:
...:
In [2]: dir(Test)
Out[2]: ['_Test__foo', '__doc__', '__module__']
In [3]: Test.__foo
---------------------------------------------------------------------------
@albertz
albertz / gist:1206172
Created September 9, 2011 13:10
fun with chrome :)
Fun with Chrome. :)
Thread 0:: CrBrowserMain Dispatch queue: com.apple.main-thread
0 com.google.Chrome.framework 0x006e9d5b ChromeMain + 6300363
1 com.google.Chrome.framework 0x0073043b ChromeMain + 6588843
2 com.google.Chrome.framework 0x0072f1da ChromeMain + 6584138
3 com.google.Chrome.framework 0x00760af2 ChromeMain + 6787170
4 com.apple.AppKit 0x9b798ff8 -[NSWindowController setWindow:] + 278
5 com.apple.CoreFoundation 0x93475901 -[NSObject performSelector:withObject:] + 65
@albertz
albertz / constr_test.cpp
Created December 9, 2011 14:59
demonstrating non-determinism of constructor execution order
//
// constr_test.cpp
//
// Created by Albert Zeyer on 08.12.11.
// Copyright (c) 2011 Albert Zeyer. All rights reserved.
//
#include <string>
#include <random>
#include <iostream>
@albertz
albertz / functor_demo.cpp
Created December 25, 2011 18:43
functions vs functors
// g++ functor_demo.cpp -c -S
// With this set to `inline`, G++ will inline both examples.
// With this empty, G++ will inline none of them.
#define OPT_INLINE inline
OPT_INLINE int f1(int) { return 42; }
template< int (*f)(int) >
void do_sth1() { f(0); }
@albertz
albertz / sdlimagetest.cpp
Created January 2, 2012 16:12
test for SDL_image
/*
g++ sdlimagetest.cpp -framework SDL -framework SDLimage -I /Library/Frameworks/SDL.framework/Headers -I /Library/Frameworks/SDLimage.framework/Headers -o sdlimagetest
*/
#include <SDL.h>
#include <SDL_image.h>
#include <assert.h>
#include <sstream>
#include <string>
#include <iostream>