A Python Script for Teleporting your Mouse!

<TLDR>Get the script here.</TLDR>

(This is mostly for Linux users -- Mac users look elsewhere.)

So, I finally got around to playing with x2x. For those of you who are unfamiliar, it allows you to control a remote machine with a local machine's input devices (mouse, keyboard). Some of you are saying "Aha! That's what they invented VNC for!" x2x is different -- it doesn't actually display what's on the other screen, but rather treats the remote monitor / TV like another attached display.

It is great for our controlling our home HTPC when it's running Google Music, RDIO, XMBC, etc. while I'm working on my laptop. I can just scroll over to the right and I'm controlling the TV, which is miles better than a crappy remote or ridiculously slow VNC refreshes when playing 1080p video.

Anyway, after browsing a blog post that wrote a couple of bash script wrappers, I thought, "Hey, Python can do that, maybe a bit better."

So, here's my github gist for the mouseporter script that starts an x2x session. You'll need Python 2.6+, x2x on both the remote machine and local machine, and faith in code downloaded from the intarwebz. :)

All you have to do (on Ubuntu, anyway) is:

 

Here's an embedded version of the Gist for copying / pasting.

Simple Socket.IO Chat Room Creator

So, yeah, I guess there's something to all this Node.JS hype. :)

I've been toying around with different modules (express, zeromq, socket.io) for a side project idea, and I have to say it's been a lot of fun. CoffeeScript + Node.JS is even better. I think Python may be getting a bit jealous. (I still love you Tornado. :))

Anyway, I decided to throw the goofy chat room creator (like EVERY OTHER Socket.IO "experiment") up on a server and github. (It's not in CoffeeScript though.)

<friends>It's UBERCHAT -- It's new, it's (not) German, it's extra tough!</friends>

(download)

Really basic, supports room creation with random id room URLs, simple private messaging, away / active, etc. Also supports crashing, I'm sure. There's no persistence or anything clever yet, so if the one instance of Node goes, so do all the rooms. :) Gogo redis... later.

Best Poboys in Austin

(download)

I usually post about Python and dev stuff, but I figured I'd share my new food obsession.

At 3rd and Congress, there's a trailer called Turf n Surf that serves fantastic poboys. My personal favorite is the Kiss yo Mama, which has bacon wrapped grilled shrimp, fresh slaw, and loads of awesome.

Anyway, if you are in the area, check em out.

Espresso Vim Plugin

Totally forgot to post this a few days ago when I put it up on Github. I wrote a quick little CoffeeScript –> minified Javascript compiler plugin for vim the other day, out of total laziness. It uses the CoffeeScript syntax library from the original CoffeeScript vim project. I call it Espresso because I think I’m clever.

You’ll need to have CoffeeScript and JSMin available in the path, and I’ve only tested it in Linux, so let me know if it explodes on you.

Introduction to Tornado

So I did an introduction to Tornado talk at the recent Austin Web Python Users' Group (or AWPUG as it is better known). It was a lot more fun for me than I bet it was for those who had to hear me yammer on. Thankfully, Travis Swicegood followed with an excellent talk on Class-based views in Django 1.3.

Someone had a Flip video camera going, so the intarweb may soon be blasted with my incomprehensible jabbering.

Anyway, here are the slides from my talk:

Also, I made a fake site for people to see how one might construct an async API-dependent website in Tornado pretty quickly. It depends on Torn, a project a few of us are working on which shamelessly apes a subset of django-admin.py, just for Tornado sites.

As an aside, someone asked me a question about why you would pick Tornado over gevent, when gevent will let you use any WSGI framework on top of magically asynchronous sockets. I mumbled something about "explicit versus implicit" and the Zen of Python, but in retrospect I totally bombed that question.

