Archive for August, 2005

quicker way to code in vim

Monday, August 15th, 2005

I’ve been experimenting with Thomas Link’s excellent tSkeleton plugin for the vim editor recently.

tSkeleton provides file templates and code skeletons which are parsed and expanded when you edit your code. It currently comes with templates for PHP, Ruby, vim scripting and many other languages too.

There are some parts of tSkeleton which will only work when using the gtk-gui version of vim (or the Windows version); the popup menus for example but I’m not going to let that stop me.

This is a brief outline of how I got it working after a few false starts:

  1. Download the multvals and genutils scripts that tSkeleton requires from vim.org and uncompress them until some useful directory. I put them into my /home/kguest/config/vim/scripts/ directory.
  2. Add entries to your ~/.vimrc to source these files:
    source /home/kguest/config/vim/scripts/multvals.vim
    source /home/kguest/config/vim/scripts/genutils.vim
  3. Download the tSkeleton.zip file and uncompress it’s contents into your ~/.vim directory.
  4. Add lines similar to these into your ~/.vimrc
    autocmd BufNewFile ~/.vim/skeletons/*.suffix TSkeletonSetup othertemplate.suffix
    autocmd BufNewFile *.suffix TSkeletonSetup template.suffix
  5. Next you’ll need to copy a directory or two from ~/.vim/skeletons/bits.samples/ to ~/.vim/skeletons/bits/ - I only copied the php directory over.
  6. Finally you may want to set some some details in your .vimrc so tSkeleton can expand the templates with slightly more meaningful information. I added these lines:
    let tskelUserName='Ken Guest'
    let tskelUserEmail='ken@guest.cx'

Some PHP and webdevelopment goodies.

Saturday, August 13th, 2005

Writing more efficient PHP
I found the IBM tutorial on writing more efficient PHP today. Most of it is very obvious stuff [cache values, understand the lower-level workings of the programming language in question so you can take advantage of it's design, etc, etc], says a guy with ten years experience of developing software with a variety of programming languages. But some is more cunning than obvious glaring-you-in-the-face-with-a-cheeky-smile stuff.
For example if too many GET requests are made then the web-application will seem to be much slower. So when generating PDFs, it’s good to issue both the Content-Type and the Content-Disposition headers to minimise the number of requests that the browser may make.
If you aren’t sure what’s going on in a scenario such as this and you use FireFox then you could always install the LiveHeaders plugin to have a detailed look what information and requests are traversing the connection between browser and server.

memcached
I recently discovered the memcached project as well. memcached is a distributed memory caching system like a huge big hash table shared between any mumber of servers intended for use in speeding up dynamic web applications by alleviating database load though it can be used for more generic purposes as well. I haven’t used it yet, but wish I had. It is used by Slashdot, WikiPedia and SourceForge amongst others.

Significant linux.ie update

Saturday, August 6th, 2005

I decided to have a look through the posts on the ILUG Tips forum last night and spend quite some time weeding through spam that had gotten posted to it.
Too much time.
So I’ve tweaked the code for the board so you now have to fully sign on to post a question or answer one or share a tip – this should significantly reduce the amount of spam getting through and fully justifies the extra hoops you have to jump through.

Getting addicted to Wikipedia.org?

Thursday, August 4th, 2005

Think I might be getting quietly addicted to adding contributions to wikipedia.org. Relax, I’m only joking. I’ve contributed more than my usual amount more recently is all….

Sure, over the past year or so I’ve been adding pertinent links to linux.ie articles for the Samba, JUnit, Vim and Leafnode entries on wikipedia.org. There are probably a few more I’ve forgotten and won’t be able to determine what they were, unless I go looking at linux.ie access logs, as I’d revised those entries anonymously as I wasn’t all that bothered to get a wikipedia account.

I changed my mind on Tuesday because I wanted to write an entry on Cloughjordan, which is where I’m from, basing my decision on wanting any other Cloughjordan natives that might read the entry to know that it was written by a local. I then quickly updated the relevant entries too.
After a while I decided to update some Clive Sinclair entries, as the ZX Spectrum which he brought out in 1982 is pretty much responsible for my interest in computers and Information Technology in general – I can’t believe that people are actually working on an extended version of Sinclair Basic at the moment!

I added information on SimpleTest which is a very useful unit/regression testing tool for PHP, much like JUnit is for Java.

That’s what I’ve been up to in my spare time while looking for work and accommodation in Dublin, along with working on the linux.ie site.