MDA Tools Überblick

Wer sucht, der findet. Leider nur ein Ausschnitt aus einem relativ alten iX Artikel über MDA Tools: iX 5/2005, S. 102: Softwareentwicklung.
Sowas müsste es öfter geben, eigentlich. Mal weiter suchen …

Singleton Pattern in Python

I was looking for a smooth way to create singletons in python. Here is a metaclass solution that seems to work:

Python
1
2
3
4
5
6
7
8
class Singleton(type):
def __init__(cls,name,bases,dic):
super(Singleton,cls).__init__(name,bases,dic)
cls.instance=None
def __call__(cls,*args,**kw):
if cls.instance is None:
cls.instance=super(Singleton,cls).__call__(*args,**kw)
return cls.instance

This was originally posted by Michele Simionato as a comment on a python singleton recipe on http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/102187

You use it like this:

Python
1
2
3
class A( object ):
__metaclass__ = Singleton
# here goes the rest of you class definiton ..

But you knew that anyway, didn’t you? ;)

My first “Plugin”

As you might have noticed I’m still struggeling with my theme choice. I’ll be switching themes a lot soon but wanted to get started on integrating plugins (like, for instance, Link Indication ). Some of those require adding CSS code though. I stumbeled upon one guide on how to preserve your CSS changes througout themes HERE but that still required you to modify the template and that I did not want to do.
So I came up with this, my first, wordpress plugin. It allows you to add Custom CSS code to the “wp_head” action hook. This will basically preserve your precious CSS in the database while you can go on changing themes as you please .. at least as long as the theme author calls “the_head()” at some point, but that he (or she for that matter) should do in any case.
So now, here is a quick Copy & Paste version.

Continue reading

AWK Function

Just for the hell of it. A little awk function to find a columns id in a csv file. Quite a handy one I might add.

1
2
3
4
5
6
7
8
9
10
11
12
13
function find_column(name,    column,i) {
    column = 0;
    i = 1
while( i != NF )
{
if( $i == name )
{
       column = i;
    }
    i++
}
    return column;
}