Instead of hash like access i.e. val = hash['key']
You can achieve a prettier val = obj.key :
class Obj:
..def add(self, k, v):
....self.__dict__[k] = v
o = Obj()
o.add(key, val)
Instead of hash like access i.e. val = hash['key']
You can achieve a prettier val = obj.key :
class Obj:
..def add(self, k, v):
....self.__dict__[k] = v
o = Obj()
o.add(key, val)
If you’re using a and Flash Actionscript 2.0 Loader to import another .swf file to the stage and your ComboBox/dropdown is no longer working – all you need to do is import the ComboBox component to the library of the .fla file that contains the loader i.e. drag it to the stage then delete it.
It’s basically a bug though we’ll be polite and call it a quirk =)
Its a reference that shows how to do common operations in php, perl and python.
You can view it here.
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
]
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.
HTML email (EHTML) is a fantastic tool for businesses to communicate with their customers. You can track which links have been clicked, work out conversion rates and the marginal cost of each email is virtually zero.
Creating a reusable email template is no simple task though. Unlike in the browser world where there has been a fair amount of progress towards the adoption of uniform display standards, in the email world there has been almost none. There isn’t enough cross client support for modern web standard for you to be able to use them.
This document is a reference for the html and css that you should use to get the most consistent cross-client viewing experience. It’s aimed at web developers who code up html emails.
This document does not deal with spam filters, stuff that you legally need to include in your html allowing people to opt out, writing content, how to setup tracking with Google Analytics, software to use to send the emails, managing emails lists or other things which are all important and that you may need to research depending on your particular role.
Many clients and a total lack of consistency.
There are many webmails clients such as gmail, hotmail and yahoo mail, as well as several other ones. Some of these have ‘classic’ versions which may display the same html email differently. Most ISP’s have their own webmail clients, which are either customised versions of an opensource product such as SquirrelMail or areis something completely custom. Because your html email has to display inside a container on an html page (html within html), any webmail clients will chop and change your html in one way or another, in particular they will modify css. Surprisingly enough, GMail is actually the worst offender and has terrible CSS support. The same email even may look different in different browsers using the same webmail client with Firefox ignoring padding in GMail.
There are many desktop email clients such as Microsoft Outlook and Windows Mail. While some of these such as Mozilla Thunderbird have excellent support for web standards, others which make up a large portion of the email client market such as Lotus Notes have horrible support. Even the recent versions of Microsoft Outlook have pretty bad support for web standards.
Authoring with PHP and other scripting languages
EHTML can get very complex quite quickly so handcoding is only going to be managable for simple emails. For moderately complex emails you simply have to use a programming language to do the bulk of the world, preferably a scripting language with good xml and regular expression support such as PHP or Python. Usually the best approach to take is to create a document using a markup language (not necessarily HTML) and run it through a script that converts the markup in it to EHTML.
CSS
Cross client support for CSS is quite simply horrible and most attributes simply don’t work cross client. For instance:
Infact the only css attributes that will reliably render are:
As you can imagine, tableless layout simply won’t work, so you have to use tables for columns, though this isn’t so bad since there’s no SEO to worry about and accessibility is handled by including a plain-text version of the email.
There are 3 ways to have css in your document.
For security reasons, most clients will strip out <link> elements. Most webmail clients will either strip out <style> tags or mutilate them. This is done because it would otherwise be quite easy to be evil and write something like <style>body {background-image:url(“http://www.evilwebsite.com/evil.jpg”);</style> and completely stuff up the webmail client. Embedded css in every element is an extremely inefficient way of using css, but it’s the only reliable method for styling without resorting to <font> tags.
Spacing without CSS
You can’t rely on css padding or margins and Gmail in firefox ignores the table.cellpadding attribute. One method for doing cross client spacing is to surrond the element with a table and setting the width and height attributes of the <td> tags.
<div style=”padding:10px 20px 10px 20px;”>My text</div>
Becomes:
<table cellpadding=”0″ cellspacing=”0″ border=”0″>
<tr><td width=”20″ height=”10″></td><td height=”10></td><td width=”20″ height=”10″></td></tr>
<tr><td width=”20″></td><td>My text</td><td width=”20″ ></td></tr>
<tr><td width=”20″ height=”10″></td><td height=”10″></td><td width=”20″ height=”10″></td></tr>
</table>
Obviously this is an extremely innefficient method for creating spacing, but it’s one of few reliable ways of doing it. You will definately want to use a scripting language to do this, probalby via XML DOM. Once you do this you’ll realise that it doesn’t actually matter that your EHTML is ugly as hell because it still renders well, the only real negative is the extra bandwidth that it takes up if you are sending out thousands of emails.
Setting background-color and background-image without CSS
Use <td bgcolor=”#FFCC00″> and <table background=”http://…/.jpg” respectively
Images
By default, many clients do not download and display images because spammers often track which email addresses download images so that they know which addresses are currently active. Some people will have images permanetly disabled because they connect to the internet via 56k, 3G and prepayed connections where bandwidth is at a premium. Users are usually given an option to download images from sites they trust, though user won’t always choose to download the images.
This means that for a lot of users, they will never see the images that you spent so long creating for your email. Most clients will display an image placeholder instead which is rectangle with a 1px black border. This make it important that you fill in the ‘alt’ attribute for images so that some text displays inside the image placeholder. Also, fill in the ‘width’ and ‘height’ attributes so that the placeholder is the correct size, However, keeping with the theme of absolutely no consistency, some clients will ignore these attributes and show either a generic sized placeholder, or even no placeholder at all. This is one of the reasons why you shouldn’t use spacers because they don’t always render (spacers are transparent .gifs used to set the size of columns and rows).
Email width
Emails are typically displayed in a viewing pane so you should author your emails to be between 400 to 500 pixels wide. The wider it is, the more likely that large portions of it will be hidden from the user – not a good thing!
Some viewing panes are horizontal, some are vertical, and some clients don’t have them at all. Here’s an example of a typical vertical viewing pane. As you can see, even though the email is only about 500px wide, some of it still gets cropped off. Even more of the email would be obscured if the email was 800px wide.
Doctypes, <html> tags, etc
Do not include Doctype or any <html> or <head> or <body> tags since they don’t actually do anything and you’re not trying to follow any modern web standards. Nor is there is no such thing as ‘quirks mode’ for email clients. Most webmail clients will strip these out anyway, though some older ones won’t so you’ll end up with two sets of Doctypes etc.
Javascript and flash
These are stripped out in virtually all clients because they are deemed a security risk.
White space and line breaks
Some clients don’t ignore whitespace and insert a bunch of unwanted spaces into your email. The solution is to not have white space in between tags. Since you’re using PHP or similar to write these emails, this will probably happen by default.
However you should still insert some line breaks. Once I had an email that was getting excessively mangled in particular ISPs ancient webmail client. Turned out the problem was there was no line breaks in the email I was sending out and for whatever reason, their crummy email software couldn’t handle a really long line of html. The answer was to put in line breaks after block tags i.e. after </p>.
Specific tags
<table>
<table cellpadding=”0″ cellspacing=”0″ border=”0″ width=”450″ background=”http://fileserver.com/mybackground.jpg”>
<td>
<td valign=”top” align=”left” bgcolor=”#FFFFFF” width=”50″>
<p> / and other block tags such as <h1>, <h2>
<p style=”line-height:1em;padding:0;margin:1em 0;”>
<img>
<img src=”http://wherever.com/images/logo.jpg” alt=”My company” border=”0″ width=’450″ height=”80″ vspace=”0″ hspace=”0″ align=”right”>
<a>
<a href=”http://whereever.com” “target=”_blank” style=”color:red;text-decoration:underline;”>link</a>
<b>
References
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
}
}
(note this no longer works if you upgrade the bios — on my todo list to find out what the new char codes are)
My Acer 4250 came with rather annoyingly and pointlessly placed euro + dollar keys ‘inside’ the cursor key area.
Being a script monkey, I figured it would be rather useful to remap these keys to delete + backspace.
After much googling, the answer is to:
a) edit C:\Program Files\Launch Manager\MMKEYBD.CFG
comment out a couple of lines with “;” so that they look like this :
;Key 19 = 1,E0,33,E0,B3,F508,Euro Symbol
;Key 20 = 1,E0,34,E0,B4,F509,Dollar Symbol
this prevents acerware from hijacking these keys for its own purposes!
then download and install www.autohotkey.com
change the default script so that it reads
$SC133::Delete
$SC134::Backspace
add autohotkey to your startup folder, reboot and viola! remapped keys
This is how you fix keyboard lag issue on the Acer Aspire 4520 Gemstone.
There are two separate ways that you can fix this issue:
The first fix is quite simple – disable the touchpad. Sorry touchpad users
Press Fn-F7 to turn it off. Remember you can easily plug in a usb mouse instead, or if you’re the geeky type learn to navigate through windows using hotkeys.
The second fix is to upgrade the BIOS to the latest version. This isn’t anywhere as scary as it sounds.
You want the file FBIOS3630.zip, which you can find here
Unzip the contents and run the file SWinFlash.exe – and point it to the file Z03_3630.WPH
If you’re the highly paranoid type, then before you do this create a factory restore disc via the Acer empowering framework. However this is an official patch, so unless you’ve done something truly strange to your laptop, then there’s no reason why updating the BIOS shouldn’t work.
Don’t ask me how this one made it past Acer QA :/
You want to get dreamweaver to treat .thtml and .ctp files like php files. There are 2 config files that you’ll need to edit
View hidden file types
C:\Documents and Settings\[user]\Application Data\Macromedia\Dreamweaver MX 2004\Configuration\Extensions.txt
PHP,PHP3,PHP4,TPL,THTML,CTP:PHP Files
C:\Program Files\Macromedia\Dreamweaver MX 2004\Configuration\DocumentTypes\MMDocumentTypes.xml
<documenttype id=”PHP_MySQL” servermodel=”PHP MySQL” internaltype=”Dynamic” winfileextension=”php,php3,php4,thtml,ctp” macfileextension=”php,php3,php4,thtml,ctp” file=”Default.php” writebyteordermark=”false”>