Archive for the ‘Other’ Category

Open source language reference

Sunday, November 16th, 2008

This is a project that is currently uncomplete, though i’ve put it online anyway to motivate myself to complete it faster =)

Its a reference that shows how to do common operations in php, perl and python.

You can view it here.

Microsoft Word characters to ASCII

Tuesday, October 28th, 2008

Microsort Word uses some characters that are in the Windows-1252 character set in the range x80-x9F range that aren’t used in the Latin-1 (extended ASCII) character set that it’s derived from. Here’s a quick reference for converting them to an extended ASCII character set.

Written in python


conv = [
[u'\u2018',"'"], # 145 - \x91
[u'\u2019',"'"], # 146 - \x92
[u'\u201C','"'], # 147 - \x93
[u'\u201D','"'], # 148 - \x94
[u'\u2013',"-"], # 150 - \x96
[u'\u2014',"-"], # 151 - \x97
]

TSHML - two space html markup language

Thursday, September 4th, 2008

I invented an extremely lightweight markup language which is used as a shorthand to author html documents. I wouldn’t be surprised if it’s been independently developed by several (million) other developers, but in case it hasn’t, you saw it here first! :) I called it TSHML - “two space html markup language”. It was inspired by coding in Python which uses whitespace in a similar fashion.

The rules are that one element is represented on one line, attributes can be optionally quoted in strings (double quotes are slash escaped) or not quoted (though they have to be if they contain spaces), childnodes are indented by two spaces, text nodes are created by specifying an attributes named “txt”.

He’s an example: - note i’ve substituted full-stops for spaces for the indent

div.id=myid
..p class=myclass style=”padding: 0px 10px 5px 5px”
….a href=http://emtek.net.nz txt=”Click \”your mouse\” here”
..p class=myclass
….span txt=”Or click ”
….a href=http://google.co.nz txt=”your mouse”
….span txt=” here”

If you use TSHML then you’ll need to write a program to convert it to something useful, probably XML.

PuTTY SSH Keep Alive with AutoHotKey

Tuesday, August 26th, 2008

If you are having trouble with PuTTY getting disconnected after being idle, usually being kicked by a router, try running this script with AutoHotKey:

; Optional - auto login script

run, …\putty.exe -load putty_profile , , , newpid
winwait, ahk_pid %newpid%
Send xxx.xxx.xxx.xxx{enter} ; put your IP here
sleep, 1500
ControlSend, , username{enter}, ahk_pid %newpid%
sleep, 500
ControlSend, , password{enter}, ahk_pid %newpid%

; KEEP ALIVE SCRIPT:
; %newpid% will refer to the original putty window, we need to refind the
; new shell window, which we do via ahk_class PuTTY
loop
{
sleep 60000
IfWinExist ahk_class PuTTY
{
IfWinNotActive ahk_class PuTTY
{
ControlSend , , date{enter}, ahk_class PuTTY
}
}
else
{
break
}
}