Why Write a Blog

Recently, I’ve been reading Liu Weipeng’s “Dark Time”. There’s a chapter discussing why one should write a blog, which resonated deeply with me. Borrowing the thought process from “Dark Time” on this topic, I want to combine it with my own experiences to record my views. My Blogging History I created my first blog in the third year of middle school. During a computer class, the teacher introduced the concept of blogs, so I followed the trend and applied for a free blog, uploading a few photos I had taken. Apart from those initial uploads, I never updated it again, and over time, I even forgot the address. Later, I sporadically created several blogs, each time driven by a sudden urge to express something, but once the blog was set up, I would forget what I wanted to say, leaving it unfinished. In college, while working on ACM problems, I started a Sina blog to post solutions, but that too ceased updates after a few days. The blog I have now was created during my senior year internship. I encountered a challenging problem at work, and after consulting various fragmented resources to solve it, I felt a sense of accomplishment and wanted to document the thought process. So, I set up a WordPress on SAE, which is the blog you see today. It wasn’t until then that I truly began blogging. ...

June 2, 2013 · 4 min · Zhiya

iOS6 Screen Rotation Issue

When creating xib files using the iOS6 SDK, AutoLayout is enabled by default. AutoLayout is a new feature introduced in iOS6 that allows for automatic layout through relative positioning, adapting to various screen resolutions (as iOS device resolutions are likely to become more diverse). If a project using AutoLayout is run on systems below iOS6, the program will encounter errors. Therefore, by disabling the AutoLayout option in all xib files and running the project again, it was found that projects originally set to display in landscape mode had switched to portrait mode, rendering all landscape settings ineffective. The solution is to add the following code in the Controller where landscape mode is needed. It’s best to set self.window as a RootViewController and then add the following code in the RootViewController: ...

May 21, 2013 · 1 min · Zhiya

AS3 Download Manager

In my work, I needed a global download manager within an application, so I implemented one using AS3. An array is used to store the download list. When a new download item is added to the list, it checks the list. If there are items not yet downloaded, it downloads that item. Once the download is complete, it checks the list again. When there is a download in progress, no new download processes are added to ensure that there is only one download process at a time. GitHub: https://github.com/simpleapples/AS3DownloadManager ...

April 24, 2013 · 1 min · Zhiya

Creating a JavaScript Runtime Environment for Vim

When testing JavaScript code, I usually write an HTML page, place the code in the body, execute it in the browser, and then check the JavaScript console. Suddenly, it occurred to me that I could use a JavaScript engine to execute JS directly. So, I decided to give it a try. After a quick Google search, I found Mozilla’s SpiderMonkey engine and Google’s V8 engine. Since V8 is widely recognized for its speed, I decided to go with it. However, after looking at some online articles, I realized that installing the V8 engine is quite troublesome = .= Then I remembered that Node.js seems to use the V8 engine, so I could just use Node.js to execute JS. I went to the Node.js official website to download the latest version. There is a pkg installer for Mac, and after installation, I needed to configure Vim to use Node.js to execute JS files. Next, I modified the .vimrc file. In the .vimrc file, I added a compile command for JavaScript files: node filename.js, as shown in the image. ...

March 7, 2013 · 1 min · Zhiya

iOS6 Text Centering Issue

After upgrading Xcode, I hadn’t used it much until today when I tried to set the centering property for a label. I discovered that the previously used text centering property, UITextAlignment, is now deprecated. See the image below. Upon checking the documentation, I found that iOS6 introduced a new property, NSTextAlignment. The new property includes Justified and Natural, so out of curiosity, I tried the Natural property on a label. It resulted in an error. ...

March 5, 2013 · 1 min · Zhiya