Releasing Quadrapassel 3.8.2

After I had some Issues releasing Quadrapassel 3.8.2 which have been resolved thanks to the quick work of Andrea Veri.

Disable preview-button in difficult block mode

Disable preview-button in difficult block mode

As of now, the most current stable version of gnome Quadrapassel is 3.8.2. Here’s what the news file says:

Colin Kinloch:

  • Fixed repeated down press bug

Mario Wenzel:

  • Hiding preview embed when preview is unavailable or disabled
  • Disable preview-button in difficult block mode
  • Fix bug where falling block shadow would get missing
  • Fix segmentation fault when down key was released after game was over
Hiding preview embed when preview is unavailable or disabled

Hiding preview embed when preview is unavailable or disabled

Michael Catanzaro:

  • help: update translate  link for new module name

Andika Triwidada:

  • Updated Indonesian translation

Yuri Myasoedov:

  • Updated Russian translation

I wish to thank all contributors, especially Michael who brought me in and vouched for me.

Quadrapassel 3.8.2 should be in your repositories soon.

GNOME, I am here

I’ve checked in with the games maintainers, […], and we’d like to extend an offer to become a maintainer for Quadrapassel.

Bildschirmfoto von »2013-07-12 10:59:41«So that’s what I am now, I guess. I will keep you posted on the new stuff I’ll help getting into the quadrapassel repository.

If you want to contact me, you can write an email to maweki at gmail dotcom or you’ll usually find me hanging out in #gnome-games on the gnome irc servers.

It will take me some time to get all the bureaucracy out of the way so bear with me a bit but I’ll be triaging bugs in notime. 🙂


p.s.: I’d like to thank Michael Catanzaro for his quick and competent help.

Solving a math puzzle with Python’s generator expressions

Recently James Grime of numberphile-fame posted a puzzle on YouTube. The video is right here but the question is (if you don’t care to watch): „How many ways are there to completely fill a Noughts and Crosses (tic-tac-toe) board, with four noughts and five crosses? Not including rotations and reflections.“

So I am not much of a mathematician and I also did not really care for fopping about much so I wrote a small program in python to find the solution. And I took the chance to make a post about generator expressions in python as well.

A generator expression can take two general forms:

def gen(count):
  c = 10
  while c > 0:
    yield c
    c = c - 1

Here the yield keyword is what it’s all about. This will generate an iterable object that returns the yielded items. The cool thing is, that computation of this method is suspended until the next item is needed.

If you already have an iterable you can create a new generator expression from it:

g = (x for x in gen(10))

Here you can filter or map the value of x as you will see. And again, this is only a generator. No computation happens unless you actually want to print any values or you manifest them into a list.

you will find the source code of my solution below the fold


Constructors in Python: overwriting __new__ and the singleton pattern

About all object-oriented languages allow you to overwrite the constructor of a particular self-defined type. In Java (and C#) this looks somewhat like that:

public class A(object) {
  constructor A() {
    // Do Something

If you think the parameters somehow merit the abortion of the object creation, you can only throw an exception. You only can do that. An object of (in this case) type A is always returned. You can’t even return a different object or an object of a subclass of A. This convention led to the factory pattern in which a static method is called to decide which specific constructor of which specific class to run. Since the method is declared as returning the supertype, it can return any subptype as well. But the factory-pattern can sometimes get out of hand.

If you get started with python you commonly see __init__(self [, args]) as the method you need to overwrite in order to get a constructor.

class A(object):
  def __init__(self):

And it is true that this is exactly what is written above.
Note: in python, methods are objects (and could be swapped any time). Therefore the own instance cannot be bound outside the method scope and it is always passed by the calling instance as the first parameter. Therefore any non-static method of a class starts with „self“ (or „s“ or whatever you want to call it) as its first parameter.

So __init__ is, as is the constructor in C# or Java, only called when the instance has already been created. So why is it called a constructor then? Historical reasons, for one. But with statically typed languages you can overload the constructor and build your instance from different parameters. A dynamically typed language like python has no method overloading. It is still good for initializing properties of the particular instance.

But there is another cool method in python which you can overwrite: __new__(C [,args]) in which the class to create an instance of is passed in C and the rest of the arguments in args. And now you can build something like this:

class A(object):

class B(object):
  def __new__(C):
    return A()

In statically typed languages it is almost always true that A() returns an object of type A. But in python, this does not need to be true. You can put your factory right there as the constructor of the superclass and it looks really neat.


The Friendzone explained

Stephen Colbert explaines platonic relationships aka The Friendzone.

php comparison explained

php is an awful language and we all know it. It has a very silly comparison algorithm for loose comparison (==) which I am going to try to explain.

If we compare variables of different types (bool, string, int, float, array, object) with each other, php tries to cast them into a common type. But some types have no „common ground“ and can never under any value assignment, be considered equal. This Venn-Diagram shows you, which stuff can be compared with each other to, in any way, get variables that are considered equal.