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

Some failed attempts on PNaCl

Google has released his [PNaCl](http://www.chromium.org/nativeclient/pnacl /building-and-testing-portable-native-client) project on Google I/O 2013, which can allow user to write portable native client application. The portable native client application can be translated to native client program and executed on supported architecture.

The official toolchain contains clang frontend, which can only be used to compile C/C++ code to PNaCl application. But the PNaCl application is a subset of LLVM so I have tried some other languages have LLVM frontend. I am still working on the solution, and this article is just recording some failed attempts.

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的,在网上转了转,拼出来下面一段代码: