Quickly Building a Multilingual Program with Gettext for PHP

Gettext is a… um, I’m not sure how to describe it. It’s something like a specification, but it’s also a set of libraries. Anyway, it makes it easy to make your program multilingual~ This article is about using Gettext with PHP to develop multilingual programs and websites. ...

July 18, 2011 · 4 min

1A2B Code Explained

This was an assignment from my teacher: design a 1A2B guessing game. Before this class, I always thought 1A2B was hard to write. After the class, I realized it wasn’t hard at all. I was just too much of a homebody and didn’t even know the rules of 1A2B…. ...

July 8, 2011 · 3 min

Shuffle Algorithm (Swap Method)

The shuffle algorithm is a way to generate random numbers that never repeat. For example, suppose you need to generate ten random numbers, and all ten must be “unique.” Many people’s first instinct is to call the rand function to get a random value, store it in an array, and compare it against the numbers already in the array. That method is simple, but its performance is very poor. The shuffle algorithm introduced here is worlds apart from that approach in terms of performance. The principle behind the shuffle algorithm is actually very simple: first store the numbers in an array, then scramble them. ...

June 5, 2011 · 3 min

What Development Environment Should I Choose? Notepad? Visual Studio?

Many people probably have this question when they first start learning a programming language: what development environment should I choose? Should I use the simplest Notepad, or a powerful tool like Visual Studio? Well, it depends on your situation. There’s no standard answer. ...

May 23, 2011 · 2 min

wxDevC++ - The C++ IDE Every Dev C++ Fan Needs to Know About

A lot of people who learn C++ actually start with Dev C++. VC++ is convenient for beginners, sure, but you can’t learn standard C (ANSI C) with it, because VC contains far too many functions that belong to .NET — compile that code with another compiler and you’ll run into trouble. So beginners generally go with Dev C++ or Code::Blocks. Unfortunately, Dev C++ hasn’t been updated for several years, and it no longer supports many newer features. Code::Blocks, on the other hand, has poor Chinese support: if there’s Chinese anywhere in your code you’ll run into problems, and that includes not being able to use Chinese in comments. The one I want to recommend here, wxDev C++, actually carries on Dev C++’s characteristics while adding some new features, unlike Dev C++ which has no end of problems… So if you’re comfortable with Dev C++, I’d suggest giving wxDev C++ a try, because it’s almost identical to Dev C++! As for me, I’ll just keep using my Code::blocks~ ...

May 18, 2011 · 2 min

Making Python Module Installation Easier: easy_install Tutorial and Egg File Installation Guide

As everyone knows, one of Python’s key features is its high extensibility. You can install third-party modules to get the functionality you want. For example, if you want to write code in Chinese, you can install the zhpy module. Installing these modules is not especially hard, but it is tedious. Some only need you to click Next a few times, while others require changing system settings. Here I want to introduce a program called “easy_install”, which makes installing modules for Python much simpler. It works similarly to yum on Linux, and with it you only need one command to install a module~ easy_install can also install packages in the so-called egg format. ...

May 1, 2011 · 2 min

Using ClientLogin to Get Access to a Google Account

Google offers many APIs that make it easy for you to access its services. For example, the Google Contacts API requires you to get permission before you can use it. In this post, I’ll cover ClientLogin, which I personally think is the simplest way to get permission. It works in a simple way: you send your account name and password to Google over http, and Google sends back a string of data that includes an authorization token. With that token, you can access Google’s various services (such as Contacts, Calendar, Notebook, and so on). ...

April 30, 2011 · 3 min

【jQuery】Lazyload - Delayed Image Loading

Photography websites often have a lot of images. When visitors browse these sites, it takes quite a while to load because so many photos have to be loaded. This has a big impact on the website’s host traffic, and it also increases the CPU time on the visitor’s side a lot. Here I want to introduce Lazyload, a jQuery plugin that delays image loading. In other words, when you enter a website, it doesn’t load all the images at once. It only loads some of them, and as you scroll the browser, it loads “the images in the section you are looking at,” so the page loads faster. ...

April 27, 2011 · 1 min

[CSS 3] Tilt Images and Web Pages with transform: rotate

A while ago, the news reported that if you searched for the Chinese word “傾斜” (meaning “tilt”) on the mobile version of Google, the results page would lean to the right. This effect isn’t hard to make at all. It only takes one line of CSS, because it is one of the CSS 3 standards. For now, IE browsers don’t support this CSS 3 tilt syntax (including IE 9). Also, it isn’t really one line: each browser has its own syntax, so you have to write several lines. Hopefully this will improve in the future. ...

April 23, 2011 · 2 min

How to Convert a Decimal Number to Binary?

I expect someone will say this article is too simple again once I finish writing it... Without further ado: this week, our teacher gave our class a problem, which is how to convert a decimal number to binary. If you do it with math, it isn't hard. Just use short division and take the remainders. ...

April 16, 2011 · 2 min