JavaScript URI class
The other day I needed an URI class for JavaScript. I was doing some stuff where I needed to alter certain parts of an URI. I bet there’s a couple of URI classes for JavaScript out there but I can be a bit nit-picky about code and how it’s written
Anyway, I had a URI parser regexp lying which I wrote for a Vala class (before I found the Soup.URI class) and I thought that since that’s reusable I could hack up a JavaScript URI class myself. So I did!
Here’s some examples of usage:
- var uri = new URI("http://poppa.se/blog/javascript-uri-class/");
- console.log(uri.scheme); //-> http
- console.log(uri.host); //-> poppa.se
- console.log(uri.path); //-> /blog/javascript-uri-class/
- console.log(uri.port); //-> 80
Now, if we want to alter the host so that it contains www we do:
- uri.host = "www.poppa.se";
- console.log(uri.toString()); //-> http://www.poppa.se/blog/javascript-uri-class/
It’s also easy to alter query string variables:
- var uri = new URI("http://host.com/?name=poppa&lang=se");
- uri.variables["name"] = 'Günther';
- uri.variables["lang"] = 'de';
- console.log(uri.toString()); //-> http://host.com/?name=Günther&lang=de
And I think that’s pretty smooth
New Roxen Application Launcher for Linux written in Vala
A couple of weeks ago I stumbled upon a fairly new programming language named Vala. I thought it looked promising and since Vala is developed by the GNOME project – with the purpose of making software development for, primarily, GNOME easier – and I’m an avid GNOME user I wanted to look deeper into the world of Vala.
I, and most programmers I believe, work in that way that I need a real and useful project when learning a new programming language. So I thought why not re-writing the Roxen Application Launcher I wrote in C#/Mono a couple of years ago in Vala – which by the way is syntactically very, very similar to C# and Java. I’d gotten tired of always having to fiddle with the C# code with every new version of Mono since something always broke when Mono was updated so a re-write wasn’t going to be totally pointless. The good thing about Vala is that the Vala compiler generates C code and that’s what you compile the program from. Fast code and hopefully more mature and stable libraries that won’t break backwards compatibility with every new release.
What about Vala
So, on I went about it and I think that Vala is a really promising language. It’s still a very young language so some library bindings isn’t behaving exactly as expected and the documentation isn’t directly redundant – although the Vala reference documentation site isn’t half bad. But since Vala pretty much is a wrapper for, or binding to, the underlying C libraries you can find answers to your questions that way. All in all I think Vala has a promising future: Way more simple than C and almost as fast and light on memory (remember the Vala compiler generates C code) and way faster than C#/Mono and free from any Microsoft associations
.
What about the Roxen Application Launcher
In this new version I utilize GConf for storing application settings. I also made use of – for the first time – the GNU Build Tools for compilation which also makes it easier to distribute and for others to compile from the sources. This also means that the distributed version compiles from the C sources and not the Vala sources so there’s no need for the Vala compiler to build the program.
Other than that there’s nothing fancy about it. The Vala sources is available at my Github repository.
Roxen Appliction Launcher 0.4.2 19:38, Sun 20 December 2009 :: 374 kB
Screenshots
The screenshots is showing the Swedish translation.
Gravatar module for Roxen
Although I’m working on some social web related Pike modules where a Gravatar module is included I needed a Gravatar module right now at work so I hacked up a standalone Gravatar Roxen module.
This is how it works
- <ul>
- <emit source="sql" host="mydb"
- query="SELECT name, email, `date`, body FROM my_comments"
- >
- <li>
- <gravatar-img email="&_.email;" rating="pg" size="32"
- default-image="/path/to/icon.png"
- /> &_.name; wrote at <date iso-time="&_.date;" />
- <wash-html paragraphify="">&_.body;</wash-html>
- </li>
- </emit>
- </ul>
Download the Gravatar Roxen module 14:20, Wed 09 December 2009 :: 7 kB
A change of times
Times are changing! This old beer ad is in Swedish but in short it says:
Pripps in a new disposable pack, for the sailing tripp. Extra tip: Make a hole in the bottom of the empty pack and it will sink faster.
It feels we at least have come some way regarding recycling.
Click on the image for a full scale version.






