Python and Access-Control-Allow-Origin

Ok, here is something that probably happens a lot:

You are trying to do some .js (if not you should get started), and write some code in your favorite ide, save it, load it in your favorite browser and everything is ok. You are a good developer and start making packages and loading your files when you need them: lazy. You don't want to overdo things, and manage to put stuff into a bunch of .js and .html. You load them into your browser and BAM:

Access-Control-Allow-Origin  
Failed to load resource: Resource failed to load  
So now you are all WTF, right? You Google (some would Bing) it and sure enough, what you were thinking is the ugly true and by now you get angry as a bird. Why? Ok, for those that didn't know there is a thing called Same Origin Policy, that forbids you from loading stuff across different domains and bla bla bla... So what does it has to do we you? You sure enough are not trying do load across domains, your are loading a file... you may think, but no. Your file is from a different origin than your loaded page. At this point nearly every post tells you to run a server or allow file access in your browser. The latter is probably a very bad idea if you do actually browse occasionally through the web. So a server.. right... you have lots of them because you are a developer, but you have to configure a lot of stuff to make them point to the right directory.

(Meh.)

But then there is this other way using python:

$ cd WebPageProject/
$ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...
Simple indeed and beautiful.

Release Plan

Mario: is of course the developer trying to save the princess
Princess: is the release
Barrels: are either feature requests or bugs
Hammer: reconsider / won't fix
Kong: release manager

Story: Mario starts at the wrong end. He is actually done developing at the time the release comes into action, but has to run his way up through the plan to make the release on time and help the princess. On the way up, there are all kind of features and bugs rolling down wanting to hurt Mario. He has no possibility whatsoever to get them done faster. However, it is in his power to keep some of them from getting done before he reaches the princess.

ThreadLocal as an Enum - I'm not afraid to admit it!

Well, as disturbing as it might be, I am not afraid to at least admit it: I did not know about the elegance of the following construct:

public enum TLData
{
INSTANCE;
private final ThreadLocal<String> myData
             = new ThreadLocal<String>();
public String getMyData()
{
  return myData.get();
}
public void setMyData(final String myData)
{
  this.myData.set(myData);
}
}


Since you are using an Enum, nobody can create new members from outside, you don't have to care about privatizing any methods and you can access it as easy as:

public class myClass
{
public void myMethod()
{

  /**
     * setting the data
     */
  TLData.INSTANCE.setMyData("some data");

  /**
     * getting the data
     */
  String myData = TLData.INSTANCE.getMyData();
}

}


Isn't that fancy? I had to admit I never thought of it myself. A colleague of mine had to put it under my nose.