Wednesday, July 16, 2008

Hide and show contents of a div

One of the websites that I am maintaining during my dayjob was getting quiet cluttered on the right side. So I decided that all the logo's of possible banks should be hidden untill clicked on. I know this is possible, I just didn't know the right code from the top of my head.

However, Dustin Diaz's blog gave me the solution after a quick Google.

This resulted in the following code:

<script type="text/javascript">
function switchDiv(obj)
{
var el = document.getElementById(obj);
if ( el.style.display != 'none' ) {
el.style.display = 'none';
}
else
{
el.style.display = '';
}
}
</script>
<div id="whatever" style="margin-bottom:2px;"><a onclick="switchDiv('nameofdivtoshowandhide');"><img src="imageonwebsite" </a></div>
<div id="nameofdivtoshowandhide" style="margin-bottom:2px; display: none;"><img src="imagewithalllogos.jpg" </div>


This is definitely repeatable code, which I should save for future use.

Monday, April 21, 2008

Ajax: first experience

I haven't written in a while, but that doesn't mean I haven't been busy. Actually I have been improving my knowledge of both PHP and MySQL, picking up additional JavaScript knowledge on the way.

Everybody has heard of Ajax, or Web 2.0, nowadays. So naturally I tried to pick this technology up as well.

Coding everything manually proved to be quiet difficult, especially since my knowledge of JavaScript is so limited. Then I came across Xajax, which is a PHP based framework to create ajax-like webapplications.

I am working on a project right now where I will be using this framework, and hopefully the first version can be released soon.

Tuesday, March 11, 2008

Good PHP book

I think I should look into buying a good PHP book, since the Java book I bought helped me learn so much quicker then reading tutorials on websites. One book I came across, and am really considering, is: PHP voor het World Wide Web; ISBN10: 9043005452; by Larry Ullman.

Monday, February 25, 2008

Browser MMOG; Ikariam!

Last week I stubled on a online game, Ikariam. It is a complete webbased game, and therefor can be played on every computer with a recent browser. I would summarize it as a slower running version of Settlers. And with slower running, I mean the game time. For instance, upgrading a building takes from twenty minutes to a few hours. Of course for a webbased game this isn't a bad thing, since most people will play this when doing their work etc. So quickly login and start some things, and the go back to work....

Thursday, February 14, 2008

Update: Airforce

As posted before, I have applied to join our airforce. Before they let you start the training, the run you through multiple selection rounds. Right now I made it to the last two. They run sort of independant of eachother. This march 6th I will have to go to the Central Military Hospital to get some (X-ray)scans of my skeleton, brains and heart. I will also get an invitation soon to fly a few flights in a real plane. It will be sort of like the flight simulator which I had to do earlier, except that in the flight simulator you'd fly solely on instruments, and in the plane you will fly without instruments.
This will be done during 1 week in Portugal. I am looking forward to go there, and make my first hours in the pilotseat. And to see some nice parts of the town Evora offcourse...

The plane I will be flying is a Slingsby Firefly T67-M200. Looks like quite a nimble plane!

Thursday, February 7, 2008

New videocard, but which one?

Recently I finally made the upgrade to the dual-core era, but I decided to use the onboard graphics of the Asus M2A-VM HDMI motherboard. Based on the AMD 690G, with Radeon X1250 graphics, it basically supports everything up to DirectX 9.0c. And I didn't expect to do a lot of gaming.
However, recently I wanted to play a few games again, mostly try Call of Duty 4: Modern Warfare. And doing that on a 690G/X1250 is really not advisable. So I started looking at what videocard might be a viable option for me.

It should not be to expensive (so <= €100,-), preferably passively cooled, and be the fasted possible within those requirements. Now I have been very interested in the new Radeon HD 3400 / 3600 series. But until now I could not find decent benchmarks with both series included. Today I found those at Legitreviews.com.

I will definatelly skip the HD 3400 series, but I think the HD 3650 is really a viable option.

Monday, February 4, 2008

Ubuntu 8.04 Hardy Heron Alpha

