PyCharm from the command line in OS X

For the past few months I’ve been writing my code in the JetBrains PyCharm IDE. While there are things I still prefer about Sublime Text, the overall feature set in PyCharm has won me over.

Something that was killing me, though, was the inability to open files and directories from the command line. Thanks to stackoverflow, I found a workaround. Here’s how to do it:

Edit your .bash_profile to include the following:

# Adds PyCharm to the command line.
alias pycharm="/Applications/"

From the command line you can now use the command pycharm to open a file in PyCharm. The only caveat is that you need to provide the full path to the file or directory you want to open. The easiest way to do this is to use pwd. If I’m in a directory that has a file,, that I want to open, I’d type the following:

> pycharm `pwd`/

Or I could open a folder in PyCharm

> pycharm `pwd`/hello

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.  []