Posts tagged ‘Programming’

One quick bug/tip that might save you lots of time. :) If you use Google’s appengine along with the webapp2 and using the Users module, you might encounter the following problem.

Recently, the ndb graduated and its python module changed from ndb to google.appengine.ext.ndb. Webapp2 is bundled along with the SDK of appengine, but it seems they forgot to update some modules in it, and they still use the previous package.

I encountered it when I tried to debug my application locally, using the webapp2 user & authentication module, the application crashes from the bad import. When you deploy the application to the appengine server, you must provide a version of the webapp2, which overrides this problem (this worked as a workaround for me at least), thus the problem will not occur. But locally, you must go the installation directory of the appengine and delete it manually.

I spotted this bug roughly a month ago (23/12/2011), and there may be some fixes on the mainstream webapp2 release.

Update (18/2/2012): The problem still persists in version 1.6.2 of the appengine SDK for python.

VN:F [1.9.14_1148]
Rating: 8.0/10 (1 vote cast)
VN:F [1.9.14_1148]
Rating: 0 (from 0 votes)

Recently I was messing with Appengine’s pull queue and noticed the following. They did not offer a C/C++ API. All the other usual suspects are there, like python, Java, go, even PHP and Obj-C.

What happened to C/C++? It is not worth offering and maintaining any more an API for these two languages? Or google wants to promote go!, and pat the iOS developers with the Obj-C?

No, you cannot have a native app. That’s it! Maybe, because C/C++ do not offer by definition an HTTP protocol implementation.

VN:F [1.9.14_1148]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.14_1148]
Rating: 0 (from 0 votes)

EavesDrop is a wow plugin that acts as simple combat log that displays events using icons for spells/kills instead of raw text. It seperates incoming events (left side) from out going events (right side) from misc. events (middle).

Since cataclysm, the add-on bugged in Atramedes fight (Blackwing descent), when he used the sound power. The add-on has not updated since 15/10/2010 (before cataclysm), so I took the liberty to introduce a minor fix for this.

Please note that this is a workaround. The add-on will ignore all sound abilities.

Many thanx to Maria, for pointing out the problem and spending her time discussing possible solutions :) .

You can download the add-on from http://bkarak.wizhut.com/www/programs/misc/EavesDrop.zip

VN:F [1.9.14_1148]
Rating: 10.0/10 (1 vote cast)
VN:F [1.9.14_1148]
Rating: 0 (from 0 votes)

Like the phoenix, from the ashes of Linux Format (Greek version) the brand-new Linux Inside was born. The first volume will be available at 27/1 (Greece only).

Linux Inside is a 100% Greek magazine that is written by the Linux community for the Linux community. It is hosted in http://www.linuxinside.gr/ (in Greek).

Feel free to visit it, tell us your opinion and freely participate in the forums.

VN:F [1.9.14_1148]
Rating: 9.8/10 (4 votes cast)
VN:F [1.9.14_1148]
Rating: +3 (from 3 votes)

Visit it now :) … and find the books’ source code, errata and more. — http://stepsinscala.com/

VN:F [1.9.14_1148]
Rating: 9.0/10 (1 vote cast)
VN:F [1.9.14_1148]
Rating: 0 (from 0 votes)

Overloading constructors in Java (not only) is good for the overall design. When used effectively it can result with correct and efficient initialisation of a class and avoidance of many lines of boiler-plate code.

Yesterday, I stumbled on the following problem. I wrote a class like the following,

public class Foo {
     public Foo(Integer i, Double d) { ... }
 
     public Foo(Integer i, Float f) { ... }
}

which defines a class Foo with two constructors that accept Integer and Double, and Integer and Float.

For some reason (not important right now) I wanted to initialise the first (Integer,Double) with the second parameter set as null.

This resulted as a compiler error, because the compiler actually could not decide which of the two constructors I wanted to use. Whoops … what could I do?

I could introduce a third constructor, with only one parameter and call this. Try it, you will see, that you will end up using part of the initialisation of the two others, which may complicate things (at least it did in my case).

Fascinating, isn’t it? Maybe we need a Null<Double> or Null<Float> to avoid this mess? Maybe the null value should be a generic Null<T> and use it to ensure type safety and instruct the compiler to correctly solve this ambiguity?

I do not know. My real-world problem solved with a third constructor as a work-around and some duplication of code. C’est la vie.

VN:F [1.9.14_1148]
Rating: 9.0/10 (1 vote cast)
VN:F [1.9.14_1148]
Rating: 0 (from 0 votes)

Recently I began coding the Firefox client of the Pithos application. This release include some small fixes, that permits you to copy local files outside your home directory in windows-based systems. I plan to add some cool features in the near future.

VN:F [1.9.14_1148]
Rating: 9.0/10 (1 vote cast)
VN:F [1.9.14_1148]
Rating: 0 (from 0 votes)

A very close friend of mine, Christos KK Loverdos and Apostolos Syropoulos are close to finish their efforts in completing their book for Scala, titled “Steps in Scala”.

Good luck to both of them, keep up the good work, and I will gladly pre-order my copy :) .

VN:F [1.9.14_1148]
Rating: 9.0/10 (3 votes cast)
VN:F [1.9.14_1148]
Rating: 0 (from 0 votes)

Hey, just noticed that the next version of the book Dive into Python. It is a brilliant book and you can found it online free here. To be honest, I will surely buy my printed version also, i’m a little old fashioned.

VN:F [1.9.14_1148]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.14_1148]
Rating: 0 (from 0 votes)

These days i’m finalising the FIRE regular expression compiler. To add a feature, the need arise to modify the classpath at runtime. It was a surprise for me when i discovered that there is no official way to modify this at runtime. I even created my own URLClassLoader (java.net), and set it as default classloader for my thread, but nothing.

I searched in google a little and found this post on a forum, which provided a class named ClassPathHacker that could add a path or file (jar) to a classpath at runtime. All this by a programmer named Antony Miguel. Well done :) .

The source code of the class follows:

import java.net.*;
import java.io.*;
import java.lang.reflect.*;
 
public class ClassPathHacker {
 
	private static final Class[] parameters = new Class[]{URL.class};
 
	public static void addFile(String s) throws IOException {
		File f = new File(s);
		addFile(f);
	}
 
	public static void addFile(File f) throws IOException {
		addURL(f.toURL());
	}	 
 
	public static void addURL(URL u) throws IOException {			
		URLClassLoader sysloader = (URLClassLoader)ClassLoader.getSystemClassLoader();
		Class sysclass = URLClassLoader.class;
 
		try {
			Method method = sysclass.getDeclaredMethod("addURL",parameters);
			method.setAccessible(true);
			method.invoke(sysloader,new Object[]{ u });
		} catch (Throwable t) {
			t.printStackTrace();
			throw new IOException("Error, could not add URL to system classloader");
		}		
	}	
}

and an example of usage ..

import java.io.*;
 
public class ClassPathAdder {
	public static void main(String[] args) {
		try {
			ClassPathHacker.add(new File("/home/user/newClassPath"));
		} catch (IOException e) {
			System.err.println("Error - " + e.toString());
		}
	}
}

Cool! :-D

VN:F [1.9.14_1148]
Rating: 4.0/10 (1 vote cast)
VN:F [1.9.14_1148]
Rating: 0 (from 0 votes)