Robert Basic's blog

Archives for March, 2011

Installing FreeBSD 8.2

by Robert Basic on March 27, 2011.
Heads-up! You're reading an old post and the information in it is quite probably outdated.

As I’m currently in the progress of installing FreeBSD on my first machine (out of 4), writing the process down for future reference sounds like a pretty good idea :)

I’ve installed it from the CD image. The installation process was straightforward, altho either the boot loader or freebsd was getting confused in the first few attempts because I was installing it on the slave HDD. After installing it on the master, everything went fine.

On this machine I’m using a LevelOne WNC0305 USB wireless card which uses realtek’s dreaded RTL8187 chipset. After a bit of a googling, I ended up on the freebsd 8.2 hardware notes page, which in the wireless section lists all the available wireless drivers. From there I figured I need to use the urtw driver, that is to add:


to the /boot/loader.conf file. After rebooting the machine, it recognised my wireless card as urtw0. Hooray! Now to connect to the wireless router and onto the world.

For that, this message about (not) getting the ifconfig scan results helped me out, this bit to be precise:

# ifconfig wlan0 create wlandev urtw0
# ifconfig wlan0 up list scan

and it listed my router correctly. To make it stay that way after rebooting, I’ve added this to the /etc/rc.conf file (I might note that it was empty before this):


At this time I figured I just could ssh to one of the servers in the office (we run freebsds there) and “steal” rest of the configuration, so I ended up with a /etc/rc.conf file something like this:

ifconfig_wlan0="inet netmask"

Reboot once again and I can ping anything via IP, but not via hostnames. Again, this (ooold) message about DNS settings in freebsd showed me the right direction - /etc/resolv.conf:


Reboot and everything is working fine! Victory!

Next step was (is) to fetch/update the ports database:

# csup -L 2 -h /usr/share/examples/cvsup/ports-supfile

From here I believe it’s all about installing software from the ports which should be all fine.

Happy hackin’!

Tags: freebsd, install, realtek, rtl8187, wireless.
Categories: Development, Software.

PHP User Group, Novi Sad, Serbia

by Robert Basic on March 24, 2011.
Heads-up! You're reading an old post and the information in it is quite probably outdated.

For almost a year now, whenever time allows it, I’m working on a side project of creating a community of PHP programmers from around here. One of the first steps was, is, a website called PHPPlaneta about which I wrote back in October. After bringing this website to a relatively steady position, time has come to take another step: creating a PHP User Group! I’m really good at naming things so it is called “PHP User Group Novi Sad”, or pugns for short.

Actually I really don’t know what one has to do to create a user group, but I’ll just improvise along the way. So far, the date, time and the place for the first meeting is set: April 5th, 6PM, in a local coffee shop by the Danube river. A website thingy is also up: pugns, which is currently just a simple HTML page, but things will improve on that front too. The page of pugns is intentionally under a “directory”, because I’d love to host information about other PHP user groups from around here on the (sub)domain. It’d be nice to keep all relevant information under one “roof”.

Sooo… This will be an interesting ride, hope it’ll turn out fine :)

Of course, if anyone has some advice, tips and tricks about organizing user groups please do share them, that would be highly appreciated :)

Tags: meeting, pugns, user group.
Categories: Blablabla, Free time.

Contributing to open source

by Robert Basic on March 17, 2011.
Heads-up! You're reading an old post and the information in it is quite probably outdated.

Often times people ask me why do I contribute to open source, why do I “waste money and time” on free stuff when I could easily do the same thing for money? Don’t have I enough of staring at the computer at work where, well, I do the same thing - hack on code? Ummm. No.

Honestly, I don’t earn much. Enough for the rent, bills, food, but giving the fact that I don’t have a family, it’s enough for me, for now. So, I don’t make a s**t loads of money, but am still willing to work for free? Ummm. No.

Thing is, I really don’t consider this to be work. This is fun. This is hacking. This is creating stuff. This is solving problems. This is my passion. So no, I don’t work for free. I don’t work. I code, I hack.

But why open source?

Giving back

Giving back is nice. Not necessarily giving back to the same project, but just giving back to the open source community in general. It just makes you a better and nicer person :)


Both in high school and in college the fastest way for me to gain knowledge was to learn, collaborate with other students. Open source gives me the chance to share knowledge with hackers from all over the world; from Portugal, via Nova Scotia to Texas. It gives me the chance to be taught and to teach.


Open source gives the opportunity to work with people from every part of the globe. Getting ideas across by the means of email, chat, irc can be hard. Open source gives me the chance to improve my communication skills. Heck, I sometimes even have troubles explaining my ideas to my co-workers who sits right next to me.

Reading other peoples code, fixing bugs, writing documentation, adding new features, testing. Hack skills ++

Also, each and every accepted patch and merged pull request gives me that warm and fuzzy feeling inside.


Open source introduces you to new people. Who knows what can come out of these random introductions? Can’t be bad, that’s for sure.

This is why I contribute to open source: it is fun, it is hacking, it is creating stuff, it is solving problems.

