Skip to main content

Posts

Showing posts from April, 2008

Inspecting object in javascript

An interesting problem is to inspect unknown objects in javascript. Found a good example of how to do it here. Just to rehash in case the site move:

function inspect(obj, maxLevels, level)
{
var str = '', type, msg;

// Start Input Validations
// Don't touch, we start iterating at level zero
if(level == null) level = 0;

// At least you want to show the first level
if(maxLevels == null) maxLevels = 1;
if(maxLevels < 1)
return '<font color="red">Error: Levels number must be > 0</font>';

// We start with a non null object
if(obj == null)
return '<font color="red">Error: Object <b>NULL</b></font>';
// End Input Validations

// Each Iteration must be indented
str += '<ul>';

// Start iterations for all objects in obj
for(property in obj)
{
try
{
// Show "property" and "type property"
type = typeof(obj[proper…

Using firebug in Ubuntu Hardy Heron

*Update* Yesterday kaeru pointed out that firebug from the ubuntu repo works with the default firefox 3 beta on Hardy. Just tried it and I'm glad to report it does work very nicely. No more need for this workaround.. Just look for it in synaptic or apt-get install firebug.

What can I say? Ubuntu is pretty bleeding edge. :P It comes with firefox 3 beta 5 which is pretty slick. But there are still a lot of add-ons which do not work with firefox 3 beta. Earlier on I've blogged about using the 1.1 beta of firebug with firefox 3 beta. It works pretty well on my home box which runs arch linux. But on my computer at the office running on Ubuntu, firebug doesn't even come out. So I had to find a way around.

Luckily Firdaus of OSCC showed me that you actually can install Firefox 2 on Ubuntu. It's still in the repo and you just have to select it with synaptic or apt-get 'Firefox-2'. But the default installation will share the same default profile of Firefox 3 and so will b…

VirtualHost in apache

Finally understand it after reading:
http://www.onlamp.com/pub/a/apache/2003/07/24/vhosts.html?page=2
I was having lotsa trouble understanding why wasn't my rules applying to the vhost I was setting up. But after reading that I know you weren't suppose to create multiple NameVirtualHost entry. Just one. The ServerName inside the VirtualHost block will determine whether that block applies to the query or not.

Using ssh and scp without a password

ssh and scp are very useful for making sure you work in a pretty secure environment. But sometimes it can be a hassle if you have to keep on keying in your password to login many times to the server or you might need to write a backup script but do not want to write your password in the script then I have found a solution at https://help.ubuntu.com/community/SSHHowto#public-key-auth.

Basically what you need to do is copy your public key to the authorized keys file on the server. If you haven't got a public key yet just type in:

ssh-keygen -t dsa

And that will create an id_dsa.pub file in your ~/.ssh folder (By default, you can set it in other places if you want). Anyway, copy the content of that file (it should be just one line) into the ~/.ssh/authorized_keys file on the server you want to login. Now whenever you ssh username@server you'll access it straight away without any password. And scp also works without password so you can write those scripts.

Setting up trac in ubuntu

After looking for quite some time finally found and easy guide to install trac on ubuntu at http://code.softwarefreedom.org/projects/backports/wiki/TracFastCgi. So I've got it up and running and uploaded one of the first Abdullah Solutions project we did. E-Punch is an online punch clock where you clock in by using a login. It checks your ip to make sure you are in the local network, and there is even a module to use a fingerprint reader. But the fingerprint reader interface was written using VB though and is not included in this folder. I am yet to set up svn so that you can download it but you can already browse it on trac at http://abdullahsolutions.com/trac/epunch

Firebug for Firefox 3

Are you using Firefox 3 Beta? You need to use Firebug but when you check the Extensions page the Firebug is not compatible with Firefox 3 Beta? Well.. here's the solution for you. With beta software use beta software. Go to http://www.getfirebug.com/ and download the 1.1 Beta. It works in Firefox 3 Beta and that is GREAT.. :)

Getting postfix relay to work with godaddy.com

Alhamdullillah after days (and I mean literally days because each day I can spend only a few minutes on this problem) I have finally got it working. To set up postfix to use relay with authentication, just ask the oracle. But to get it working with godaddy? I finally gave up and sent them an email. And in their reply was my answer:
Username: Your full email address (i.e. person@domain.com)
Outgoing Mail Server: smtpout.secureserver.net
Outgoing Mail Server Port: 25, 80, or 3535.

And so first I tested the ports. After telneting the host and ports I finally decided that most probably would work best because the server response has the word 'auth' in it (I have no idea whether it's even relevant or not). Anyhow changed it my /etc/postfix/main.cf to use the 3535 port:
relayhost = smtpout.secureserver.net:3535

And the most important part is the username. It is person@domain.com. It is the person@domain.com you registered your free mailbox with. Not your login name to godaddy. Use the…

WebDav works :)

Alhamdullillah.. finally got webdav in plone not only working, but rerouted through apache lak tu... :)

First step, enable webdav in plone. Go to the zinstance/etc/zope.conf file and unremark the webdav part.

<webdav-source-server>
# # valid keys are "address" and "force-connection-close"
address localhost:1980
force-connection-close off
</webdav-source-server>

And restart your zope. That ought to make it listen to port 1980 on localhost for webdav connection.

Then go to your apache web root folder and add a folder with the same name of your plone instance. Inside there put a .htaccess file like this:

RewriteEngine on
RewriteRule ^($|.*) http://localhost:1980/dev/$1 [L,P]

And that will redirect any access to your folder to the proper port (Note: because you can't use VirtualHostMonster for webdav, it has to be in the same folder as your plone instance. You can put the redirect to your plone instance in a different folder and redirect it from there w…

Use rsync to copy files

Finally took time to learn rsync. Great stuff. Can copy gigs and gigs of files real fast. Learned it from http://www.physics.queensu.ca/Computing/Docs/HOWTOs/rsync/. Basically all I needed to do was:
rsync -av -e ssh username@host:/source/directory/ destination/directory

Or if you need to ssh over a different port you would do something like this:
rsync -av -e "ssh -p 443" username@host:/source/directory destination/directory

-a for archive. -v for verbose. -e to specify to use ssh.

Setting up awstats in ubuntu

Finally my server at abdullahsolutions.com has awstats after delaying to install it for so long. The steps I follow were found at here http://www.petersblog.org/node/697 . Here they are:
Install awstats package Edit a file called /etc/awstats/awstats.hostname.conf where hostname is the hostname. Put something like this in it: LogFile="/var/log/apache/access.log"
LogFormat=1
DNSLookup=1
DirData="/var/cache/awstats/"
DirCgi="/cgi-bin"
DirIcons="/icon"
SiteDomain="hostname"
AllowToUpdateStatsFromBrowser=1
AllowFullYearView=3
Make a directory called /var/cache and chmod it 777 so it can be used from the web server Copy icons to web directory: cp -r /usr/share/awstats/icon /var/www/icon
Run this to update databases: /usr/lib/cgi-bin/awstats.pl -config=hostname -update
In your web browser, go to the url: http://hostname/cgi-bin/awstats.pl?config=hostname
Study the stats in quiet awe Edit crontab to update stats automatically every night:�…