jump to navigation

rsync debian linux August 10, 2007

Posted by chris in : linux , 1 comment so far

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.

doing math in javascript umm…sucks August 10, 2007

Posted by chris in : ajax/dom/javascript , add a comment

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:
(more…)

word press spam stopper August 10, 2007

Posted by chris in : rant , add a comment

I was receiving about 50 spam comments a day to my blog, since I moderate all comments this was becoming a pain in the ass. So I installed this: http://blue-anvil.com/archives/wordpress-comment-spam-stopper-plugin#download which asks whether fire is hot or cold. This cut the spam in half, but I suppose some bots have been programmed to answer this question.

So I setup the Akismet plugin which compares a post to some database or algorithm to determine if its spam or not. Since implementing these two plugins…zero spam. I will probably just get rid of the comment moderation thing soon.

looping through form fields in javascript August 2, 2007

Posted by chris in : ajax/dom/javascript , add a comment

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 + '|';
}