Archive for the ‘Open Source’ Category

wget hack

Tuesday, December 19th, 2006

Today, I recursively downloaded a web site to my web server using wget, and for some reason it didn’t work well. Some of the immediate files are missing. After running through the original site source, I realized that it’s about the files inside the style sheets. So, I made some quick modifications to the wget source.

It’s just a hack to get my download working, however it will also work on some other sites as well(I hope ;-)). errr…. Sorry about the quality of code.

Unfortunately, I lost the original source code(I have no intention to download it again using my dialup; ah! I forgot to tell you, I’m enjoying the vacation at home; Ratnapura), so I can’t create patch files. wget version is 1.10.1. Download recur.c and html-url.c.

Number Puzzle Changed - It’s 15-Puzzle now!

Tuesday, October 31st, 2006

I changed the Number Puzzle plugin a bit and renamed it to 15-Puzzle. The new download links is http://www.sandaru1.com/15-Puzzle.gg. The older link also contains the same files now.

Number Puzzle - A plugin for Google Desktop

Monday, October 23rd, 2006

Number Puzzle is a plugin for google desktop. Click here to download. You can download the source code from here. (It’s the same file, just with the extension of “zip”. Just forget it if you can’t understand).

Jigsaw

Monday, August 28th, 2006

Download jigsaw.js samples.zip
Jigsaw is a small javascript framework for AJAX.

First you need to download the prototype library from http://prototype.conio.net/. Then include the javascripts in your header like this :

<script src="prototype.js" type="text/javascript" language="javascript"></script>
<script src=”jigsaw.js” language=”javascript” type=”text/javascript”></script>

After that you just have to call the request function.

<script>
var request = new Ajax.Request(’test.xml’);
</script>

It can be either a static xml page or dynamically generated one, it doesn’t matter. The xml file describes what to do next.

Here is a sample xml.

<?xml version="1.0" encoding="iso-8859-1"?>
<response>
<element id=”header”>World!</element>
<element id=”header” attribute=”style”>font-size:16px</element>
<element id=”image1″ attribute=”src”>picture2.jpg</element>
<script>alert(’Text inside script tags are executed’)</script>
</response>

Your html page should have two elements like this :
<div id="header">Hello</div>
<img id=”image1″ src=”picture1.jpg” />

It’ll update the content of the header div to “World!”, make the font size larger and the change the picture to “picture2.jpg”.

You can also create javascript objects.

<?xml version="1.0" encoding="iso-8859-1"?>
<response>
<object>
<attribute name=”name”>Person1</attribute>
<attribute name=”age”>20</attribute>
</object>
<object age=”30″>
<attribute name=”name”>Person2</attribute>
</object>
<object name=”Person3″ age=”40″ />
</response>

Then you have to create a function to process the objects.

function process_objects(response) {
for (var i=0;i<response.objects.length;i++) {
alert(response.objects[i].name+” = “+response.objects[i].age);
}
}

The request should be like -

var request = new Ajax.Request("objects.php",{onFinish:process_objects});

You can also access the XMLHTTP Object from response.transport

This function is called after the pre-processing, if you want to process something before pre-processing use onComplete option.

AJAX, wow it’s getting really popular

Saturday, June 24th, 2006

Yesterday, I was browsing through digg.com programming channel. Mmm.. Impressive, more than half of the stories are related to ajax. So, I decided to write about bit of ajax today.

The main advantage of AJAX is that it works like a desktop application; instead of refreshing the page every time you change something, you can interact with the server then and there. When we talk about the disadvantages, there are a lot; bookmarks, back button, search engine incompatibility, etc (there are hundreds of articles in the internet regarding these.. so, I’m not going to repeat those ;-) ). But use of some hacks will help you to avoid those problems.

There are plenty of AJAX frameworks, both client side and the server side ones. I have gone through many of them and found out that one of the bests is rico. This simple javascript client side framework also contains some animation effects and drag and drop feature.

If you had a careful look at the popular javascript frameworks, you’ll see that most of them are based on prototype. Prototype is a really powerful javascript framework which allows you to create classes.

When we consider about the server side languages, using php is really easy. It’s a simple light weighted language and php applications can be executed in almost any web server (of course only if it supports php).

So, this great combination of tools will make you ajax life easier; prototype, rico and php.