It is my passion.

Tags: contributing, hack, hacking, open source, random.
Categories: Blablabla.

Multiple Dojo tooltips on page load

by Robert Basic on March 15, 2011.
Heads-up! You're reading an old post and the information in it is quite probably outdated.

As I said a few days (weeks?) ago, I’ve decided to learn dojo and not by just doing random examples, but by changing the whole administration panel for to use dojo and the ZendDojo* components. Maybe it’ll become a bit more usable and prettier :)

Fast forward a few hours into this journey of dojos and dijits and I found myself hacking and extending it just to make it work and behave like I want it to. I knew that this time would come sooner and later, but somehow this was way to soon. All I wanted is to have multiple tooltips pop up soon as the page loads; it couldn’t be so hard, right? Right? Well, it wasn’t hard, but it sure wasn’t easy either.

Note: when first started this post there was a section generally on dojo, which started out as a few words, thoughts, on it, but in the end turned out to be big enough for a separate post. The plan is to finish that once when I get to the end of this “dojo journey”.

OK, back to topic. What I wanted to achieve, and to some extent I did, is to show a few dijit tooltips when a page loads, for example after a user has submitted an invalid Zend_Dojo_Form, show the error messages in the tooltips. Bonus points for marking the invalid form elements as invalid a la dijit.form.validationtextbox.

First thing I learnt is that by default there can be only one dijit.Tooltip shown on the page at a time. A dijit.Tooltip will be shown when the element it is connected to gets focus and will be hidden when the element loses focus. By the logic that there can not be more than one element in focus at a time, dijit.Tooltip works perfectly.

To achieve what I wanted to, I had to make it possible to have several tooltips shown at the same time, all connected to different elements, plus they should be “activated” programmatically on page load, instead of waiting for the user to bring those elements in focus.

Making it possible to have multiple tooltips: the “offending” code that was stopping me from showing multiple tooltips is in dijit/Tooltip.js, around lines 83-93. Be warned, dojo code is a bit cryptic in places and figuring it out takes time. A whole lot of it. That piece of code there is responsible for creating a new tooltip instance each and every time. Luckily, that part can be easily overwritten in our dojo.addOnLoad function:

var ttids = Array();
        ttids[]=new dijit._MasterTooltip();
    return ttids[].show(_a,_b,_c,_d);
        ttids[]=new dijit._MasterTooltip();
    return ttids[].hide(_e);

Showing those tooltips programatically is a bit harder. I hoped that there’s some built-in method which when called will just happily show the tooltip, but I was foolish for having such hopes. Anyway, by looking at how dijit.Tooltip was created/declared, I’ve wrote my own tooltip which extends dijit.Tooltip and adds the “missing method”:

dojo.declare("app.errorTooltip", dijit.Tooltip, {
    show: function() {
        var elem = dojo.byId(this.connectId[0]);
        if(dojo.isIE) {
        } else {
            var e = document.createEvent("HTMLEvents");
            e.initEvent('focus', false, true);

Now, when creating a tooltip, instead of dijit.Tooltip I need to use app.errorTooltip (error, as I’m currently using it for showing errors). The contents of the show() method are a different story and they belong to that rant post about dojo I promised earlier :D All that code is actually doing there is firing the “onfocus” event on the element to which our tooltip is connected to.

Finally, querying the DOM for all elements which contain the actual error messages I was first interested in, creating a app.errorTooltip for each of those error message and showing those tooltips with the method I created.

var errors = dojo.query("form ul.errors").forEach(function(node, idx, nodes){
    var id = node.parentNode.firstChild.getAttribute('for');
    var label = "<ul class='errors'>" + node.innerHTML + "</ul>";
    var tooltip = app.errorTooltip({
        label: label,
        connectId: [id]
    // these next 2 lines are for marking the connected fields as invalid
    // as they are also an instance of dijit.form.ValidationTextBox
    dijit.byId(id).state = "Error";

There. Multiple dojo tooltips shown on page load. Mission accomplished. As I said, it’s not easy, but it’s not hard either.

Happy hackin’! :)

Tags: custom tooltips, dijit.tooltip, dojo, tooltips.
Categories: Development.

Ideas of March

by Robert Basic on March 15, 2011.
Heads-up! You're reading an old post and the information in it is quite probably outdated.

Apparently there’s this new movement in the PHP community, “Ideas of March”, where we all pledge that we will blog more about PHP and web dev and the community in general. So here I am, doing the same :)

This will be a real test for me because for the 2 and a half years of this blog I’ve published merely 60 posts. Why? Mostly because I was (am?) scared to just write more about things I’m interested in. But, as I really do like blogging and letting my thoughts out I’ll just have to do my best to write more :) and yes, it’ll still mostly be PHP related with some linux or javascript stuff here and there :)

To see who pledged to blog more in March, check out the list on PHPDeveloper or follow the movement on Twitter #ideasofmarch.

Happy bloggin’!

Tags: community, ideas of march, php.
Categories: Blablabla, Development.