Sprinting new concepts

I decided to do a sprint this weekend, I’m currently working on my bachelor project so I didn’t want to have some big project floating around at the same time, but I needed to do something different so I decided to come up with a new (to me) concept.

I love data and trying to figure out what to do with it, so the natural choice was to find some sort of free data and (ab)use it in a very simple page/web app. The Norwegian Public Roads Administration, or Statens Vegvesen as they’re called in Norway, have an XML feed available with all the information about the roads in Norway (closed roads, weather conditions and so on).

By using CakePHP to convert it to JSON and cache it to avoid getting banned for DoS’ing their server, and jQuery for the front end, it took 3 days (including horse riding, football(soccer) on TV, gaming, etc) to get everything up and running.

Overall doing this sprint gave me some useful information:

  • Programming too much makes it hard to sleep
  • When you sleep, you dream about code
  • Keeping the code maintainable when on a tight deadline can be a challenge, even when its only yourself you have to kneel down and apologize to from the bottom of your heart.
  • At the very least, add comments shortly after implementing something (useful after some sleep!)
  • Sometimes development can be fun, if you can tear yourself away from the worries about security flaws, browser incompatibilities, LOLcode and the kind of feedback which only is appropriate in TV-shows about cooking.

Anyhow, my sprint project:

https://github.com/bovan/Trafikkmeldinger

No Comments

Clickable rounded header

For a header to consist of an image and be rounded at the same time (atleast in good browsers), using border-radius to crop a box and having the image as a background-image is pretty much the best (or only) option now.

And if you want to have the box clickable without going for JavaScript, you have to add display:block to the link and size it properly. As long as you don’t have too rounded corners, this works just fine with very little code; the only problem is that it seems impossible to get the link to be anything but squared with just CSS.

No Comments

Git

I was working on this javascript project at work, where things got a bit too complicated because of junk code and interaction between other widgets. I decided the best solution to get back on track was to separate out the problem, and create a new and very basic project to solve some of the challenges.

I remembered that a friend had talked warmly about Git and complained that I didn’t have anything at github he could take a look at when I came looking for advice. So I decided that i’d give github a try. As NetBeans, which is my IDE of choice, doesn’t have the native git support yet I went for msysgit (which I guess most windows users end up with), and though I’m far from intimidated by using console for tasks, I was a bit worried that I would spend too much time fiddling around.

But my worries was quickly put to shame by GitHub’s intuitive way of introducing new users to both their webpage and git. For anyone wanting to have a look at git, I would definately just recommend them to sign up for GitHub and start using it right away.

After using (msys)git for a few days I’m definately feeling comfortable with it. More so than when I used TortoiseGit, I had it installed a few months ago, but it started using 50% of my CPU at random times. So not only did it crash and mess up my repository, but it also ruined my gaming sessions!…

Sometimes the simplest option is the best.

No Comments

Privacy – Top Secret or Inaccurate?

I’m not a big fan of hiding all my information so people can’t find me, however in this world of facebook and what not I feel some urge to participate, but I don’t want to reveal every tiny little detail.

Of course I have some blocks on my facebook settings and so on, but I also provide very sloppy data.

When I list where I live, I put the nearest city, which at the moment happens to be in a different country. At most places where I use my real name, I make sure that I don’t use my full unique name, but only first and last which isn’t really unique.

Of course finding out details about me is still possible, but it’s more problematic for the finder to know if the data is real and if it’s really me.

I think providing inaccurate data at least provides an additional layer of privacy for those who are concerned about privacy, but doesn’t feel like they have to hide.

I still keep my identity, even though it’s a tad distorted, but not many who don’t know me can easily get hold of the exact and real data.

(And no this ain’t a challenge :P )

, , ,

No Comments

Dojo vs jQuery in a jQuery based system

I recently had to evaluate which JavaScript framework/toolkit/library I wanted to use for developing a workflow engine inside a system that already uses jQuery.

Using jQuery would include less files and have (hopefully) no chance of conflicts. However, 1 year into the future, when I’m most likely not working here at CERN, what would happen if the system that my application is embedded inside would be updated with a newer jQuery version?

