Ubuntu is just a keypress away with crouton

Last weekend I tried another Ubuntu approach on my Samsung Chromebook. On the same blog where I found the ChrUbuntu trackpad fix, Craig provides instructions on how to run crouton. What’s crouton: it’s a ‘Chromium OS Ubuntu Chroot Environment’ originally found here.

The advantage of this method over the dual-boot method is that dual booting is not required! Instead, one can install linux to an SD card, launch X, and then switch between ChromeOS and Ubuntu with Ctrl-Alt-Shift-Back. And if you can master this key chord, Emacs commands are just one step away :p

So, I followed Craig’s instructions and setup XFCE as my window manager. However, I am still going to keep ChrUbuntu and my dual-boot for the time being. First let’s look at what’s cool about crouton:

  1. Swap between ChromeOS and Ubuntu without rebooting.
  2. apt-get install emacs works and installs emacs23 no problem. (I haven’t figured out how to get emacs24 on this device yet…)
  3. Ubuntu and ChromeOS can share files together by mounting your ChromeOS directory into the Ubuntu chroot environment. (See bottom of this post)

Here’s what didn’t work for me:

  1. I did not like XFCE. It was my first experience with this window manager and I had a few issues that I could not easily fix: the resolution was set too high and I could not seem to change it and I could not switch the super key to ctrl in XFCE. Using ctrl on the home row is a blessing and curse. It is SO NICE to use that nice big button for something useful besides caps lock, but on the other hand, it drives me bonkers to type on the default keymap… ARGH!
  2. Something odd was going on with my SD card. After a reboot, all that was visible was “lost and found.” So, I just reformatted my card back to its regular self.

I may try this experiment again, but I might pick KDE as the target not xfce. But since I already have the dual-boot setup, there is not much motivation for me to change at this moment. If you don’t have Ubuntu running at all on your Chromebook, it may be better to start with the crouton approach since you don’t have to re-partition your internal drive at all.

Creeping Emacs: Imma (Bitl)bee

In the continuing progression of Emacs taking over my life, I’ve found another service that can be replaced by Emacs: Google Talk!

For the rest of the world out there that has been using this for the last three years, please excuse my late discovery. Lately I’ve been lurking on the #emacs channel on freenode, keeping tabs on the conversation stream in the background. I was using Colloquy at first, which is a nice graphical IRC client on the mac, but I switched to ERC, an IRC client inside Emacs, and I was very impressed with how nicely it has integrated inside Emacs. Continue reading “Creeping Emacs: Imma (Bitl)bee”

Hello world from ChrUbuntu!

After following these instructions, my Chromebook is now running ChrUbuntu!  The install is fairly painless and the instructions worked for me without any modifications.  It took about 15 minutes for my Chromebook to switch into “developer mode,” but after running the script and a few reboots later, I can dual-boot into Linux!

Emacs on chrubuntu with some disk usage stats in the corner.
Emacs on ChrUbuntu with some disk usage stats in the corner.

Thanks to the great work over at that blog and to this motivated reader for posting some awesome links to some Linux on the Chromebook material!  At the moment, I just have the vanilla ChrUbuntu sources but per the comments there seems to be active community members trying to fix various issues.  Most notable is that the touchpad is less responsive than in ChromeOS… [Update 21JAN13: I’ve post a script to fix this issue here]

While I don’t support Canonical decision to leave in its surveillance search feature, ChrUbuntu seemed the easiest Linux distro to get up and running right now.  Plus, ChrUbuntu is based from Ubuntu 12.04 and I don’t think Canonical’s search appeared until 12.10.  Thankfully, thanks to the diligent work from the EFF (this is a great organization, I just re-upped my membership), they have a post on how to remove this “feature.”

My first apt-get was for Emacs of course, in which I’m happily typing away.  The Chromebook’s “search” key acts like a “super” key (Windows key) in ChrUbuntu so I found this post which shows how to switch it.  Once you get used to the ctrl key located to the left of the “a” key, it’s very hard to switch back…  I tried to get emacs24 but there were some issues.  For some reason, I couldn’t add the ppa for emacs24 to apt-get and when I tried to build by source there were a lot of missing depends on x-windows and various ncurses libraries.  So, I decided not to push it too far right now and be content with emacs 23 (which installed with apt-get just fine).

If you plan on using the Chromebook as a pure consumption device or if you never heard of Linux(?!) than ChromeOS may be fine for you.  But actually, if that’s the case, a tablet may be better because you probably don’t need a keyboard.  Otherwise, if you want to do *anything* else, try ChrUbuntu.  Firefox is the default browser, but it may be possible to install Chromium if you really want.  And if you have never tried Linux, the Chromebook is a well priced laptop, with which you can experiment.  Just be sure to understand what’s working and not before you make the plunge.

Feeding Pythons

In these last few weeks, I’ve been working in a slew of programming languages. My OS course involves hacking around in the Linux kernel, so that’s in C. The projects in my AI course have been in Lisp, Java and the next one is in Prolog. At work, I mainly dabble in C++, but I’ve been helping with some continuous integration scripts in Perl and Python.

