How to secure your Wordpress blog by setting up SSL

The latest (from version 2.6) version of Wordpress has support for making the admin section of your Wordpress site use SSL or Secure Sockets Layer. This means that you’d be able to encrypt your admin pages if you want to.

Encrypting the admin pages provides more security for your Wordpress site. In order to enforce SSL in your admin pages you need to do things a couple of things.

Read more of “How to secure your Wordpress blog by setting up SSL” »

A simple way to find out the location of a running shell script

When a shell script is executed, the default directory would normally be the current directory of the user when the script is called. If you get into a situation wherein you want to determine the location of the shell script when it was called by the user, you can do the following within the shell script:

fullpath=`which $0`
scriptdir=`dirname ${fullpath}`

The scriptdir variable would contain the directory where the running script is stored. The which program returns the full path of the called script (e.g. /usr/bin/mybashscript.sh) while the dirname program returns the directory portion of the argument which was passed to dirname.

One use for it would be if for example you need to know where the shell script was stored because you need to call another script that was also stored in that directory when it was installed.

Making CSS work with Firefox and Internet Explorer

I have just finished up on updating my Javamidlet.com web site. It’s been almost a year since I’ve made any changes to the site’s wordpress theme. The theme I use on Javamidlet was one of my early themes when I was still learning how to make them in Wordpress.

I’ve learned quite a few from the exercise and one of them was — it’s really quite a challenge to have a web site theme that works on majority of the web browsers — Firefox, IE7 and IE6. Working with Firefox (both for Linux and Windows) and MSIE 7 was easy but you’ve got to give credit to IE6 for being such a creation! It’s a good thing that less and less people are using IE6.

Read more of “Making CSS work with Firefox and Internet Explorer” »

How to check if a Javascript variable is an array

Looking for the simplest way to check if a Javascript variable / object is an array? Here’s a simple way on how to check for an Array variable in javascript:

function isArray(variable) {
if (variable.constructor == Array)
return true;
else
return false;
}

or better yet, just do this:

function isArray(variable) {
return (variable.constructor == Array);
}

Bash script to empty a mysql database

I wrote a bash shell script that deletes all the tables in a mysql database and I thought I’d just post it here in case anyone might find it useful. It accepts one required argument which is the database name and one optional argument which is the username with DROP/CREATE DATABASE privileges to dbname .

#!/bin/bash
if [[ ${1} == '' ]]
then
echo “”
echo ” `basename ${0}` {dbname} [{user}]”
echo “”
echo ” {dbname} - is the name of the mysql database to zap”
echo ” {user} - optional, user ‘root’ is used as default”
echo “”
exit 1;
else
read -p “Are you sure you want to empty ${1} [Y/N]? ” ans
if [[ ${ans} == "y" || ${ans} == "Y" ]]
then
user=${2:-”root”}
echo -n “Using mysql user ‘${user}’, ”
mysql -u ${user} -p -e “drop database ${1};create database ${1};” && echo “${1} emptied.”
exit 0;
else
echo “Aborted.”
exit 1;
fi
fi

Note: Oh and be careful in using the script ‘coz it will erase all the data in your database so make sure you have backups. ;-)

How to empty a mysql database

This morning I was doing some tests and I found myself having to use a web-based mysql tool called phpmyadmin to delete all the tables in a mysql database.

Since I was to do it several times, I decided to use the command line interface program mysql. I was kinda surprise that I didn’t find any single command to drop all the tables, anyway deleting all the tables can be done by issuing the following command:

sh$ mysql -u username -p -e “drop database dbname; create database dbname;”

You will need to specify a username with drop/create privileges for the dbname database. It will then prompt for the user’s password when you hit enter on the command line.

Using mailto links in web pages

Yesterday, I found myself in a situation, wherein I wanted to provide a mailto link that will not only include a subject but also an initial body when a web site visitor clicks on the link.

I was quite sure that it was possible but couldn’t remember how to do it so after some googling, I found a “MailTo Syntax” page that describes how it’s done.

In the message body you can actually include html links that a person can email to friends. You’ll just have to url encode the text so that it will be properly included in the email message body when the user clicks on the link. If you need a url encoder, you can use this online form.

Project Gazell source code released to public

In an effort to improve private torrent trackers the Project Gazelle team has created a reliable, lightweight and secure codebase. It was designed from the ground up to be secure against SQL and XSS injection attacks and at the same time be able to handle thousands of users.

The source code, which is currently undergoing beta, is available via the Project Gazelle SVN. The source code comes with a C++ based tracker, PHP frontend and complete administration panel.

You can find more info at the Project Gazelle web site.

The .NET Source Code soon to be released

Looks like Microsoft will be releasing the source code for the .NET framework for the soon to be released version 3.5 of the framework. ScottGu has made the announcement on his blog.

This is welcome news for .NET developers because it will help a lot in creating and debugging .NET software. The .NET source code release offers integrated debugging in Visual Studio 2008 allowing developers to step thru the framework’s source code.

How to pass data in neutral way in C++

I have often thought what would really be the easiest, efficient (in terms of coding, performance, storage) way of passing data across a network or even just among several software applications.

Different solutions have been available depending on different applications. The current trend of using XML as a universal way to pass around data has been widely accepted.

Read more of “How to pass data in neutral way in C++” »