Yesterday I upgrade my Ubuntu Gutsy install to the latest 8.04 Alpha (#4 I believe). First I was planning to do a clean install from a freshly downloaded ISO, but then I decided to see if an upgrade would work.

This turned out te be pretty easy. I haven't worked long on 8.04 yet, but have yet to encounter problems. I guess the upgrade went pretty smooth.

First edit your sourcelist:

sudo gedit /etc/apt/sources.list
replace gedit with your favorite text editor. I used gedit because I have no idea wether nano has an easy replace function. In the sources.list file, replace every gutsy with hardy. This will make sure that when you do the next apt-get update, it will connect to the hardy repos.

sudo apt-get update
sudo apt-get dist-upgrade

Now it will install everything which is needed to upgrade your current 7.10 install to the 8.04 alpha. After apt-get is finished, reboot et voila! You can now try the latest Ubuntu.

Wednesday, January 23, 2008

Joining the Airforce

I never finished anything after my high school diploma. I went to University for two years, but decided to take a brake, mostly because of the (almost non-existing) progress I was making. In that time I met my current wife, and by now we have three children.
However, without a proper education, it is quiet hard to find a job that is both satisfying and well-payed.
Last spring I applied as a pilot in our Airforce (again, second time I tried). This time I went trough the selection pretty quickly. Right now, all I have to pass is a physical test and a piloting test.
Who knows, perhaps I will have to stop doing what I'm doing, and start a new career as a military pilot...

Wednesday, January 9, 2008

Password protect Apache2 server

I have been running an Apache2 server (with MySQL and PHP) since forever, mainly to run MythWeb (a great plugin for MythTV), and the occasional  CMS like Joomla! or Mambo.

Now I am also experimenting with Java, JavaScript, PHP and MySQL, and I would like to be able to do some from my work as well. So I opened port 80 on my connection. However, without any kind of protection, this means that anybody who knows my IP, can just use MythWeb to delete all my recording. 

There are two option in securing your webserver:

1. Use PHP (or equivalent language) to create a login system

2. Put security parameters in the Apache2 configuration.

Since I am still beginning with PHP etc, I opted for the second option. My server is running Ubuntu 7.04. It is possible to use .htaccess files in the root of your webserver to set passwords etc. But I read that it is better to set passwords in httpd.conf. Ubuntu puts this file in /etc/apache2/. Note that by default httpd.conf is not used anymore, right now Apache uses the /etc/apache2/apache2.conf file. But anything that you put in the httpd.conf will be applied by Apache2. And doing so, has the benefit that your apache2.conf stays nice and clean.

Create a password with the htpasswd command:

htpasswd -c <username> /some/location/for/passwordfile

It will ask to give a password, and will then put it in the specified location.

This is what I added to the httpd.conf file:

<Directory>

AuthType Basic

AuthName "Please enter username and password"

AuthUserFile /some/location/for/passwordfile

Require valid-user

</Directory>

The first line sets this policy for /var/www/ and lower directories. The third line is the message shown to users, the fourth line specifies where the created password file is set.

Wednesday, January 2, 2008

Java + XML

I have a certain text, which is basically an template for our CMS at work. This text needs to be edited and written in notepad or any other texteditor. What I would like to do, is have an nice GUI, where I just select the specifics, and it generates the requiered text from that. So for instance, just fill in the partnumber, after which the program would generate the complete text which I can then just copy/paste in our CMS.

So I would use JTextFields, and maybe Combobox etc. But what to do with those values? The most flexibel option would be to have each change of each value updated seperately in the "template". But I have not found a way to edit a certain text in an JTextArea.

The way to go? Write each value to an XML file, and use that XML file to create the "template" in an JTextArea/Pane/whatever.

So now I have to get into XML, and I am going to start here: http://developerlife.com/tutorials/?p=26 and http://www.cafeconleche.org/books/xmljava/.

And some more links: http://www.onjava.com/pub/a/onjava/excerpt/netbeans_2/index2.html and http://www.netbeans.org/kb/55/xmltools-openingsample.html

Remote access

I have set up a SSH server on my Ubuntu mediacenter, and forwarded the proper port. I'm using password authentication, with maximum 3 attempts, en 20 seconds maximum before disconnect. And guess what? It works! I can now access my mediacenter from work through Putty for commandline access, or WinSCP for some easy file browsing.

What I need to fix now, is a remote desktop solution. Within my LAN at home I am using the Vino VNC server of Ubuntu, but I haven't figured out yet how to tunnel this over SSH with putty. There are tutorials, but they presume the use of TightVNC.

And I would like to access my webserver, but without making access public. This also I haven't got working through tunneling over SSH. I guess I could just open up another port for my webserver, but then I'd have to protect access to it. This can be done by using an PHP login system, or by configuring either the .htaccess or httpd.conf file properly. Some usefull links on this subject:

http://php.codenewbie.com/articles/php/1482/Login_With_Sessions-Page_1.html
http://ubuntuforums.org/showthread.php?t=379752&highlight=apache+password+protect