Out of all these languages, I think Lisp has permanently changed the way I think about programming. Unfortunately, it didn’t really click until after I submitted my project… After working a bit in Lisp and then going back to other imperative languages I found myself thinking of a Lisp-like solution and then realizing, “oh, this is was a lot easier in Lisp!” For example, trying to pass functions as parameters is very easy in Lisp since functions are first-class objects, but to do this in C one has defined a function pointer, which has very specific type definitions and some messy syntax, etc…

So, that led me to find this Google Tech Talk by Peter Seibel on “Practical Common Lisp.” This lecture further cleared up some of the concepts about Lisp (again, after I submitted my project, which I’m still waiting for the grade…) and that lead me to buy Peter’s book: Coders at Work, which is an amazing collection of interviews from great programmers. Anybody who is interested in

Cover of "Coders at Work"
Cover of Coders at Work

programming would find this book intriguing. After I finish it, I’ll put up a post specifically on that book.

Then I set out to make a small project in Lisp and ended up using Python 🙂 I wanted to integrate my Google Reader feeds with Emacs gnus and I found libgreader which pretty much handled all of the details with the still-unofficial Google Reader API. Inspired by reader2maildir, which does the same thing in Ruby, I set out to essentially port this to Python.

And I was able to download my feeds and read them in gnus, but since a lot of the feeds using embedded HTML or simply links to the main article (i.e. they don’t contain a summary) and would require me opening a web browser anyway, I figured the gnus approach wasn’t the best, for me.

But I learned a few things about programming in Python along the way. First of all, one has to be a little more specific while searching Google. Working with RSS Feeds, I realized it’s not adequate to search “python feed” due to the homograph “python.” Unappetizing images aside, I really like the interactive python interpreter. I didn’t really understand the point of using the interpreter directly and I thought it was useful only for toy programs, but it really helps in prototyping. Like Lisp’s REPL (read-veal-print-loop), interactive programming feels like precognitive debugging; it allows one to step through a debugger while the program is being written.

And while Python is not Lisp, it does have some functional style artifacts (much to the chagrin of its designer from what I understand). Python has a filter(function, sequence) function that:

returns a sequence consisting of those items from the sequence for which function(item) is true.

Combine this with a lambda expression, and I was able to write something like this:

filter(lambda x: x.unread != 0, reader.getSubscriptionList())

In this example, this line returns a list of feeds from Google Reader that contain unread items. So, I thought that was pretty cool 🙂 So while I would like to do some more stuff in Lisp, I was impressed on just how easy it was to get python running. That and with some Emacs-python integration, the development environment was very nice to work in.

Building Java applications inside Emacs with JDEE

First of all, I think Eclipse is a great IDE. There are a ton of features that work really well in Eclipse: intellisense, auto-compilation, and hotswap debugging. It handles your project and classpath pretty well too… But the more I get used to Emacs the less I can stand typing in an non-Emacs setup. Eclipse even has key binding support for Emacs mode, but it’s just not the same. Plus, it occupies a tremendous amount of real-estate as seen below.

Eclipse window. I’m not a fan of the tabs, nor do I like the redundant information (package information is in three spots). Overall I think it’s a good IDE, but I think I could be more productive in Emacs. (Discounting the non-trivial setup cost…)

So I’m trying Java within Emacs with JDEE. At the moment, I can’t get it to be an Eclipse replacement and I’m not sure it supports completions like Eclipse does. But when I started typing I forgot I had auto-complete mode on! While it may not know the scope of a class, it saves a lot of time with quick tab completion of long Java variable and class names. Intellisense and auto-complete mode are two different tools, but I’m starting to think I’d rather have the auto-complete over Intellisense. Also, as I’ve been using YASnippet more and more, I can quickly add custom snippets to expand code. Eclipse does have some of this, namely a nice try / catch like snippet. But imagine being able to have that code expansion on anything you wanted… that’s YASnippet!

But to get it to work with Emacs 24, there is some annoying configuration. I found an obscure forum post that details the instructions, which seem to get JDEE up and running. After some manual project configuration by customizing some variables as outlined in the user’s guide, I was able to get my project built and running.  Yeah yeah, Eclipse automatically handles the classpath variable, I know.

Honestly, this is a lot of pain to go through and I don’t recommend it unless you are already an Emacs user. But, once one does get it finally working, I think the benefits of staying in Emacs outweigh the context switch of using Eclipse. At least for small projects. For large projects with complex dependencies and a complicated build process, I’m not sure about JDEE, but for small projects, like this Othello game AI I’m working on, it’s fine.

My agent is the green ones. I played against my agent and beat it and I was like “Yeah!!!” But then, I realized that just means my AI isn’t that good yet…

So this weekend I’ll be improving my Othello AI and studying for my AI midterm.  (All things I should be doing instead of trying to get Emacs to work well with Java… 🙂 )

The same code as seen through Emacs. Much more code centric without a lot of the extra noise…

