A fun utf-related Django error

I was working with Django tonight and got this error:

UnicodeDecodeError at /blog/ 'utf-8' codec can't decode byte 0xfe in position 0: invalid start byte

Here’s my troubleshooting procedure:
1. I checked my base template (base.html) and saw I had set <meta charset="utf-16"/> when Django was expecting utf-8.
2. I changed to utf-8, saved the file, reloaded.
3. I got the same error.
4. I spent some time looking at other code and googling. Nothing worked.
5. Finally, I copied my template, deleted base.html, created a new version and pasted in the code.

And then everything worked. I’m writing my code in PyCharm; not sure if that had anything to do with not being able to get the initial html file to change from utf-16 to utf-8.

China’s indigenous OS and the Windows 8 ban

China Operating System (COS) and Ubuntu Kylin: Two of China's 'indigenous' operating systems.

China Operating System (COS) and Ubuntu Kylin: Two of China’s ‘indigenous’ operating systems.

The Chinese government has decided to not purchase computers loaded with Windows 8. Some have argued that this is a negotiating tactic or, as many Chinese netizens have pointed out, a pragmatic move based upon the expense of training millions of government workers to use the OS. However, as I wrote on Quora, I see this as a move accellerating adoption of an ‘indigenously developed’ operating system: an operating system created in China, by Chinese software engineers, specifically for use in China.

This desire for an indigenous OS is not new. The original Kylin operating system, originally a FreeBSD ripoff but now a Ubuntu branch discussed in more detail below, began development in 2001. Reports in the media of a recent speech in which one Chinese academic stated that “China will kick its dependency on foreign mobile OSes in the next three to five years” and a Xinhua article about Chinese OS both reenforce the fact that pressing for adoption of an indigenous OS is more than a trend or knee-jerk reaction to Snowden. The range of options being developed, and the reasons why they are being considered, are worthy of consideration.

Continue reading

Some thoughts on learning Python and how to program

I have been learning Python over the past several months1, using three different resources: Zed Shaw’s Learn Python The Hard WayCodecademy’s Python course, and Allen Downey’s book Think Python.

Below I’d like to share a few thoughts about the strengths and weaknesses of each and a bit of reflection on my own learning. If you’re thinking about learning programming by learning Python, I hope this may be useful.

Continue reading

  1. Why Python instead of Ruby? I wasted hours and hours reading about the two, but chose Python because of its cool libraries, especially the NLTK. What brought me to try my hand at programming was the desire to be able to do work on questions related to linguistics. Because of my initial interest in being able to use the NLTK, I’ve been learning Python 2.7 rather than Python 3.  []

If you aren’t using Sina Weibo with your Chinese students, you’re missing out.

While many teachers have embraced social websites (twitter, facebook, Google+) to engage students outside of the classroom and expand opportunities for learning, the vast majority of teachers have had little to no exposure to the social website with the most users in the world: Sina Weibo, China’s most popular microblogging website. Given the growing number of Chinese students in western universities and high schools, knowledge of Weibo (pronounced “way-bwuh”) is essential – if you work with Chinese students, Weibo  is without a doubt the best way to extend learning outside of class.

The below is not a guide to using Weibo (setting up an account, posting, following people, etc). Others have already written excellent guides (such as Bill Bishop’s “Inside Sina Weibo” presentation), and I have no desire to reinvent the wheel. Instead, I’d like to make some suggestions on how to use the website based upon my own experiences using Weibo with my own students.

What is Weibo?

Weibo is most commonly described as “Chinese twitter”, and is the most popular micro-blogging platform in China. Weibo  has more than twice the number of active users than twitter does, and many argue that Weibo offers better/richer features. Like twitter, Weibo lets users write 140 character messages, which can be shared, forwarded, or commented upon. Weibo also allows sharing of pictures, movies, and audio – generally in ways superior to those offered by twitter. We will look at some of these below and think about how to make the most of them.

Continue reading