[philiptellis] /bb|[^b]{2}/
Never stop Grokking


Sunday, March 27, 2011

HTC Freestyle: First Impressions

I got an HTC Freestyle from AT&T today. It was free, so I can't complain about the price, however it's a bit of a downgrade from my E71. First, what I like about it.

It has a decently sized touchscreen, and the Twitter+Facebook app is pretty decent. The browser is WebKit based and handles CSS @media queries correctly. It even switches correctly when you rotate, which the iPhone gets wrong.

On the downside though, rotating from portrait to landscape is not automatic. You need two clicks to tell the browser that you've rotated. No accelerometer in this phone. Which brings us to the things I don't like about it.

No GMail and GMaps apps for it. Since the primary reason I went in for a smartphone was to check my email and use the GPS while I'm on the road, this makes the phone a complete non-starter. The sales rep at AT&T told me that it was an Android device, but once I got it home and looked it up, it turns out that that isn't true. It runs something called Brew MP.

Transferring contacts from my older phone is clumsy, but doable. The main problem here is that I need to use the SIM card to transfer contacts and it just doesn't have enough space for all my contacts.

I could set my ringtone on the E71 to any mp3 file that I had access to. On the HTC Freestyle, it's limited to files under 300KB. Seriously. Kilobytes. What is this? The 80's? My current ring tone on my 3 year old Nokia is 6.4MB.

After using the real keyboard on the E71, the onscreen keyboard on this device is extremely clumsy to use. I've made mistakes on every occasion that I've needed to use the keyboard. I even make mistakes trying to hit the backspace key. I guess I'll get used to this eventually, however one thing to note is that the E71 does far more with just one key than this phone can do with its keyboard. The main problem is the number of times your hands/fingers need to move in order to type or even to just select menu items.

No wifi. 'Nuff said.

Ok, so that's it for the "Smart" part of the phone. Now to the phone part.

I tried to make a call when I got out of the AT&T store. The call dropped after 3 seconds. Remember, this is right outside the AT&T store. All the phones inside the store had decent signal strength. I thought it may have been due to the battery having almost no charge (since it was a new phone), so took it home and charged it up, but it hasn't changed. On 8 out of 9 calls that I've made so far I've been unable to hear what the other party says though they can hear me.

Switching on the speakerphone requires two clicks after the call connects. On the E71 it was one click while the phone was ringing. This makes a big difference because the person at the other end has no idea what's happening while you're switching on the speakerphone. It also makes it impossible to answer the phone in speaker mode while driving.

The speakerphone sound quality is also pretty bad. It's not clear when soft, and starts jarring when loud. There doesn't seem to be an optimum volume setting for it.

All in all, this is not a phone I'd pay for.

Friday, March 18, 2011

X-XSS-Protection

Internet Explorer 8 has a "useful" feature where it tries to detect if a page is under an XSS attack. If it thinks it has detected an attack, it will disable the malicious code and warn the user about it. Sound good on the surface of it, except that it's often wrong, often with ads. In most cases with security issues, it's better to err on the side of caution, but what happens here is that IE ends up warning your users about non-existent security issues on your site. Users lose trust in your site and everyone loses.

If you already take proactive steps to protect your users from XSS attacks, you SHOULD disable the check and warning. To do this, add the following HTTP header to all your responses:
X-XSS-Protection: 0
How you do that depends on the server you're using. For apache, you'd add this to one of your apache conf files:
Header add X-XSS-Protection 0
TTYL

Saturday, January 29, 2011

Printing unicode characters in web documents

I often have to look up reference sites to find out how to write a particular character in HTML, JavaScript or CSS when that character isn't on my keyboard. This post should save me some searching time in future.

To type a character that's not on your keyboard, you need its unicode codepoint in decimal or hexadecimal. In the examples below, HH means two hexadecimal digits, DD means two decimal digits, HHHH is four hexadecimal digits, and so on. DD+ means two or more decimal digits, HH+ means two or more hexadecimal digits.

HTML

To type out unicode characters in HTML, use one of the following:
  • &#DDD+;
  • &#xHHH+;
eg:
Ɖ == Ɖ
Ɖ == Ɖ
‡ == ‡

JavaScript

To type out unicode characters in JavaScript, use the following:
  • \uHHHH
eg:
 == \u2021

CSS

To print out a unicode character using CSS content, use the following:
  • \HH+
eg:
 == \2021
(Note: the CSS example that I've used here only works in browsers that support the :before pseudo class and the content rule, but in general you can use unicode characters anywhere in CSS.)

URL

URL context is different from HTML context, so I'm including it here.

To print a unicode character into a URL, you need to represent it in UTF-8, using the %HH notation for each byte.
eg:
‡ ==  %E2%80%A1
л ==  %D0%BB
' ==  %39
This is not something that you want to do by hand, so use a library to do the conversion. In JavaScript, you can use the encodeURI or encodeURIComponent functions to do this for you.

End notes

Use escape sequences only in two cases.
  1. Your editor or keyboard doesn't allow you to type the characters in directly.
  2. The characters could be misinterpreted as syntax, eg < or > in HTML.

References and Further Reading

  1. List of Unicode Characters on WikiPedia
  2. UTF-8 on WikiPedia
  3. Unicode and HTML on WikiPedia
  4. JavaScript Unicode Escape Sequences on Mozilla Developer Network
  5. Richard Ishida. 2005. Using Character Escapes in Markup and CSS in W3C Internationalisation.

...===...