While the explicit nature of Tornado IS awesome, as is the performance of epoll, etc., Tornado is genius in the fact that it somehow manages to provide very low-level, simple access to all parts of the HTTP request-response cycle and yet simultaneously includes most helpers you might need for building a slick web application. By overwriting a few methods, I can create a custom authentication system in a few lines, using whatever data backend I choose.

You can do the same with Django, but the difference is that Django's shortcuts tend to make you follow Django conventions. Tornado provides the tools to easily create your own. Tie that in with slick async single-sign-on libraries for Twitter, Facebook, Google, OAuth, etc. and that's just one simple example of one of Tornado's many benefits. Personally, I just tend to work faster in Tornado, with more flexibility.

Anyway, that's what I should have said. :)

Laziness FTW

So, I'm horrible at maintaining a blog. I'm going to be oblivious to my own weaknesses and assume it's because managing my own Wordpress installation is just too time consuming (or some other equally inaccurate reason I'm too lazy to post), and I've ported all my stuff to Posterous now. I can just email a post now, so surely I'll be more proactive, right?

...yeah...

Anyway, my massive library of something like ten posts have been imported here, and all the code formatting, etc. has disappeared. Let's see how long I go before forgetting to update for another year and a half...

URL Checker

I wrote a quick Python script designed to search a file / remote address for URLs and return the HTTP status codes for each one. It's quick and dirty, and the regex needs some tweaking, but for the most part it works. The reason I didn't just use a link checker is that I was actually testing RSS feeds, so this was designed to grab URLs throughout the feed as opposed to just A tags. It lists anything in the 40x range.

Read the rest of this post »

Tornado RPC Library on Google Code

I finished my JSON-RPC and XML-RPC handlers for Tornado, and so I've thrown them up on Google Code. Now people can test my JSON-RPC v2.0 implementation on my jsonrpclib library. :) Which is just what everyone was dying to do, I'm sure. Usage is pretty simple, it's designed to be a.) pretty transparent and b.) easily ported between XML-RPC and JSON-RPC to compare speed, network transfer, etc. times. For example, here's the complete code for XML-RPC client (after installing Tornado and the TornadoRPC library):

To use JSON-RPC, you'd just change any instance of xml/XML to json/JSON. There are several benefits to using JSON, such as smaller transfer size, keyword arguments, notifications, etc., but to use it you are required to install my jsonrpclib implementation.

Added my JSON-RPC library to Google Code

Recently, I've been hacking together a JSON-RPC implementation for Python. It follows the xmlrpclib syntax (because it's pretty darn simple to use and extend), but also adds some of the new, slick features of the JSON-RPC v2 (proposed) specification like:

  • Batch submissions
  • Keyword arguments
  • Notifications (both via batch and single)

So, unsurprisingly, I called it jsonrpclib. I didn't see anything called that yet, so I hope I'm not hopping on someone else's name. But Google Code didn't have it, and if it's not on Google, then it doesn't really exist, right? :)

Project Page for jsonrpclib - http://code.google.com/p/jsonrpclib/

In some simple (read: probably inaccurate) speed tests, my library usually came out on top, about 1.1x faster than the "official" JSON-RPC implementation, and about 1.5-1.7x faster than the xmlrpclib library. I've also created a JSON-RPC handler for Tornado (what I used to test it), and I'll be uploading it plus the XML-RPC Tornado handler to Google Code in the next few days, after I put some shiny paper on it. I didn't see any other 2.0 server implementations yet (maybe because it's just a proposed specification :)) so I figure maybe it will be worthwhile until I can add a standalone JSON-RPC server to the library a la SimpleXMLRPCServer.

Anyway, so usage should be really familiar (this is in a python console):

I do have to say inserting a notification into a batch seems a little silly to me since you have to do intelligent parsing afterwards to dismiss the missing notification, but people smarter than I are working on the spec, so I'll dig for now. If you play with it, please post in the comments about your experience! Also, add an Issue to the project page if it a.) acts oddly b.) just doesn't work for you c.) replaces your hard drive with a toaster oven.