Skip to content

Instantly share code, notes, and snippets.

# create symlink to solve missing directory on mountain lion
sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain
# install mod with brew
brew install mod_wsgi
# add this line to httpd.conf and restart apache
LoadModule wsgi_module /usr/local/Cellar/mod_wsgi/3.3/libexec/mod_wsgi.so
sudo apachectl restart
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.0</real>
<key>Green Component</key>
<real>0.0</real>
@litzomatic
litzomatic / multipleinheritance.py
Created August 1, 2012 17:39
Understanding super and multiple inheritance in Python.
class Bar(object):
def __init__(self, bar='bar', *args, **kwargs):
self.bar = bar
super(Bar, self).__init__(*args, **kwargs)
class Foo(object):
def __init__(self, foo='foo', *args, **kwargs):
self.foo = foo
super(Foo, self).__init__(*args, **kwargs)
@litzomatic
litzomatic / pass_by_value_demo.c
Created June 27, 2012 15:25
Useful ammo for any pass by value debates (Java, Python, etc)
#include <stdio.h>
#include <malloc.h>
void value_swap(int, int);
void reference_swap(int*, int*);
void memory_swap(int*, int*);
int main(int argc, char **argv)
{
int* a = malloc(sizeof(int));
Originally:
https://gist.github.com/7565976a89d5da1511ce
Hi Donald (and Martin),
Thanks for pinging me; it's nice to know Typesafe is keeping tabs on this, and I
appreciate the tone. This is a Yegge-long response, but given that you and
Martin are the two people best-situated to do anything about this, I'd rather
err on the side of giving you too much to think about. I realize I'm being very
critical of something in which you've invested a great deal (both financially
@litzomatic
litzomatic / useformatstring.py
Created May 18, 2012 20:51
Python: A bug waiting to happen.
# Oh yeah these and print anything with a __str__, right?
string_formating = 'This is not cool %s'
format_string = 'This is very cool {}'
# Wrong, wrong, wrong...
input = ('since', 'I', 'can', 'do', 'this')
print format_string.format(input)
@litzomatic
litzomatic / forgetting_self_py27_cherrypy
Created April 26, 2012 15:16
Unobvious error using Python2.7 and CherryPy
Unobvious error using Python2.7 and CherryPy
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/cherrypy/_cprequest.py", line 656, in respond
response.body = self.handler()
File "/usr/local/lib/python2.7/site-packages/cherrypy/lib/encoding.py", line 188, in __call__
self.body = self.oldhandler(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/cherrypy/_cpdispatch.py", line 34, in __call__
return self.callable(*self.args, **self.kwargs)
TypeError: logout() got multiple values for keyword argument 'page_url'
@litzomatic
litzomatic / comparing_strings_and_integers_in_python.txt
Created April 19, 2012 15:50
Python: A bug waiting to happen.
Python2 vs Python3
A bug waiting to happen.
Python2
>>> x = 1
>>> y = '234'
>>> x == y
False
A Python bug waiting to happen.
>>> x = ['1', '2', '3']
>>> x[:] = x[0]
>>> x
['1']
>>> x = ['10', '2', '3']
>>> x[:] = x[0]
>>> x
['1', '0']