November 22, 2006 at 6:54 pm
by Wolfram · Filed under MySQL, Programming
MySQL told me that it had a problem renaming a file. So I really thought I would go and help it by removing the file on the command line. But somehow I really felt that it didn’t really mean to rename a file. So I did a bit of googling and in the mysql bug tracker I found the problem.
The real problem occurs when you are using foreign key constraints with InnoDB. Even though I had only created an additional unique index on one of two columns where one of them was a foreign key. And when I tried to remove it mysql told me it had problems renaming a file :-(.
The solution was to remove the foreign key using ALTER TABLE tablename DROP FOREIGN KEY fkname. Now I was able to remove my index and then I added the foreign key constraint again.
Really ugly.
Permalink
November 22, 2006 at 2:35 pm
by Wolfram · Filed under Programming, Python
Decorators is another one of those features that is easy to use and also easy to implement (once you know how). I proved to myself again, that it is very much easier in Python than one can imagine and that I am thinking too difficult again.
The must read article about decorators, that explains it all in depth and the different use cases is the article Python 2.4 Decorators by Phillip Eby.
Finally I am sure not only about how to use them :-).
Permalink
November 21, 2006 at 12:17 pm
by Wolfram · Filed under Dojo, JavaScript, Programming, Python
I really had thought I knew a lot of the programming terminology, methodolgy and stuff. That was about two years ago, when I had reached the point that PHP, the language I had used the last years and knew very well, had become boring and caused those kind of feelings. When starting with Python back then I saw that I had taken the blue pill before, it’s time to take the red one.
Currying was one of those things that crossed my way and I first thought it was some dirty hack thingy. But a lot more of those things crossed my way and I was glad to be back in the space of things I didn’t know yet but things that seemed everyone knew, but me. Finally a lot of challenges. And then I came across curry in Dojo too. Now my interest was finally raised and I had to learn in depth what currying is.
There is a Wikipedia article about Currying, but I feel more attracted by the article by Svend Tofte Curried JavaScript functions. And I guess there are a lot more.
So let me read and explore the real world.
Permalink
November 16, 2006 at 2:00 pm
by Wolfram · Filed under JavaScript, Programming
I was fiddeling with some code and got trapped by the way JavaScript handles references. The following code shows very clearly that JavaScript only creates a reference to the value, not to the variable itself!
>>> var a = [1,2,3]
>>> b = a
[1,2,3]
>>> a = [4,5]
[4,5]
>>> b
[1,2,3]
You can see that in the end b is still the initial array, while a has changed it’s value. As long as we only modify the array in a and not a itself b points to the same array. That proves that “b=a” doesn’t create a reference to a but the value of a (but only for arrays and objects!). I guess that is nothing new for JS experts. I just needed to write it down, it hopefully stays in mind better this way :-).
Permalink
November 15, 2006 at 12:13 am
by Wolfram · Filed under JavaScript, Programming
That is pretty easy and I guess obviously and known to all the advanced JavaScript hackers, but I was searching a bit for it and now I am using it constantly. For where there is no clone() method for arrays, you can simply use:
var arr = [1,2,3,4];
// slice() does the cloning for us. Doesn't handle nested arrays/objects!
var cloned = arr.slice(0);
// Now you can modify arr without fear of cloned being modified too.
arr[2] = "Other value";
Permalink