Wenn man keine Ahnung hat …
Donnerstag, 2 Februar 2012
Das haben wir alle nicht kommen sehen …
Samstag, 10 Dezember 2011
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.
HowTo mock django template tag ‘now’
Donnerstag, 3 November 2011
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
Dienstag, 25 Oktober 2011
import pprint from django.db import connection ... pprint.pprint(connection.queries)
_to_the_crazy_ones
Samstag, 8 Oktober 2011
“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)
Caught Exception while rendering: Found a compiled template that is incompatible with the deprecated `django.template.loader.find_template_source` function.
Samstag, 24 September 2011
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
Montag, 5 September 2011
#
# get all the commits which have deleted files and the files deleted
git log --diff-filter=D --summary
Django Unit Tests: Mailbox Debugging
Donnerstag, 14 Juli 2011
#
# 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’
Donnerstag, 14 Juli 2011
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
Mittwoch, 13 Juli 2011
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)
debugging django unit tests
Dienstag, 21 Juni 2011
Looking for the response of a GET or POST statement?
print "[ %s ] self.response.content: %s" % (self.response.status_code, self.response.content)
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xc3 in position
Freitag, 10 Juni 2011
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
Mittwoch, 1 Juni 2011
datetime.now().strftime('%Y-%m-%d %H:%M:%S')
_motd_20110522:
Sonntag, 22 Mai 2011
"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:
Samstag, 14 Mai 2011
"Using words to describe magic is like using a screwdriver to cut roast beef." - Tom Robbins
remove multiple whitespaces in Python
Montag, 4 April 2011
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
Sonntag, 27 März 2011
schoen grusz an Heiko und Ute …
thx2dannytheman …
Schuhwichse war gestern!
Freitag, 25 Februar 2011
thx2klabusterbeere
“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
Freitag, 18 Februar 2011
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
Donnerstag, 17 Februar 2011
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
Dienstag, 18 Januar 2011
# 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
Dienstag, 18 Januar 2011
# 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
django: documentation
Mittwoch, 12 Januar 2011
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
Donnerstag, 30 Dezember 2010
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’):
print method name in Python
Donnerstag, 23 Dezember 2010
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
Dienstag, 21 Dezember 2010
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:

More details about the Django query api can be found here




