As one doesn’t know the changes in future versions of jQuery (I’ve seen plugins break before), one could run into the risk of having the embedded application stop working, because it wasn’t updated along with jQuery.

This makes a strong point for my development using Dojo instead. Dojo uses it’s own namespace, and if one updates jQuery it shouldn’t affect the Dojo-application. Add to the fact that with Dojo one have less need for 3rd party plugins, as it has got so much more included in the package, and the survivability of the application should be longer.

No Comments

Fixing usability with GreaseMonkey

Sometimes there are annoying small usability issues, like on cds.cern.ch, where the standard option is to select ALL categories when you search.

Usually I know what I want to search for, and there’s a big difference in searching for books and multimedia, which means I don’t want to have books popping up if I want a picture.

Luckily a simple GreaseMonkey fix can solve such annoyances with no effort at all:

var inputFields = document.getElementsByTagName("input");
for(key in inputFields)
{
  if(inputFields[key].type == "checkbox" && inputFields[key].checked == true)
    inputFields[key].checked = false;
}

Now I just select what I want, instead of deselecting what I don’t want, which usually leads to a lot less clicking.

Thank you GreaseMonkey!

No Comments

Embedding CSS from JavaScript

After spending some time in JavaScript (and modifying my CSS a tad), I managed to add a semi-flexible global sitemap (on top).

I wanted something that could be easily attached to any site, with adding just a simple script.
Also, as I wanted it to work independent of jQuery, Dojo etc, it has to be vanilla JS.

Satisfying IE is still a pain in the ass, and it doesn’t help that one chose not to use jQuery and Dojo for simplifying cross-browser support.

One example is the function I have for putting CSS into the HTML page. I really didn’t want to add another stylesheet, to reduce the number of page loads.

However, IE didn’t like the:

styles.appendChild(document.createTextNode(css[key]));

Thus I was forced to find some way of making it accept it:

function bytestorkStyles()
{
    // Storing styles
    var css = [];
    css[0] = "div#bytestorkSiteMap { ..stuff here..} \n";
    css[1] = "div#bytestorkSiteMap ul { ..more stuff here...}"
    css[2] = "div#bytestorkSiteMap ul li { ..and so on.. }\n";

    // create style element
    var styles = document.createElement("style");
    styles.setAttribute('type', 'text/css');
    // the usual IE hack fix
    if(styles.styleSheet)
    {
        styles.styleSheet.cssText = '';
        for(key in css)
        {
            styles.styleSheet.cssText += css[key];
        }
    } else{
        for(key in css)
        {
            styles.appendChild(document.createTextNode(css[key]));
        }
    }
    //throw it into the head tag
    document.getElementsByTagName("head")[0].appendChild(styles);
}

Maybe not the cleanest code, but it helped me not having to put all the styles into the elements themselves. Perhaps a better solution would be a cacheable CSS file, but it’s not like this is gonna kill a computer. :)

No Comments

My CERN page made in Dojo

I finally got the required project homepage for my degree work up and running.

Playing around with Dojo to make some functionality behind it:

  • Data is stored in JSON files
  • A template for each page is stored in a seperate file
  • When you enter the site, all the content and the template is stored in the user’s browser.

This has the effect that it might take a few milliseconds more to load the page, but after that there is no more page loading.

This makes the server very happy:

No Comments

No Adobe = Open Source

As I’m no longer at my university, I don’t have access to computers with Adobe Illustrator and Photoshop anymore. For that reason I’ve been playing around some with Gimp and Inkscape to find open source solutions to my lack of design skills.

As I didn’t have any good ideas concerning my logo, I drew a few storks (without babies) in Inkscape, until I had one which I didn’t feel intensely ashamed of. Luckily I found a tutorial which explained volumetric objects in Inkscape, and after playing around a bit with it, and putting it all together in Gimp (with the obligatory reflection) it ended up like this:

No Comments

ByteStork

I have established ByteStork.com, and finally have a place to put all my professional stuff instead of just leaving it on my harddrive and forgetting about it.

Nothing more to say about it for now, this blog will focus on the web development stuff in my life :)

No Comments