About roopunk

Just your usual techie.

Submitting a form via AJAX

Ok so here is a very simple yet descriptive example how web-forms can be submitted using AJAX. This is an advanced tutorial, so although I’ll try to explain everything, I am assuming that the reader has a basic understanding of php and javascript.

AJAX is Asynchronous JavaScript And XML. Its a client side method to communicate data with a server. Asynchronous means that this communication can take place without interfering with other client side processes. (As we’ll see later, the asynchronous part is optional). Javascript is the main framework where AJAX works and XML is a format in which data might be communicated. Although this is not necessary. Data might be communicated in text, JSON, etc formats also.

Lets jump right in and look at this live demo.

Ok, lets look at the code now. The HTML structure is something like this:

Continue reading

Changing Body Background Image Using Javascript

Things are getting weirder.
So I was trying to set the background image of a website using javascript. The requirement was to set an image as a background and then setting the parameters background-position as center and background-repeat as no-repeat. So here was my initial code:

document.body.style.background = “url(images/middle-bg.jpg)”;
document.body.style.background-position = “center”;
document.body.style.background-repeat = “no-repeat”;


I tried variations, searched the forums. There were variations like
Continue reading

Image capturing in matlab

If you are using a laptop with a camera. Then this is how one can open the camera in MATLAB.

Web cameras are viewed by Matlab as adapters. So to use the webcam we need to know the adapter name of our webcam. In most cases it’s “winvideo”
So to know that: we type the following command.

So easily one can see that the installed adapters in my system are ‘coreco’ and ‘winvideo’
Now to use that adapter we need to make an object for it. This is how it’s done:




This creates an object to handle the web cam and can be henceforth used to operate the webcam.
The following simple command lets you preview the camera output.
voila, Now don’t blush. 🙂

Difference between ROM and PROM


ROM : Read Only Memory
PROM : Programmable Read Only Memory

It had me confused for some time. But now I know for sure.

The similarity between ROM and PROM is that the program can be burned only once in both of them and it stays there forever. For the difference part, there are two major differences:
1. When the power is turned off to the system, PROM retains the data in it while it is erased in case of ROM
2. While to program is burned in ROM at the time of manufacture, in the case of PROM, nothing inside the memory at the time of manufacture. For burning program into it, a special hardware is required known as PROM programmer or PROM burner.

I couldn’t find a proper video programming the PROM, but here is something similar for EPROM.
PS: Hey, an interesting thing about EPROM is that it is erased using ultraviolet light. Fancy watching that live.

Sharing files with a google group using google docs!

Hey fellas,
Here’s what I have after an evening head-scratching finding some way to allow users having gmail accounts to share files with google groups, since now the file sharing feature is being discontinued.
Yeah I know, you might shout at me to use yahoo groups instead. But hey reconsider the conditions highlighted in the above statement.
I wouldn’t mind a little appreciation. 🙂

Line space in HTML

Cool, so after some frustrated googling, I found out a way to give spaces in html. Usually if you give lots of space between text in html it shows up as only one space.
To give more than one space, one can use this character:  

So if in HTML editor, I write something like:
Hi            there

then in the html page it will show up as:
Hi there

That’s where   comes in handy. So instead of space you’ll have to write something like:

Hi       there

to produce the desired effect.