Emacs Wizardry: markdown-mode


I have made an amazing discovery recently.  While its not quite an achievement like the Curiosity rover (Mr. Rover has been entertaining to follow on Twitter) it certainly has brought me great joy nonetheless.  It is Jason Blevin’s markdown-mode.

Back in this post I mentioned that I would be using Emacs more routinely, to include editing these blog posts which I have been doing so far.  But to get the formatting just the way I like it, I’ve been using html-mode and editing the raw html and then uploading it to WordPress.  This wasn’t all that bad, but I’d have to remember the paragraph tag for each paragraph, use the right href, etc… Word wrapping was an issue too and I would have to fill / unfill paragraphs prior to uploading as well.

This is no more.  Using markdown-mode I can edit in the lightweight markdown and after installing markdown (via brew install markdown on my mac), I can quickly generate the html from the text. I’ve used github’s flavored markdown (gfm) before, but it never clicked with me to use it for blogging until I did some googling. Conveniently, gfm-mode is also available.

emacs (specifically aquamacs24 built from source at github) with the top buffer in markdown-mode and the bottom buffer showing the html.

I realized that I’ve just geeked out on Emacs, but very much in the Neal Stephenson definition from “Tune On, Tune In, Veg Out” in Some Remarks, which I have been enjoying lately:

“To geek out on something means to immerse yourself in its details to an extent that is distinctly abnormal-and to have a good time doing it.”

My Emacs usage has drastically increased now that I’m back at work, so there will be more geeking out in the future.

But first, from that same article, another great Stephenson quote (that and I’m enjoying the simple blockquote markdown syntax):

“The few conservatives still able to hold up one end of a Socratic dialogue are those in the ostracized libertarian wing-interestingly enough, a group with a disproportionately high representation among fans of speculative fiction.”


Emacs and PostgreSQL

One of the nice things about going to grad school, is that I really get to refine my Emacs fu.  I’m taking this database class where we are using PostgreSQL and I’m using Emacs’ minor sql modes and I’m very impressed.  Now, I’m no emacs knight, nor do I have the Emacs-fu of the emacs rocks guy, but like any good student of zen, I’m maintaining a beginner’s mind (which is pretty easy to do with Emacs since it does pretty much everything).

Using the latest Aquamacs. BTW, I really like the new version of Gimp (which I used to blur the data). The left pane is my .emacs file since the queries are graded homework.

So, with the setup in the screenshot and working in the SQL minor mode, once I’ve written my query, I can shoot it over to the SQL Interpreter with at quick ^C-^C, which then runs the query and outputs the results, meanwhile the point stays right where I left it!  Logging into the database is easy by firing off \texttt{M-x sql-postgres} and entering your credentials.  This mode is even more essential when SSHing in the department CS machines, where I then must connect to a remote DB server, only accessible from another CS department machine.  Since this all is done in Emacs, in one screen, I have a complete SQL IDE, which is great.

This may seem a bit archaic to some to still use Emacs when there are other, more intuitive interfaces out there.  But even those vim users can appreciate that there is much to be had for learning the same tool and using it everywhere.  Admittedly, in this area I need some attention since I’m writing this post now in WordPress’ online editor, and I actually like Eclipse’s intellisense, and I’m tied to a proprietary editor at my day job.  But besides WordPress, Eclipse, Mail, roads, public order and sanitation, what has Emacs done for us!?!  Brought peace?!

Real Programmers
xkcd # 378. I’m glad to see there is actually a M-x Butterfly easter egg in Emacs 🙂

Areas where I think I can realistically incorporate Emacs:

  1. First draft of blog posts.  100% integration looks a bit wonky with WordPress and I’m still in that baby-blogger phase where I bounce back and forth from the preview to the  edit screen and make tweeks.  But the main draft can (and should) be authored from Emacs.
  2. Code more in Emacs.  For any of the scripting languages this is easy.  For C and C++, this isn’t too hard for me either since I never really grew up on Visual Studios, but for Java… Typing \texttt{this.} and then seeing a list of options is very handy.  Except when I had this kick where I was over-using reflection, then Eclipse can’t really keep up…
  3. Email.  I checked out gnus the other day and while I see how an Emacs only mail client can be done, with so much inline html these days, I’m not sure if its worth it.  But I’m poking a stick at this bear and I’ll probably come back to it.
  4. \LaTeX.  I love \LaTeX.  Once I learned WordPress supported this, I was even more addicted to WordPress.  My résumé, presentations, papers, letters (when I must actually print one out), are all done in lovable \LaTeX.  If you find yourself cursing at M$ Word, take the red pill my friend.  And then you’ll start cursing weird compile errors, but worry about that after you take the pill…  Many thanks to Brent over at The Math Less Traveled for showing me this!

Well, that’ll keep me busy for a while 🙂

Emacs mug, which sold out in less than a day! Under the mug, the book I’m currently reading. Behind it, some Leuchtturm 1917s and Umberto Eco’s Baudolino, which I’m half-way through and from which I’m taking a break and of course, a WIRED.