— Shang Liang

This may only affect Firefox on OSX Lion .

When embedding a custom font

@font-face {
font-family: "my-optima";
src: local('Optima'), url('/css/optima.woff') format('woff');
}

Try to vary name the local(‘font-name’) a bit and the problem will be solved.

Read More

Recently my EC2 server was hacked and it was totally my fault. I  enabled  password authentication and I set the password way too simple. I took a look at the log and I found out there are indeed many free people who keep trying to log in using brute force method.

To secure my server, I decided to limit SSH access to my office and home IP addresses only. Here are the steps.

  • Go to “AWS Management Console” and select “Security Groups”
  • Select the security group which is used for the instance, e.g. “quicklaunch-0″
  • Delete the existing SSH access which is set to allow any IP addresses, “0.0.0.0/0″
  • Find out what is your current IP address by searching “what is my ip” in Google (Sorry Bing, you don’t understand this yet. Maybe one day when you grow up).
  • Select SSH from the “Create a new rule” drop down list
  • Customise the “Source” field with your own IP, e.g. “212.157.7.65″ and add “/32″ at the end, which is “212.157.7.65/32″
  • Click “Add rule” and “Apply rule changes”. Now your server only allows this specific IP address to login
  • You can add multiple SSH rules with different IP addresses
  • If you want to allow a range of IP addresses, you need play around with the “/32″ part
  • An IP address has 4 parts, separated by 3 dots. Each part is 8 bit (2 to the power of 8 ) and that makes 255.
  • “/32″ means the IP address allowed to access the server must match all 4 parts (8×4)
  • “/24″ means the IP address allowed to access the server must match the first 3 parts, which means “212.157.7.XXX” is allowed
  • It’s not hard to figure out “/16″ and “/8″ require less matching
  • I’m not sure how to match a specific range e.g. “212.157.7.60 - 212.157.7.200″. Maybe “/29″ will work, but I’m not sure.

I hope this helps.

Read More

In Xcode 3, this is an option to select whether the project uses core data features. If it’s checked, Xcode automatically generates the code to set up the environment. Most of the examples about core data is based on the codes generated by Xcode. However, this feature is taken out in Xcode 4.This post is a guide of how to add the code manually in Xcode 4. Based on that, here’s my version of a simplified routine (it’s only 7 lines without the comments) .

>>Enjoy<<

Read More

Quite often, websites developed in Singapore need to be localized (translated) into other Asian languages. Here’s my experience of working on Asian fonts. This is more useful for Flash designer and developers. But since embedding fonts for HTML is becoming a norm, this may be helpful for HTML work, too.

  1. Most fonts only have English glyphs (characters) and some symbols (punctuations and copyright mark etc.)
  2. Only well established fonts have other latin glyphs (circles and funny heads on top of the letters)
  3. None of the popular fonts (Helvetica or Futura) has Chinese, Thai, Japanese or Korean glyphs
  4. Big Brands’ special fonts (Nokia or Cisco) do not support Asian languages
  5. The only one font has all characters (full unicode set) is Arial Unicode MS
  6. The default local fonts are generally very ugly. Get help from someone who speaks the language to search for a good looking font.
  7. If you embed a font with the full character set the file size will be 12 MB (and most of the Asian countries have slow internet speed)
  8. Thai characters are smaller than other languages’ characters (11px or 10px Thai words are not readable)
  9. Vietnamese characters is a mix of all kinds of latin languages (details here)

Read More

B.I.R.M.E (Batch Image Resizing Made Easy) finally gets an update and it’s a HTML5 web app now. I’ve finally achieved my goal, to make a software which does not need to be installed and runs in all operating systems. The resizing is done by Javascript so the user do not need to wait for uploading the file to the server and then download them later.

Well, it’s not perfect. BIRME uses drag and drop and File API. Recent versions of Chrome and Firefox support these functions well. Safari 6 and IE10 will be fine once they are released. I haven’t tried it out in Opera yet (to be honest, I’m not interested to find out).

This is the most useful thing I’ve ever made so far.

Read More

I had a weird error when working with Core Data. The App crashes without giving anything information. After adding break points here and there for  a few hours, I narrowed that the problem is caused by failure to retrieve the NSManagedObjectModel file. I re-created another project and re-created the xcdatamodeld file from scratch and everything works fine. I suddenly remember I edited the xcdatamodeld file with vim when entering the attributes. That must be the reason.

I’m not 100% sure what happened but here’s my guess. The data model file is versioned automatically in Xcode 4. If I edit the “content” file directly, the versioning is disturbed and the IOS won’t be able to locate the “mom” file properly inside the “momd” folder.

Read More

A gene is a long sequence of string with 4 letters, A, T, C and G. The “encryption” was figured out long time ago. Every 3 bases code for one amino acid. But, what if we look at genes from a computer graphic programmer’s point of view?

I wrote a program in Processing to “decrypt” genes in my way. I read 12 bases and convert it to a RGB color. The images are the result of such interpretation. It’s a E.Coli genome (a bacteria easily found from our backside). It’s very similar to a random noise image. However, what caught my eyes are the darker bands close to the bottom of the image. Does it mean anything?

Further study will be carried out. I’ll verify whether the dark bands correspond to any biological features. Are those areas more packed with coding genes or non-coding genes?

Another thing I would like to do is to write a program to search for a better “decryption” look up table, to see if that will yield better results. Interestingly, these kind of programming method is normally call “genetic algorithm”.

Image generated based on E.Coli Genome

Image generated with random noise

Read More

I’m very sick of this Flash session issue. I thought I had the perfect solution of passing the session id into Flash and fix the session by appending all the request, then the bomb drops to me. It doesn’t work in an iframe in IE. Apparently, IE doesn’t trust cookies set from an iframe so there goes the session. The solution is to add a header information in the backend code. Something like this for PHP.
header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
It’s not hard to find the code for other languages in Google.

Read More

http://en.wikipedia.org/wiki/Suffix_tree

Here’s the speed test. The speed boost is not obvious for daily usage but it’s very significant when the word base get larger, or it’s searching against long sentences.

Suffix tree search speed test

Read More

Facebook parameters passed to applications’ iframe is changed from GET to POST. It’s unclear whether this will be permanent. If your Facebook application uses iframe and tries to check parameters view GET method, it’s very likely to be broken now.

Many iframe applications  check ‘fb_sig_in_iframe’ to determine whether the user is accessing the app directly, not going through Facebook. Such applications will go into a looping re-directing.

To be safe, you can try to get the parameters via both GET and POST in case Facebook change it back to GET in the future.

 

Read More