_white_and_nerdy

Wenn man keine Ahnung hat …

 

… einfach mal die Kresse halten.

 

 

thx2klabusterbeere

 

_use_somebody

_move

MOVE from Rick Mereki

_xmas_song

thx2dg

Das haben wir alle nicht kommen sehen …

Ein lesenswerter Artikel von Frank Rieger in dessen Blog zum Thema: “Zu einer neuen rechtskonservativ-nationalen Partei – die Gerüchtelage”. Das derzeitig diskutierte Verbot der NPD wird sicherlich seinen Beitrag hin zur Neo-Nationalen Partei leisten. Die Argumentation in dem Artikel bezüglich des Kopierers läßt sich auch nachvollziehen. Fast täglich kann der aufmerksame Leser/Höhrer/Zuschauer Fragmente dieses “sich wieder ins Gespräch” Bringens in der uns täglich beschallenden Propaganda den Medien finden.

_fuer die Freunde der nicht-euklidischen Geometrie

mensch vs. matratze

thx2dg

 

_facebook

HowTo mock django template tag ‘now’

Sometimes it might be necessary to mock the return value of the django template tag ‘now’ which returns the current date (especially the value of ‘datetime.now()’ in the given format). Anyway the unit test might expect to see a specific (fixed) date which is even not at runtime of the unit test the current date. In such a case it is easy to fake the returned value of the django template tag ‘now’ (formatted ‘datetime.now()’). This can be done by usage of the mock library in the following w

from django.test import TestCase
from mock import patch

class TestFooBar(TestCase):
	def test_foo_bar(self):
		with patch.object(NowNode, 'render') as _now:
			_now.return_value = datetime(2011, 11, 11)
			# some really important action which needs to be tested ...

debugging django SQL queries

import pprint
from django.db import connection
...
pprint.pprint(connection.queries)

_to_the_crazy_ones

“Here’s to the crazy ones. The misfits. The rebels. The troublemakers. The round pegs in the square holes. The ones who see things differently. They’re not fond of rules. And they have no respect for the status quo. You can quote them, disagree with them, glorify or vilify them. About the only thing you can’t do is ignore them. Because they change things. They invent. They imagine. They heal. They explore. They create. They inspire. They push the human race forward. Maybe they have to be crazy. How else can you stare at an empty canvas and see a work of art? Or sit in silence and hear a song that’s never been written? Or gaze at a red planet and see a laboratory on wheels? We make tools for these kinds of people. While some see them as the crazy ones, we see genius. Because the people who are crazy enough to think they can change the world, are the ones who do.”

Steve Jobs (1955-2011)

… neulich auf Malle

Fehlersuchbild

Fehlersuchbild

_believe_in_your_fucking_self!

thx2jw

Caught Exception while rendering: Found a compiled template that is incompatible with the deprecated `django.template.loader.find_template_source` function.

versions in use: django: 1.3.1, satchmo: 0.9.1
error_message:
Caught Exception while rendering: Found a compiled template that is incompatible with the
deprecated `django.template.loader.find_template_source` function.
fix:
The error comes from the application 'app_plugins' which uses the deprecated
`django.template.loader.find_template_source` function in its defined template tags.
Use `django.template.loader.find_template` instead.
Another nice to know - who is calling this function?

import inspect
print "who_called_this_function: ", inspect.stack()[2][3]

_git: show commits which have deleted files


#
# get all the commits which have deleted files and the files deleted
git log --diff-filter=D --summary

_family_decals

bash command line calculator

reminder …

echo "19601 - 49" | bc

git blame on deleted files

git blame eacd7~1 — scripts/old_deleted_file.py

_musik_fuer_beide_ohren_no.10:

_the_entire_day_in_just_one_photo

beautiful idea - thx2jw

_girlz_are_evil

thx2nk

 

make everything ok

http://make-everything-ok.com/

Django Unit Tests: Mailbox Debugging


#
# snippet to print the content of the outbox ...
#
from django.core import mail
from django.utils.encoding import smart_str
...
for msg in mail.outbox:
....print "msg_subject: ", msg.subject
....print "msg_body: ", smart_str(msg.body)

`msgid’ and `msgstr’ entries do not both end with ‘\n’

During an i18n task using django compilemessages the message:

`msgid' and `msgstr' entries do not both end with '\n'

hold me stubbornly off to keep on working …

It disappears when the exact same number of new lines is used in each corresponding message string.

smart_str is your friend

Hopping mad with error messages like this?:

UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6'

The Django framework provides a comfortable method to deal with such strings:

from django.utils.encoding import smart_str
...
print smart_str(foobar)

_musik_fuer_beide_ohren_no.9:

… neulich bei IKEA

thx2dg

 

liu bolin: the invisible man

thx2dg

debugging django unit tests

Looking for the response of a GET or POST statement?

 print "[ %s ] self.response.content: %s" % (self.response.status_code, self.response.content)

