Chris Nizzardini, Salt Lake City Utah, Web Developer Specializing in LAMP+Ajax Since 2006

My Blog

Here is my awesome blog. You can find information on programming, linux, documentation, tips for code and database optimization, my thoughts and rants, and whatever else I feel like sharing. Feel free to contribute to the blog by posting comments and asking questions.

Archive for August, 2007

rsync debian linux

Posted by chris on August 10th, 2007 Comment(1)

Install rsync on the server you want to backup apt-get install rsync

To backup the entire server create a cron job with the following command in it (you can choose how often you'd like it to run yourself if you know how the time syntax in a cronjob, otherwise search the blog for information on crontab):

rsync -a -e ssh / username@10.10.10.10:/path/to/destination/

Since you will be doing this over SSH you will be prompted for a password, but we can't really enter in a password if this is a cronjob. So on the source system and source user that the cron job will run as enter in the following command and when it asks for a password leave it blank, take the default file location:

ssh-keygen -t rsa

Do the same thing on the destination system, but remember to run the command as the user who will be logging in via SSH for the rsync conrjob.

Open ~/.ssh/id_rsa.pub on the source system and create a new file on the destination system called /home/username/.ssh/authorized_keys, copy the line in the id_rsa.pub to the authorized_keys files. Verify you can SSH into destination system from the source system.

This has just made your backup server pretty insecure, but since it is just a backup server you can restrict who can log into the system via SSH to the source computer.

In Linux ()

Doing Math in JavaScript umm…sucks

Posted by chris on August 10th, 2007 Comments(0)

So I’ve been writing a new point of sale page for use by our customer service reps in accepting orders by phone. It will be replacing a very old, ugly, slow, and inefficient strictly php/html web application with one which is heavy javascript/ajax/dom, css, html, and php. I noticed when working on a point of sale page for another department months ago that javascript was a pain in the ass when doing math based on values stored inside form fields.

Javascript views everything stored in a form field as a string. Which is very different for me because I’m use to the PHP model where it doesn’t classify variables as strings or integers, it just knows when to do math based on the operator you use. Now there are a few tricks I’ve come up with on my own, and a few I found googling to work around these nuances. I’d love some feedback and additional work-arounds from anyone who reads this though.

Here we go:
Read the rest of this entry »

In JavaScript and Ajax (, , )

looping through form fields in javascript

Posted by chris on August 2nd, 2007 Comments(0)

I needed to loop through a bunch of form fields in javascript, serialize them into a string, and then pass them to a PHP script for further manipulation. Here’s an easy way to loop through form fields that I found on the google:

for(i=0; i

Here's what my code ended up looking like:

var strArr = "";
for(i=0; i(<)document.posfrm.elements.length; i++)
{
	strArr += document.posfrm.elements[i].name + '*' + document.posfrm.elements[i].value + '|';
}
In JavaScript and Ajax ()