Skip to content

Instantly share code, notes, and snippets.

View narfdotpl's full-sized avatar

Maciej Konieczny aka narf narfdotpl

View GitHub Profile
@narfdotpl
narfdotpl / Python: while True
Created March 11, 2010 18:07
Python infinite loop bytecode
~ $ python
Python 2.6.4 (r264:75821M, Oct 27 2009, 19:48:32)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from dis import dis
>>> def wT():
... while True:
... pass
...
>>> dis(wT)
@narfdotpl
narfdotpl / edit.html.haml
Created May 4, 2010 11:13
ror: "/profile" instead of "/users/1/edit"
%h1 edit your profile
- form_for @user, :url => {:action => :update} do |form|
%div= form.text_field :name
= error_message_on @user, :name, 'name '
%div= submit_tag 'save'
@narfdotpl
narfdotpl / postactivate
Created August 8, 2010 09:12
~/.virtualenvs/postactivate
#!/bin/zsh
# This hook is run after every virtualenv is activated.
# prefix prompt with... umm... pink, I think? name of virtualenv
PS1=$'%{\e[0;35m%}$(basename $VIRTUAL_ENV)%{\e[0m%} '$_OLD_VIRTUAL_PS1
Python 2.7 (r27:82500, Jul 6 2010, 21:27:24)
[GCC 4.2.1 (Apple Inc. build 5659)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> s = 'foo'
>>> s is s.lower()
False
>>> s is s.replace('a', 'b')
True
>>> s is s.replace('o', 'o')
False
@narfdotpl
narfdotpl / dnoodles.f
Created October 21, 2010 20:17
Demonic Noodles
* Demonic Noodles
*
* Author: Maciej Konieczny <[email protected]>
* Website: http://gist.github.com/639250
* License: public domain <http://unlicense.org/>
* Background: My first Fortran program; written as a Programming
* Paradigms assignment. We were supposed to generate
* a creature picture in Fortran 77.
@narfdotpl
narfdotpl / rs.zsh
Created November 20, 2010 22:33
copy to clipboard links to rars hosted at rapidshare found at given url
# copy to clipboard links to rars hosted at rapidshare found at given url
rs() {
curl $1 2> /dev/null | grep -Po 'http://rapidshare.com/.*?rar' | pbcopy
}
@narfdotpl
narfdotpl / mysqldb.markdown
Created December 4, 2010 16:01
MySQLdb, Python 2.5 and OS X 10.6

MySQLdb, Python 2.5 and OS X 10.6

I wasted too much time trying to make MySQLdb work with Python 2.5 (mysteriously it worked fine with 2.7). I thought I'll share my experience.

I installed MySQLdb normally with pip install MySQL-python (yeah, ingenious name) and there were no problems. But every time I imported it, I got following error:

@narfdotpl
narfdotpl / gist:860606
Created March 8, 2011 17:26
fix plotting in Octave.app

To fix plotting in Octave.app in latest Snow Leopard (10.6.6 at the moment of writing) change /Applications/Gnuplot.app/Contents/Resources/bin/gnuplot as follows:

@@ -31,7 +31,7 @@ ROOT=`(cd "${BASE}" 2>/dev/null && pwd)`
 # startup the Gnuplot program.
 GNUPLOT_HOME="${ROOT}"
 PATH="${ROOT}/bin:${PATH}"
-DYLD_LIBRARY_PATH="${ROOT}/lib:${DYLD_LIBRARY_PATH}"

+DYLD_LIBRARY_PATH="${ROOT}/lib"

@narfdotpl
narfdotpl / gist:995048
Created May 27, 2011 11:10
mysql unicode ffs
-- mysql unicode ffs
DROP DATABASE foo;
CREATE DATABASE foo CHARACTER SET utf8 COLLATE utf8_general_ci;
@narfdotpl
narfdotpl / fix-it-fix-it
Created June 18, 2011 13:01
fix iTunes icon
#!/usr/bin/env sh
sudo curl -L http://3.narf.pl/iTunes.icns > /Applications/iTunes.app/Contents/Resources/iTunes.icns
echo 'relog, remove itunes from dock, go to /Applications and drag it back'