P.S. : As I have mentioned in an earlier post, firebug will help you a lot on debugging.

Rico = Javascript + XML = AJAX

Saturday, June 10th, 2006

After successfully finished an AJAX project (a simple AJAX Content Management System), this time I’m going to create a complete AJAX site. The CMS was created without using any 3rd party frameworks, and had a great time debugging the javascript code. So, this time I decided to use a framework.My choice was Rico – A client side javascript framework. It also provides some javascript animations and drag n drop features – haven’t tried those yet. Actually, this made my work much easier. If I want to update the value of an element, then I just have to create a piece of xml code, the framework parses it and updates the element automatically. But it only supports updating an element value, if I’m doing something outside that, I have to parse the code manually and do it. So, I created my own mini framework using Rico:). Now, it’s really easy.

When I was creating the CMS, the alerts did a great job ;). It really helped me to debug the javascript code. But this time, Rico blog directed me to a nice extension for firefox – FireBug. It’s really cool. Actually, the main advantage is, it captures all AJAX events. Simple and Useful.

Linux or Windows

Wednesday, March 8th, 2006

It is true that most people in the world are using Windows. But there is a doubt: “Is it the best OS for PCs?”. Here is a brief description regarding Linux vs. Windows.

GUI (Graphical User Interfaces) -

Both Windows and Linux provide GUIs and both are seem to be fairly ok. But there is an advantage in Linux; many GUIs (Gnome, KDE, etc) are available. Windows only comes with its own one and only GUI. There are some external software to change the look of the theme. But those are third party products and take up too much memory and slow down your computer.

Shell / Dos prompt -

The shell in Linux is very powerful. You can do almost everything in the shell. But the Dos prompt’s scope is limited to a small area (Almost only file handling!).

Cost -

Linux is almost free and Windows is around $200 - $300. But when you consider running Linux on a business environment, you may have to hire some Linux technicians, who might be more costly than the Windows techno craps.

Live CDs -

Windows doesn’t support a live booting while there are many live linux distros.

Software -

This is the main disadvantage of Linux. There are only few 3rd party software for Linux. You might have some kind of alternatives but those might not good as windows products. For example macromedia products are the ideal tools for the web publishing; there is no good alternative for those in Linux. And most of the games are only for Windows. So, regarding the software Microsoft is in the lead.

Security -

There is no point of even talking about this. Linux is much more secure than Windows. There are thousand of security holes in Windows and very few in Linux. And the Linux bugs are always quickly fixed by the community.

So, as you guys can see Linux is much better than Windows? But why the people are still using Windows? That’s a topic to discuss and gateway to improve linux. Get back to you in another article.

The Start - joy of open source

Thursday, January 19th, 2006

Well! Well! This is the begining. The main purpose of this blog is to share my experience with you. Yeah! probally it will be about programming, open source, may be some electornics, etc.

Yesterday (rather today morning, around 2 AM), I managed to install wordpress blog on our server. As they always say, it is five minutes install proccess. It was even less than five minutes. Really simple bloging software.

Then the next step was to download a new theme for it. It was also really simple. Just running a wget and unzip. It installs the theme automatically. Then It came to configuring. As you know, a usuall content management system/blog have a admin section to add and remove portlets/menues, edit navigation bar. I was looking all over the place, but the wordpress doesn’t have a section like that. You can create pages, but there is no way to add those into the navigation bar. So, I had to go through
the php code to edit the navigation bar. And then the portlets, I had to edit the code to remove portlets. But anyway, the code is nicely written, so that it is very easy to edit. It will only take few minutes to change the code. Yeah! of course after spending several minutes to find out there are no options for those features.

Except that, the wordpress blog seems to be nice. The main advantage is, it is very simple, so that you can easily customize it. The point is if you have experince with php and html, I think wordpress blog will be a great tool for you.

That’s about installing, and configuring. After configured it, it was too late in the night and i went to sleep. Then the next day, or same day, I had a big problem. WHAT TO WRITE! So, after thinking several HOURS, i decided to write about this wordpress it self.

Anyway, i’ll be writing about my experince about open source products like wordpress, various programming tricks, libaries, etc. So, If you are interested about those, just drop in here once a day(may be once a month ;-)) and check wether there is something new.

All comments are welcome!