— Shang Liang

Here’s the step by step instruction:
  1. Create a “installyum.sh” file: vi installyum.sh
  2. Paste the code below inside
  3. Change the [mirror-site-address] to somewhere near you. The list can be found at CentOS’s Website. Remember to change i386 to x86_64 if you are using 64 bit system.
  4. Press Shift+ZZ to save and exit
  5. Grant executable right to the file: chmod +x installyum.sh
  6. Run the script: ./installyum.sh

Here’s the shell script.

for file in \
gmp-4.1.4-10.el5.i386.rpm \
readline-5.1-3.el5.i386.rpm \
python-2.4.3-27.el5.i386.rp \
libxml2-2.6.26-2.1.2.8.i386.rpm \
libxml2-python-2.6.26-2.1.2.8.i386.rpm \
expat-1.95.8-8.3.el5_4.2.i386.rpm \
python-elementtree-1.2.6-5.i386.rpm \
sqlite-3.3.6-5.i386.rpm \
python-sqlite-1.1.7-1.2.1.i386.rpm \
elfutils-libelf-0.137-3.el5.i386.rpm \
elfutils-0.137-3.el5.i386.rpm \
popt-1.10.2.3-18.el5.i386.rpm \
rpm-libs-4.4.2.3-18.el5.i386.rpm \
rpm-4.4.2.3-18.el5.i386.rpm \
rpm-python-4.4.2.3-18.el5.i386.rpm\
m2crypto-0.16-6.el5.6.i386.rpm \
python-urlgrabber-3.1.0-5.el5.noarch.rpm \
python-iniparse-0.2.3-4.el5.noarch.rpm \
yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm \
yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm \
yum-3.2.22-26.el5.centos.noarch.rpm
do rpm -Uvh --nodeps http://[mirror-site-address]/Linux/CentOS/5.5/os/i386/CentOS/$file;
done

Read More

The library is great and it’s very simple to implement. You can follow the instructions on Google to get things ready.

When calling the function, assuming trackPageview, it will be like this

NSError* error;
[[GANTracker sharedTracker] trackPageview:@"/page name" withError:&error]

Just two things to note:

  1. the page name must start with forward slash “/”
  2. withError cannot be nil. If you set the “error” as nil, the system will give you a runtime error.

Read More

I’m spoilt by other IDEs and used to see all my files in my project folder are sorted alphabetically. Xcode does not do that automatically. The newer files are located at the bottom of the folders by default. However, you can drag and drop to arrange them.

I accidentally found out that there is a “Sort” function in the “Edit” menu. Select the folder you want to sort and apply. It will list the files by name or by type based on your choice.

I guess the reason for Xcode not to sort files automatically is due to usability issue. As I am working on my project, some files are seldom opened and some files are edited constantly. It’s quite convenient to drag the more frequently used files onto the top.

Read More

I was using ASIHTTPRequest and encountered the following error

Incorrect NSStringEncoding value 0×0000 detected. Assuming NSStringEncodingASCII. Will stop this compatiblity mapping behavior in the near future.

After I tried various ways of setting the encoding of the NSString, nothing really worked. I then dug a bit more and realized I didn’t initialize ASIHTTPRequest properly. The only right way to initialize it is through calling initWithURL. The “init” function is empty and it does not set the instance into the working state. The error is raised when you try to call setURL function of when it’s not initialized properly.

What I was trying to od is to reuse one instance of ASIHTTPRequest. After I looked into the source code, I chose not to play around with it and initialize separate instances when needed and destroy them afterward. The class is very complicated because of the threadings happening inside it. I’m sure there’s a better solution of reusing an instance, for example calling a “close” function of the instance. But I can’t find the right function at the moment.

Read More

I was following the instructions on this website but I didn’t manage to get the custom fonts working. After trying for a while I found out the problem.

Here’s the updated details of how to use custom fonts in iPhone. This is only available for SDK 4.0 and above.

  1. Add your custom font files into your project using XCode as resources.
  2. Add a key to your info.plist file called “Fonts provided by application” ( Used to be called UIAppFonts).
  3. It’s an array key.
  4. For each font you have, enter the full name of your font file (including the extension).
  5. Save info.plist.
  6. Now in your application you can simply call [UIFont fontWithName:@"CustomFontName" size:12] to get the custom font to use with your UILabels and UITextView.
  7. “CustomFontName” is not the font’s file name. It is the font name registered in the operating system. For example, if you try to use “Bauhaus Medium BT.ttf”, the “CustomFontName” should be “Bauhaus Md BT”, no extension “.ttf” is needed. You need to install the font in your system to find out what name it is. Some fonts have 2 names, you may need FontForge to find out and try which one works.
  8. So far I found out that both ttf and otf format work out of the box. I haven’t tested other font formats yet.

*Points 1-6 credit to http://blog.beefyapps.com/

Read More

I’ve just started using Sass to code CSS. I really like it because it has greatly boosted my ego as a programmer, “I can put programming logic inside my CSS!” And of course, it makes it much easier to manage a complicated CSS. However, I can’t edit scss files with Dreamweaver and I miss seeing the colorful syntax. After searching for a while, I found the solution.

less-scss-syntax-highlighting-in-dreamweaver

It’s quite easy. All you need to do is to find this file Dreamweaver CS?/Configuration/DocumentTypes/MMDocumentTypes.xml and change this line macfileextension=”css” to this macfileextension=”css,scss”.

Read More

I spent hours trying to solve this problem. If you need to load an swf which runs away3d inside it, the loaded swf may get cropped off on the right and bottom sides. Don’t try to set the clipping attributes of the View3D instance. I’ve tried all sorts of clippings but had no luck. The problem lies with the swf’s document dimension. Once that’s set correctly, the cropping problem will be fixed.

Read More

To have 2 glows, you need to apply the inner glow first then the outer glow. If not, the inner glow will not be activated. It’s true for both timeline based filters and scripted filters.

Read More

Try it Now!

[UPDATE] BIRME is an HTML5 App now and you can use it online. 

The story behind

As a web developer, I often need to resize images into a specific dimension to suit the website’s design. I used to resize images in Photoshop but I find it tedious to record actions again and again for different websites. Besides that, Photoshop is not cheap and not everyone has a (legal) copy. I tried some existing software but none of them satisfied me. Therefore, I decided to write one myself .

I’ve been searching and testing with many different platforms to develop it, C++, Java, Python and Perl. None of the above can achieve what I wanted, a single executable file without any extra libraries or dll files, no installation required. Finally I landed on PHP and I used bamcompile to generate an executable file. I still have troubles to get a Mac or Linux version of any PHP compiler to work. I may re-use my C++ code for Mac in the future and wrap it up as an .app.

Read More

From: tech-bits.com

“Some hosting providers are still using php 4 as their default for scripts, but offer php5 as well.  To force your scripts to all use php5, you can try adding this to a .htaccess file on your site:

AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php

Read More