_musik_fuer_beide_ohren_no.8:

thx2dg

UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xc3 in position

 

Coding in Python and going mad by this error message?

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position

Just fix the encoding:

foo.encode('utf-8')

 

print Python datetime into SQL format

datetime.now().strftime('%Y-%m-%d %H:%M:%S')

… neulich in Nürnberg

Blaue Nacht in Nürnberg :)




_motd_20110522:

"After a time, you may find that having is not so pleasing a thing,  after all, as wanting.
It is not logical, but it is often true." --Spock in 'Amok Time'

_motd_20110514:

"Using words to describe magic is like using a screwdriver to cut roast beef." - Tom Robbins

remove multiple whitespaces in Python

just beautiful …

# remove leading and trailing whitespaces and
# substitude multiple whitespaces by one (foo is a string)
" ".join(foo.split())

8 Regeln für den totalen Stillstand in Unternehmen

schoen grusz an Heiko und Ute …

thx2dannytheman …

_musik_fuer_beide_ohren_no.7: K.I.Z.

thx2reza

The crisis of credit

nice visualization – thx2acai.branco

_musik_fuer_beide_ ohren.no.6:

heute: japanischer schlager

marketing

thx2acai.branco

Five Mullah Facepalm

thx2mo

Schuhwichse war gestern!

thx2klabusterbeere

den Gutenberg machen

“den Guttenberg machen” wird wohl genauso Einzug in die deutsche Sprache halten wie “den Effenberger zeigen” … mal sehen ob der Jura Student mit dem ersten Staatsexamen (mehr hat Herr Guttenberg naemlich nicht ohne seinen Doktortitel) trotzdem von der Springerpresse zum Kanzler gejubelt wird … shoppkuetteln …

 

print multipage PDF poster

PosteRazor is a really cool tool to print a poster which is tiled in several A4 pdf pages. This pretty cool open source tool allows the user to configure several parameters like overlapping, number of tiles and some more under Linux. MacOSX, Wintendo and others. It is very easy to handle to create multipage PDF documents.

repository has at least one unnamed head

When you try to convert an mercurial repository into git the error message:

"Error: repository has at least one unnamed head: hg r1234" might occur.

The fast-export tool works fine and does not care about this "error" anymore and let you continue the export if you use its "--force" option.

macosx: howto mount nfs share from virtualbox to macosx

# The following command can be used to mount the nfs share from a virtualbox (running debian) to the local folder ‘nfs’ on MacOSX
sudo mount -t nfs -o hard,intr -o -P 192.168.2.102:/home/user_name /Users/user_name/nfs/

# The option -P acts as synonym for resvport
http://www.manpagez.com/man/8/mount_nfs/

# on the virtual machine the nfs is exported in the following way:
/home/user_name/ 192.168.2.0/255.255.255.0(rw,async,insecure)

macosx: howto show hidden files and directories

# use the following command to show all hidden files and directories in ‘Finder’ (tested on MacOSX 10.6.6):

defaults write com.apple.finder AppleShowAllFiles 1

# restart the Finder application

killall Finder

# to hide files again use:

defaults write com.apple.finder AppleShowAllFiles 0
killall Finder

FNORD NEWS Jahresrückblick 2010

django: documentation

I deposit a copy of Djangos framework documentation for quick (and offline) access here.
This documentation comes with django's sources and has to be generated. The latexpdf version of
Django 1.2.4 contains topics like "Howtos", "FAQs", "API Reference", "Getting started" on 944(!!!)
pages and is definitely worth to explore. An online version of the documentation is provided here.

django: tinymce and filebrowser

May be this hint save somebody some time … The current versions von django-filebrowser (2010-06-02: FileBrowser 3.1) and django-tinymce (django-tinymce-1.5.1.dev101 ) do not really fit because of a reverse reference in tinymce/views.py which can not be resolved anymore. The url name in filebrowser/urls.py is not ‘filebrowser-index’ anymore, it is: ‘fb_browse’.
The phenomenon is that the button of the filebrowser is shown, but nothing happens when the button is pressed. No error message – nothing. This is is hard to find especiallly for a newbie. So the following change can operate as workaround (snippet from ‘tinymce/views.py’):

xmas

thx2sh :)

print method name in Python

This snippet can be used to print out the name of the current method in Python (e.g. for debugging reasons):

print "[ %s ]" % sys._getframe().f_code.co_name

django: variable filter for queries

Sometimes it is needed or wanted do define a filter which is not known until runtime. This example may be part of a view method which checks the request.GET and creates a filter (normal python dictionary) depending on the values which have been found in the GET request. The GET request is expected to contain several booleann fields which define the search criteria for the query filter:

dynamic query filter for django

More details about the Django query api can be found here

pixels

Pixels from Passion Pictures on Vimeo.