Posts

Showing posts from 2012

LimeSurvey Nginx rewrite rules

I just downloaded LimeSurvey, an amazing free open-source project for creating your own online surveys , and was about to install it on my own Nginx-powered server. To my surprise, there are no available Nginx rewrite rules for it on the official project website, and I didn't even find any blog post detailing such rules. So here I go again, filling the voids. This post details: - the Nginx rewrite rules translated directly from the provided .htaccess file, the small server configuration file containing the rewrite rules for Apache. - what to do after installing LimeSurvey Nginx rewrite rules The original rewrite rules for LimeSurvey are contained in this simple .htaccess file: <IfModule mod_rewrite.c>   RewriteEngine on     # if a directory or a file exists, use it directly     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     # otherwise forward it to index.php     RewriteRule . inde...

Shanghai Air Quality Index Widget (from US Embassy data)

Image
I live in Shanghai and air pollution is a major concern, especially in institutions such as schools or hospitals. It is important to give proper directives to children and elder: when the air pollution reaches a certain threshold, they should stay inside as much as possible and avoid any form of physical exercise outside. There are mainly two indices for air quality in Shanghai: the Chinese government's data and the official website of the US Consulate in Shanghai . The latter is based on an RSS feed updated every hour. In order to facilitate the display and comprehension of the data from that RSS feed, I have designed a widget (running under Windows XP/Vista/7/8) that is meant to display Shanghai's air quality index in real time - again, based on official data from the US Embassy. The widget was designed to be ran on display monitors that stay on 24/7, so it displays at the topmost  - it always shows on top regardless of other windows. The data is automatically refreshe...

JWPlayer: remembering position in video, to resume playback later

As part of my recent developments on my upload site Filetrip.net, which comes with interesting video playback capabilities, I've added the possibility for visitors who watch a video once and interrupt playback to return to the video later on and resume where they left off. In short: you are watching a video, you suddenly or accidentally close the tab or visit another site. When you go back to the video page and start playing again, the video will resume where you left off. I was wrong to assume that this was an upcoming feature for JwPlayer, seeing as one of the authors stated that they " don't support this explicitely ". So I designed it myself with minimal coding. Note that this has been tested on JWPlayer 5 and above, but I cannot guarantee that it will always work in the future. Here is how I am going to detail this tweak: 1. Introduction and requirements 2. Remembering the position 3. Setting the starting offset 4. Cookie data limitations Intro...

AVCLevels PHP Library: read and set profile level from H264 AVC-encoded video (MP4, MKV, ...)

I was stunned this morning to find out about AVC levels  (H264/MPEG-4 AVC). Basically, when you encode a video using the widespread H264 codec for the video stream, the encoder sets a flag called the "level". Wikipedia says that the level  is a specified set of constraints indicating a degree of required decoder performance for a profile . The problem I have with this is: some software and equipment restrict their own capabilities based on that level! They check the level, and if the value doesn't please them, they refuse to even attempt to play the video. What is this all about? See, I had two MP4 videos. One would play fine on my iPhone, the other refused to play (iTunes refused to copy it into my library, claiming that my iPhone did not support the video format). I inspected both files with MediaInfo , they were both encoded properly with AVC (H264) and AAC audio, similar bitrates, same resolution. After hours of testing and research I stumbled upon this blog po...

Top 3 fixes for: Internet Explorer won't start, IE7, IE8, IE9 opens then closes immediately

Image
I have been having this issue for years and I found the final solution just yesterday! So I thought I would post it here and hopefully help out thousands of other people like me. Before I explain the solution let me describe the problem in detail. For some unknown reason, I have always had this problem on my main computer with Internet Explorer 9 : whenever I want to run it, a blank window appears for 0.1 second then closes instantly , without any error message or anything. The solutions I describe are valid for Internet Explorer 7 (IE7), Internet Explorer 8 (IE8) and Internet Explorer 9 (IE9). I am running Windows 7 but the solutions also work for Windows Vista and Windows XP. There are three solutions here, among which two are the official solutions proposed by Microsoft. Let me tell you right off - Microsoft's solutions had no effect, so you might want to skip to the last one immediately. Solution 1: deleting all IE settings so as to remove potentially blocking add-on...

Chinese OCR: translating scanned or photographied Chinese text to any language

Image
Having lived in China for almost 3 years now I am able to recognize a good bunch of characters, I can type in Chinese on the computer too but writing is much easier than reading since it doesn't require you to actually memorize the characters, you just type in pinyin (phonetics). That is not enough to understand a full, complex text. After months of research I've finally figured out how to recognize chinese characters automatically from a picture , in order to copy/paste the text into a translator such as Google translate or others. The solution was right under my eyes all this time: Microsoft Office 2007 . I had no idea that Office 2007 came with such features. I've always known of expensive solutions such as Ominpage Pro, but I refused to resort to purchasing the app considering its price and how little I would need it. OCR , which stands for Optical Character Recognition , is the principle of proceeding to the digital analysis of an image to extract the characters/t...