MacPython Logo from __future__ import *

2007-03-18

simplejson 1.7

Filed under: python, simplejson — bob @ 2:31 pm

simplejson is a simple, fast, complete, correct and extensible JSON (RFC 4627) encoder/decoder for Python 2.3+. It is pure Python code with no dependencies.

simplejson 1.7 is a minor update that improves encoding performance with an optional C extension to speed up str/unicode encoding (by 10-150x or so), which yields an overall speed boost of 2x+ (JSON is string-heavy). Additionally 1.7 adds support for encoding unicode code points outside the BMP to UTF-16 surrogate code pairs (specified by the Strings section of RFC 4627).

2007-03-16

Distel and Erlang mode for Emacs, on Mac OS X

Filed under: erlang — bob @ 6:19 pm

In the comments of my post on Erlang Mode for Emacs Tobbe pointed me at the new Distel repository for Distel. I had originally tried to install Distel last year when I began with Erlang but it didn't work. It works now! Here's the deal.

  1. Check out Distel. In my case I'm going to check it out to /Users/bob/src/distel:

    $ cd /Users/bob/src
    $ svn co http://distel.googlecode.com/svn/trunk distel
    
  2. Configure and compile Distel:

    $ ./configure
    $ make
    
  3. Configure Distel and configure Erlang mode, ensure that the inferior Erlang shell has an explicit node name of emacs so that Distel can connect to the. Here's my full .emacs:

    (add-to-list 'load-path  "/usr/local/lib/erlang/lib/tools-2.5.3/emacs")
          (setq erlang-root-dir "/usr/local/lib/erlang")
          (setq exec-path (cons "/usr/local/lib/erlang/bin" exec-path))
          (require 'erlang-start)
    (add-to-list 'load-path "/Users/bob/src/distel/elisp")
          (require 'distel)
          (distel-setup)
    
    ;; prevent annoying hang-on-compile
    (defvar inferior-erlang-prompt-timeout t)
    ;; default node name to emacs@localhost
    (setq inferior-erlang-machine-options '("-sname" "emacs"))
    ;; tell distel to default to that node
    (setq erl-nodename-cache
          (make-symbol
           (concat
            "emacs@"
            ;; Mac OS X uses "name.local" instead of "name", this should work
            ;; pretty much anywhere without having to muck with NetInfo
            ;; ... but I only tested it on Mac OS X.
            (car (split-string (shell-command-to-string "hostname"))))))
    
  4. Add Distel to your ~/.erlang so that it's on your Erlang code path:

    $ echo 'code:add_pathsz(["/Users/bob/src/distel/ebin"]).' >> ~/.erlang
    

If the Distel installation was done properly your Emacs mode line will be displayed as (Erlang EXT) next time you're editing an Erlang module. If you get a "nodedown: ..." message when executing a Distel command that means you haven't started a shell yet (C-c C-z). A good test is to stick your insertion point at a function name and hit M-. to get to its definition. M-TAB is auto-completion. I haven't used too much else from it yet.

(Now here's to hoping I don't have to learn any more elisp, ever).

2007-03-14

Erlang Mode for Emacs

Filed under: erlang — bob @ 4:51 pm

Erlang ships with a quite nice Erlang mode for Emacs. Editing Erlang code is actually the only thing I ever use Emacs for.

Setting it up is only slightly painful. For a default R11B-3 installation your .emacs will look like this:

(setq load-path (cons  "/usr/local/lib/erlang/lib/tools-2.5.3/emacs"
      load-path))
      (setq erlang-root-dir "/usr/local/lib/erlang")
      (setq exec-path (cons "/usr/local/lib/erlang/bin" exec-path))
      (require 'erlang-start)
(defvar inferior-erlang-prompt-timeout t)

The first set of expressions sets up Emacs to find erlang.el and the path to your Erlang installation.

The second expression tells the emacs mode not to wait for an Erlang prompt. This is my only annoyance with the mode. Without this defvar, when you send a command from Emacs to Erlang it'll hang for 60 seconds (or until you hit Ctrl-G) if there was any IO since the last prompt (e.g. an error_logger report or an io:format call). The caveat with this setting is that the first command you issue (the one that causes the inferior shell to get started) will get sent before Erlang is started and get lost. Issuing the first command twice is a small price to pay in this case, because the lock-up is annoying as all hell when you're in the middle of the compile/play cycle.

Using the Erlang mode is pretty straightforward. Tab does the right thing for indentation and is a good way to check to see if your code makes sense syntactically. If it doesn't indent to the right place, you probably screwed up. The electric stuff like comma and semicolon are great and save you a good deal of typing. The only command I really use is C-c C-k which compiles and reloads the current module into the running Erlang inferior shell. It will start one if one isn't already running (C-c C-z just starts the shell).

The other gripe I have is that when you get compiler errors sometimes clicking the line numbers takes you to the wrong line in the source file, but that's a relatively minor annoyance for me. Restarting seems to fix that (until it breaks again) and normally I'm not fighting too many compiler errors :)

2007-03-04

Erlang in Print (almost)

Filed under: erlang — bob @ 1:34 pm

Erlang finally has a book out in print again (almost): Programming Erlang, written by Joe Armstrong. The best part of the story is that the publisher is allowing a combo purchase of a beta PDF plus the print book when it's available. How cool is that? I think this model makes a lot of sense with the speed that technologies move these days. Imagine how much they could have made riding the Ruby on Rails hype train a few months earlier than any other publisher with a 70% finished beta PDF plus a print book when available?

I've purchased the book and read through what's available in the beta PDF so far. It definitely does not disappoint: this is the Erlang book and it will be for some time to come.

If you're particularly interested I also highly recommend reading Joe Armstrong's doctoral thesis paper (Making Reliable Systems in the Presence of Software Errors), which has a lot of overlap with what the beta PDF covers and what the book will cover when it's finished. There's also a lot of interesting information in the thesis that may or may not end up in the book such as the history and evolution of Erlang and some interesting case studies.

2007-03-03

simplejson 1.6

Filed under: python, simplejson — bob @ 9:40 pm

simplejson is a simple, fast, complete, correct and extensible JSON encoder/decoder for Python 2.3+. It is pure Python code with no dependencies.

simplejson 1.6 is a minor update that improves str support for encoding. Previous versions of simplejson integrated strings directly into the output stream, this version ensures they're of a particular encoding (default is UTF-8) so that the output stream is valid. See the documentation for more information.

2007-01-31

Mochi Media interview with PodTech’s LunchMeet

Filed under: General — bob @ 1:18 pm

Jameson and I did an interview with Irina and Eddie from PodTech's LunchMeet yesterday at our office. Twenty minutes of video podcasty goodness right here: LunchMeet: Fueling Creativity with Mochi Media

Before anyone asks about the shirt, it's from the xkcd store (inspired by #54).

2007-01-18

simplejson 1.5

Filed under: python, simplejson — bob @ 12:23 am

simplejson is a simple, fast, complete, correct and extensible JSON encoder/decoder for Python 2.3+. It is pure Python code with no dependencies.

simplejson 1.5 is a major update that provides better Python 2.5 and Windows compatibility, and two new features that control encoding (indent for pretty-printing, and separators for generating optimally compact JSON). See the documentation for more information.

2007-01-01

Lessons learned in Asia

Filed under: General — bob @ 3:42 am
  • Food is cheap in Taipei and Shanghai
  • Alcohol isn't
  • US internet connectivity in Taipei is kinda slow and high latency
  • US internet connectivity in Shanghai is even worse; barely usable
  • An earthquake in Taiwan can make Shanghai's US connectivity completely unusable for days. Going on 6 now; still slower than dial-up 10 years ago.
  • The great firewall blocking sites like wikipedia, google's cache and wordpress can get annoying. It's also hard to tell if a site is just unreachable or is blocked by the great firewall.
  • Google knows what the hell they're doing (and nobody else seems to). They're the only US company I've found that has maintained a usable infrastructure in Shanghai through this whole mess. Not Yahoo, not Microsoft, just Google. If Google had a proxy, I could've gotten by pretty nicely.
  • Localized sites for US companies work fine because they're hosted domestically, but I can't read them (e.g. apple.com.cn).
  • MacBook Pro power supplies really do melt, and they cost twice as much in Shanghai than retail from Apple in the US. No wonder people outside the US don't buy Apple!

2006-12-06

CacheFly vs. Amazon S3

Filed under: General — bob @ 1:50 am

We've been looking at solutions for hosting and serving large amounts of (small) static content to a global audience and are currently in the process of evaluating all of the CDNs out there.

One might think that Amazon S3 would be good for this purpose, but it's absolutely not. We tried it for a while, and it really only has two things going for it:

  • It's very cheap
  • Everything is automated and easy to set up

Aside from that, the performance is absolutely terrible outside of the US, which I really noticed since I've been in Taipei. In addition to that, it's simply not reliable. There are extended and unannounced periods of downtime, so you shouldn't be using it in production (except maybe for redundancy or backup purposes).

After we experienced some unacceptably long downtime I scoured the internet for a real CDN solution. There are a bunch out there, but only one of them is open enough to publish prices and allow you to sign up without doing a sales call: CacheFly. So far our experience with CacheFly has been pleasant. It's a little more expensive than Amazon S3, but you're paying for a far better service. Plus, there's a 30 day free trial. The trial appears to be "only available if you sign up before tomorrow", but it seems to be following the calendar.

There have been a few small snags with the CacheFly service so far:

  • In order to use rsync/scp/sftp uploads you must file a support ticket; ftp is the only service enabled by default
  • After that support ticket was resolved, scp was broken so I had to file another ticket (rsync and sftp worked)
  • In order to use your own DNS you must file a support ticket, otherwise you're stuck with accountname.cachefly.net
  • Their POP distribution technology seems suboptimal; they're serving the lion's share of our traffic from the US when most of it isn't coming from there (though still massively better than Amazon S3)

On the flip side, the experience has been good overall:

  • Latency is MUCH better than Amazon S3 in our experience
  • They give you pretty good reports about your traffic, without having to parse your own logs
  • Responses to support tickets have been prompt
  • It's the only real CDN with published prices that allows you to sign up without dealing with a sales department

All that said, CacheFly is the smallest fish in the CDN pond. It only has 5 POPs and we'll probably outgrow it within the next year and move over to one of the "Tier 1" providers such as Akamai or BitGravity . I still highly recommend CacheFly as a first step for anyone looking to improve their site's reliability and performance by using a CDN.

2006-11-21

MochiAds - Flash Game Ad Network

Filed under: python, flash, actionscript, erlang, Pylons, Genshi, SQLAlchemy, MTASC, nginx — bob @ 2:00 pm

MochiAds is finally out the door! There's a pretty good summary of what we're doing on TechCrunch.

For the technically inclined, the UI for MochiAds is built with Pylons, Genshi and SQLAlchemy. The secret sauce is a combination of Python and Erlang code, and we've got Nginx as the gatekeeper. I've got nothing but good things to say about this whole stack. Erlang's module reloading, concurrency oriented programming model, and pattern matching has really been a dream.

For Flash game developers, we support ActionScript 1, ActionScript 2, and MTASC. Flash movies must be published in Flash 6 or later. Currently we support two ad formats: preloaders and interstitial ads. Either way it's just one line of code to toss in the movie.

The really Big Deal is that Flash game developers can make money off of their work throughout the entire lifespan of the project, especially if it spreads virally. It's no longer a bad thing if a portal "steals" the game without paying a licensing fee, the developer still gets paid!

Next Page »

Powered by WordPress