蓝天,小湖,湖水中一方小筑

Using Rails with Redis

I have met an issue recently that the Rails site always returns 502 error for some page. After some investigation, I have found that the problem is caused by a long time query of database, which exceeds the timeout value of unicorn configuration, then the unicorn worker process will be killed and the Nginx returns 502 to user.

So the solution for this kind prblem is to put the job into some background task, and use some other method to inform the frontend when job done. Finally I choose the Redis for this task.

iOS Code Snippets - UITableView

Just created a project on BitBucket to save some iOS code snippets, and the first project is a simple UITableViewController one. The code is placed at http://goo.gl/0ZrcA. The text above is the introduction text for that project, please reference the code for detailed information.

@property and its attributes

Recently working on iOS project, and have met some problems while using the attributes of @property. I have searched some documents and here is my idea about this.

Change font size of UITextView dynamically

I am working on a UITextView related problem recently, the widget, which have a fixed size, but need to show all content passed in. The text passed in have different length, so the font size should be different. The code snippet below will change the font size dynamically based on the text. // Set the text before setting font size my_text_view.text = foo_text; // Set the default font name and size int pre_defined_font_size = 14; my_text_view.

Show alert box in calendar operations of iOS6

With the new permission schema in iOS6, app should acquire authentication before accessing calendar. So the code for calendar operation should be surrounded like this: EKEventStore *eventStore = [[EKEventStore alloc] init]; EKEvent *event = [EKEvent eventWithEventStore:eventStore]; [eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) { if (granted) { // Calendar operation } }]; As you can see, the code for calendar operation is written in a block. After the operation completed, you may want to show customer an alert box to say the operation is done.

Compile Object-C program in command line

Recently I am working on an iOS project, and I am getting interested in the language itself. But it is inconvenient to start Xcode for each program, especially for program without UI elements in. So I want to set up a command line environment that can compile and execute ObjC program.

Invoke map app in iOS app

最近在写个app,要调地图来展示一个地点,于是就有了三种选择:ios5之前的, 装了gmap的ios6和没装gmap的,在网上转了转,拼出来下面一段代码:

Playing MongoDB with Rails

This post will try to implement a web app used for recording mobile phone of cheaters. This idea is came from cooler@linuxfb, and I have used this for a presentation about GAE on 2009, and here is the slide.

NOTE: Code still under developing, the Git repo is shown at the end of article.