Archive for September, 2007

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 »

09th Sep 2007

Defeat Comment Spam

In today’s world, it is almost impossible to have a spam-free blog without employing some counter-measut you have to compromise either the user experience or your time (using a spam filter), so what is to be done? Here is a post that very nicely describes the pros and cons of several popular methods:  http://www.baekdal.com/articles/Technology/comment-spam/

Posted in Uncategorized | No Comments »

09th Sep 2007

Site Update!

So, I finally updated this site, got it re-themed and installed wordpress. I hope to be able to post more often, now that I’m back from vacation ;)

Posted in Uncategorized | No Comments »

09th Sep 2007

Site Backup

I just finished a cPanel backup program BackMeUp. It is built in python, using PythonCard. I will be releasing the source code shortly.

Posted in python | No Comments »

09th Sep 2007

ActionScript Compiler

I had discovered mtasc(Motion Twin Action Script Compiler) several months ago while on a flash splurge, but I dug it out again today and found a nice companion for it: Flash Develop. It has very nice mtasc integration, and I decided to grease my rusty ActionScript skills. The result (of about 30 minutes of work) was Extreme Art. I plan to add some more effects….sometime :)

Posted in Uncategorized | No Comments »

09th Sep 2007

OpenGL

i finally took the jump into OpenGL, and its not as bad as i thought (althought it is far too C, if you know what i mean). The pyOlenGL module provides a full wrapper, although i would like a more pythonic layer on top of ogl, just to soften the blow. Anyway, here’s my first OpenGL program (its hoping to grow into a pong-type game)

from OpenGL.GL import *
from OpenGL.GLU import *
import pygame
from pygame.locals import *

def resize((width, height)):
    if height==0:
        height=1
    glViewport(0, 0, width, height)
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    #gluPerspective(45, 1.0*width/height, 0.1, 100.0)
    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()

def init():
    global quad

    glShadeModel(GL_SMOOTH)
    glClearColor(0.0, 0.0, 0.0, 0.0)
    glClearDepth(1.0)
    glEnable(GL_DEPTH_TEST)
    glDepthFunc(GL_LEQUAL)
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
    quad=gluNewQuadric()

def draw(x,y):
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
    glLoadIdentity()
    y=600-y

    #square((x,y,0),(x+100,y,0),(x+100,y+100,0),(x,y+100,0),(255,100,0))
    #sqaure(x,y,100,100)
    cube(100,100,0,100,100,-100)

def square(v1,v2,v3,v4,color=(255,255,255)):
    def cx(x):return (1.0/300)*x-1.0
    glBegin(GL_QUADS)
    glColor3f(*[c*(1.0/255) for c in color])

    for point in [v1,v2,v3,v4]:
        glVertex3f(*[cx(o) for o in point])
    glEnd()

def sqaure(x,y,w,h,color=(255,255,255)):
    def cx(x):return (1.0/300)*x-1.0
    glBegin(GL_QUADS)
    glColor3f(*[c*(1.0/255) for c in color])

    glVertex2f(cx(x),cx(y))
    glVertex2f(cx(x)-cx(w),cx(y))
    glVertex2f(cx(x)-cx(w),cx(y)-cx(h))
    glVertex2f(cx(x),cx(y)-cx(h))

    glEnd()
xat=0
def cube(x,y,z,w,h,d,color=(255,255,255)):
    global xat
    xat+=0.1
    def cx(ax):return (1.0/300)*ax-1.0
    glRotatef(xat,1.0,1.0,0.0)
    glBegin(GL_QUADS)
    glColor3f(*[c*(1.0/255) for c in color])

    glVertex3f(cx(x),cx(y),cx(z))
    glVertex3f(cx(x)-cx(w),cx(y),cx(z))
    glVertex3f(cx(x)-cx(w),cx(y)-cx(h),cx(z))
    glVertex3f(cx(x),cx(y)-cx(h),cx(z))
    glEnd()
    glColor3f(*[c*(1.0/255)-0.5 for c in color])
    glBegin(GL_QUADS)
    glVertex3f(cx(x),cx(y),cx(z)+cx(d))
    glVertex3f(cx(x)-cx(w),cx(y),cx(z)+cx(d))
    glVertex3f(cx(x)-cx(w),cx(y)-cx(h),cx(z)+cx(d))
    glVertex3f(cx(x),cx(y)-cx(h),cx(z)+cx(d))

    glColor3f(*[c*(1.0/255)-0.1 for c in color])

   # glVertex3f(cx(x),cx(y),cx(z)+cx(d))
   # glVertex3f(cx(x)-cx(w),cx(y),cx(z)+cx(d))
   # glVertex3f(cx(x)-cx(w),cx(y),cx(z))
   # glVertex3f(cx(x),cx(y),cx(z))

    glEnd()

def main():
    x=y=0
    video_flags = OPENGL|DOUBLEBUF

    pygame.init()
    pygame.display.set_mode((600,600), video_flags)

    resize((600,600))
    init()

    frames = 0
    ticks = pygame.time.get_ticks()
    while 1:
        if pygame.event.get(QUIT):
            break
        for ev in pygame.event.get():
            if ev.type==MOUSEMOTION:
                x,y=ev.pos
            if ev.type==MOUSEBUTTONDOWN:
                mp=1
            if ev.type==MOUSEBUTTONUP:
                mp=0

        pygame.event.pump()
        draw(x,y)
        pygame.display.flip()
        frames = frames+1

    print “fps:  %d” % ((frames*1000)/(pygame.time.get_ticks()-ticks))
    pygame.display.quit()

if __name__ == ‘__main__’: main()

Posted in python | No Comments »

09th Sep 2007

Basic AJAX Example

This is about the simplest you can get, with the XMLHttpRequest object.

var client = new XMLHttpRequest();
client.open("GET", "test.txt", true);
client.send();
client.onreadystatechange = function() {
    if(this.readyState == 4) {
        alert(client.responseText);
    }
}

The key things being

client.open("GET", “test.txt”, true);

–change “test.txt” to the file you want to call
and

alert(client.responseText);

change this to the function, doing what you want to do with the response. responseText is just a string, but you can use responseXML, which is a full document.

Posted in ajax, javascript | 2 Comments »