CSS hacks and Cross-Browser Compatibility August 3, 2006

Posted by Predrag in : Resources and Links , add a comment

This is a great starting point for every HTML coder and Web Designer who wants to pass over to pure XHTML/CSS coding. Cross browser compatibility is the thing I find most annoying in this field, and I looked for this kind of table for a while.

Take a look at this List of CSS Hacks and start your fight. Below the table you’ll find a lot of useful links too. Simply, one great web page.

rsync - synchronize web server and your local computer July 20, 2006

Posted by Slobodan Kovacevic in : Resources and Links , add a comment

When developing sites it’s always a pain to upload updates on server, i.e. to synchronize server with local copy of the files. This is especially true if you have a site which you don’t keep under version control (although there is no good reason for that) or if your hosting company doesn’t have CVS / SVN client installed so you cannot simply update server working copy. So usually you are best of always uploading the whole site.

But if you have SSH access to your server (and most decent hosting companies will give you SSH) you may use rsync to upload only changed files from your local computer to server. If you have Linux you probably already have rsync and if you use Windows you’ll need to use Cygwin (just look at any of these for Windows rsync install instructions).

The command itself looks like this:

rsync -e ssh -av /path/to/local/copy/ yourusername@yourserver.com:/path/to/www/server/copy/

When you execute (obviously you’ll have to change command a bit to reflect your real paths) it will ask you for your password and upon login you’ll get something like this:

building file list ... done
./
production.php
sound_and_light.php
specialist.php
user-edit-process.php
user-logout.php
user-sendemail.php

sent 1942 bytes  received 158 bytes  113.51 bytes/sec
total size is 1692  speedup is 0.81

That’s it, files on your server have been updated and they are exactly the same as those on your local computer.

Main advantage when using rsync is that it will only upload files that have been changed, so you won’t have to upload everything whenever you want to update server files - this will save you a lot of time.

Although command might seem complicated it’s actually pretty straight forward. You are just telling rsync that you want to synchronize first dir with second one which happens to be on server. It also contains couple options:

‘-e ssh’ - tells it to use ssh to connect to your server.
‘-av’ - tells it to be verbose and use something called ‘archive mode’ (which basically says you want to copy everything in this dir and to preserve file time stamps).

You can also use rsync for much more than this, for example you can synchronize two servers, set it up to run as cron script to perform daily synchronization / backup or even just make local backup copies of your files.

How to sort MySQL results ignoring definite and indefinite articles (the, a, an) July 14, 2006

Posted by Slobodan Kovacevic in : Resources and Links , 7 comments

We recently had a problem - we needed to sort MySQL result based on Title column, but while sorting we needed to ignore both definite and indefinite articles (i.e. ‘a’, ‘an’, ‘the’).

Although this is an frequent request (people mostly want to ignore articles when sorting), we didn’t find a lot of solutions. Those which we found usually involved suggestions like “just put ‘the’ in the end when inputting data” or “add another column in which you can enter whatever you want and use it to sort”… All those solutions work and can be used, but also all of them are unacceptable because they unnecessarily ask from user to perform additional operations.

Finally we stumbled onto a thread on Site point MySQL: Proper sorting of a column which has a solution in a very last post.

Here is the query (slightly modified/formatted) that performs sorting ignoring articles:

SELECT Title,
	CASE WHEN SUBSTRING_INDEX(Title, ' ', 1)
			IN ('a', 'an', 'the')
		THEN CONCAT(
			SUBSTRING(Title, INSTR(Title, ' ') + 1),
			', ',
			SUBSTRING_INDEX(Title, ' ', 1)
		)
		ELSE Title
	END AS TitleSort
FROM music
ORDER BY TitleSort

What it basically does is that beside actual Title column it also adds a second column called TitleSort which contains Title without articles and so it can be used for proper sorting.

The query logic is simple. First determine if the first word (i.e. everything from start to first space) of the Title is ‘a’, ‘an’ or ‘the’. If it is, then it will move it to the end of the string (for example, “The Best Of” will become “Best Of, The”). Otherwise it won’t touch Title and TitleSort will be exactly the same. Of course in the end it sorts everything according to values in TitleSort.

How to add multiple files to Subversion July 10, 2006

Posted by Slobodan Kovacevic in : Resources and Links , add a comment

After switching completely to Ubuntu I also had to switch from TortoiseSVN to plain svn command line. The problem I have is that I don’t see any way to add multiple files to SVN with one command.

I want to be able to add ALL files that aren’t under Subversion version control and use a single command to do it (as opposed to issuing bunch of ’svn add file1 file2…’ commands). I’d like to have something like:

svn add ./*

Now since I’m lazy and not exactly an shell scripting expert I found a someone else’s solution to this problem. In a blog post add multiple files in subversion at once proposed solution is to use following line (it’s a slightly modified version of original line):

svn st | grep "^?" | awk '{ print $2}' | while read f; do svn add "$f"; done

Basically, it will first list all files that have been changed, then filter out those that have ? as status (hint: files that aren’t under version control), extract file names and then for each file issue a separate ’svn add’ command. I just tried it and it works great.

GMail Drive shell extension March 16, 2005

Posted by Slobodan Kovacevic in : Resources and Links , add a comment

When GMail appeared almost instantly there was a Linux program that enabled you to mount your GMail account as 1GB drive on your local system.

Today I stumbled upon same kind of program, but for Windows. If is called GMail Drive shell extension and it will make your GMail account act as ordinary storage medium. You can do all normal stuff, like drag&drop, copy, make folders…

Although this tool works perfectly author states that there are some limitations, as well that changes at GMail might either block use of this program or make it temporary “broken”.

Prevent content / bandwidth theft April 30, 2004

Posted by Slobodan Kovacevic in : Resources and Links , add a comment

Recently we had content theft problem on one of the sites we worked on. Content theft or bandwidth theft occurs when somebody links directly to an image (or any other file) on your server and displays it on their page.
(more…)

B-MAN Stock Photos April 13, 2004

Posted by Predrag in : Resources and Links , add a comment

While I was seeking for inspiration throughout the Net one place jumped to my face. B-MAN has excellent royalty free stock photos, some very interesting tutorials.

And A LOT of inspiring stuff! Check it out now!