Archive for the 'web' Category

29th Apr 2008

Ouch

I went to check my site a few minutes ago and found that any page I tried to access returned a “403 Forbidden” error. scary. So I spent a panicked 5 minutes checking error logs, .htaccess files, file permissions, folder permissions…of course the last thing I checked was the permissions on my public_html folder. It seems my host hiccupped and changed the public_html folder’s permissions to 0750…so it was a quick fix (once I found it), but; note to self — check the public_html permissions first.

Posted in how-to, web | No Comments »

19th Feb 2008

Automating WordPress

Here are a few useful plugins to make you wordpress management easier:

First, an automatic plugin installer:

PlugInstaller

This plugin makes plugin management much easier — you can install from either an uploaded zip file or a url, and it is easy to enable, disable and uninstall plugins.

Next, to upgrade Wordpress itself

Of course, before you upgrade you should backup your database, which is simplified wih the use of

WordPress Database Backup

This plugin provides numerous configuration options for you backup, as well as automatic backup (on an hourly, dayly, or weekly basis).

Now for the actual upgrade:

InstantUpgrade

With minimal configuration,  this plugin makes upgrading your wordpress installation a one-click
operation.

Have you found any other plugins useful for WordPress automation?

Posted in web, wordpress | No Comments »

16th Feb 2008

Install Python module without root privileges

By default, python tries to install modules to the /usr/lib/pythonXX directory, which is write protected for any user other that root. Here’s how to get around that limitation:

In my case, I will be installing sqlite onto a web server, and so will be doing this all through cgi scripts. It shouldn’t be much different for other situations, though.

The short answer is:

run “python install.py –prefix=/home/username”

whenever you want to use the module, put this at the top of your file:

import sys
sys.path.append('/home/jabapyth/lib64/pythonX.X/site-packages')

For the long answer (how I did it),

Run this file:

#!/usr/bin/python
print "Content-type: text/html\n"

from urllib import urlopen as upen
import tarfile
import os

## the source archive URL
archive = "http://initd.org/pub/software/pysqlite/releases/2.4/2.4.0/pysqlite-2.4.0.tar.gz"

## download the archive
open("pysqlite.tar.gz","w").write(upen(archive).read())

## extract it
tr = tarfile.open("pypy.tar.gz","r:gz")
for m in tr.getmembers():
    tr.extract(m)

## run the installer
import os
os.chdir("pysqlite-2.4.0")
## this is the relevant line for most people: pass --prefix=/home/username to the install file
res = os.popen("python setup.py install --prefix=/home/jabapyth").read()
print res

Run that file, and the module will be installed

again, you will need to put this at the top of any file into which you want to import this module:

import sys
sys.path.append('/home/username/lib64/python2.4/site-packages')

Posted in how-to, python, web | No Comments »

08th Nov 2007

Onbeforeunload

If you have an ajax application and dont want the user to leave (w/o saving, of something), you can alert them to this with the onbeforeunload window attribute.

window.onbeforeunload = function () {  return "You have unsaved changes. Really leave?";}

Posted in ajax, javascript, web | No Comments »

23rd Oct 2007

Drawing Text on a Javascript Canvas

After many long hours of hard work, I have finally developed a library to draw text on a javascript canvas! Download it (or, check out this example) Now, I know I’m not the first one to do this, but I hadn’t found exactly what I wanted, so I made my own ;)

After some searching I found http://www.federated.com/~jim/canvastext/, but this was not enough: it only provides one sans-serif font. I wanted ttf fonts: complex, pretty fonts. Of course, I can’t parse ttf files with javascript (or, if i can, I definitely don’t want to ;), so I needed some way to convert ttf files to some more javascript friendly format.
For this, I found the Batik SVG Font Converter, a java tool to convert ttf fonts to the svg font format.
Now in svg format, the font file was not to difficult to parse and separate into it’s letters and individual bezier curves and lines. (look in the source if you want a more detailed explanation)

A quick overview of the functions you get:

loadFont(url,return_function); /// load a font asynchronously. return_function gets called with the loaded font as the only argument
var font = loadSync(url); /// load and return a font (a dictionary of letters)
draw_string( context, font, size, string, x, y ); /// self-explanatory

draw_center
( context, font, size, string, x, y ); /// center the text around a point

Posted in Uncategorized, javascript, web, wordpress | No Comments »

17th Oct 2007

Wordpress Plugins

Here are the Wordpress plugins I currently have installed:

* These are plugins I have made ;)

Posted in web, wordpress | No Comments »

30th Sep 2007

Browser Compatibility

If you’ve ever designed a complex website, you know that making a site browser compatible can be a pain. So here are a few tools to help you on your journey:

  • Webdevout has very good Standards Compatability tables
  • Wikipedia: — Note: Gecko=Fifefox, Trident=IE, Tasman=IE Mac, WebCore=safari
  • IEs4linux (run ie on linux)

As we all know, however, sometimes you’ve just gotta try it out. For that, we have:

What do you use? Let us know in the comments.

Posted in javascript, web | No Comments »

11th Sep 2007

HTTP Auth

heres a script for easy http authentication. It can be particularly helpful for automating data backups and the like. Source Code


Posted in python, web | No Comments »