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 entry »
URL Checker
November 10th, 2009Updated jsonrpclib
November 2nd, 2009I’ve added automatic class translation, a simple standalone JSON-RPC server, and a configuration object to the jsonrpclib. You can check it out at the project page, where I’ve also posted a few new usage examples. I’ll be updating the blog with more specific examples and things to keep in mind soon.
Tornado RPC Library on Google Code
October 18th, 2009I 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):
from tornadorpc.xml import XMLRPCHandler
from tornadorpc import private, start_server
class Handler(XMLRPCHandler):
def add(self, x, y):
return x+y
def ping(self, obj):
return obj
@private
def private(self):
#should not get called
return False
start_server(Handler, port=8080)
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
October 18th, 2009Recently, 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):
>>> import jsonrpclib
>>> server = jsonrpclib.Server('http://localhost:8181')
>>> server.add(5, 6)
11
>>> server._notify.add(5, 6)
>>> batch = jsonrpclib.MultiCall(server)
>>> batch.add(10, 17)
>>> batch.ping({'key':'value'})
>>> batch._notify.add(50, 40)
>>> batch()
[27, {'key': 'value'}]
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.
It’s a Twister – Now with More XML
October 15th, 2009Holy community code, Batman. Facebook has been launching open source projects like crazy in the past few months. (This would be a Good Thing — I think they launched two today just while I refreshed the page!) Things like Cassandra, Thrift, and Hive are great additions to the community, and hopefully the rewards will go both ways. One of the projects I’ve been playing with is Tornado, FriendFeed’s Python web framework. It’s quite simple to dive into if you are familiar with any of the dozens of web frameworks available for Python (like web.py, Pylons, CherryPy, etc.), and it’s very fast. (But, in the immortal words of LeVar Burton, “don’t take my word for it.“)
Quickie: Updating Site and Ubuntu
October 14th, 2009So, I’ve started creating a new theme for this blog. It’s pretty simple, and knowing me, I’ll change it up a lot as time goes by, but it works for now. Forgive some ugly / broken stuff as I sift through all the CSS / PHP and make the necessary changes.
I really do like how simple it is to create / augment Wordpress themes. The system is very intuitive, and you can scale from a small blog to a decent-sized multi-user site easily. Plus, the plugin system is quite developer-friendly. You can’t create the level of customization you can achieve with a real web framework, but it’s fun for baby sites.
Anyway, the other part of this evening was spent grabbing the new Ubuntu Desktop Beta (9.10). Originally, I could not get any of the Live CDs to work, and I was about to post a mean bug report when I noticed that I was getting strange RAM reporting on boot up. Lo and behold, after running a memory diagnostic, it turns out one of my sticks went bad. Darn you, cheap power supply! Pulled it out, and within twenty minutes I was rocking a new, 64-bit beta distro. There is a Koala in my computer now.
Anyway, if you want to run 64bit Linux, and you happen to frequent tiny sites like YouTube, Vimeo, ON Networks, and Hulu, then you probably will want the Flash plugin. You can wrap the libraries in ndiswrapper, sure to provide hours of fun, or you can just grab Adobe’s 64-bit beta Flash 10 player from here. After that, just copy it into your Firefox directory:
tar xvzf libflashplayer-10.0.32.18.linux-x86_64.so.tar.gz sudo cp -r libflashplayer.so /usr/lib/mozilla/plugins/
64-bit Ubuntu is really quick, by the way. I have enjoyed just pummeling the system (made better by the fact that I already reduced the amount of RAM!) and watching it yawn at me.
Sacrilege and Zeroconf
October 13th, 2009(Yes, I will get back to CouchDB soon. It’s my blog, I can post what I want.
)
Recently, I’ve been toying around with Zeroconf, the “look ma, no hands” network service discovery better known as Bonjour on Mac and Avahi on Linux. It actually does a lot of different things, from “headless” network address negotiation to host name resolution, all built on top of (mostly) the same stuff that drives DNS across the web. It’s really cool stuff, and also really late for me to be getting into the game.
Anyway, the stuff I am most interested in is the “service discovery”, or the way two iTunes clients see each other without anyone entering in IP addresses. This is solid user-friendly tech, and this style of thinking should be implemented in more software.
So, when I found pyzeroconf, a pure python implementation of the service discovery stack, I was stoked. Until I tried running it, and all of the tests failed no matter what system I ran it on. I was no longer stoked. Thus I began reading, and this is always a dangerous thing.
Read the rest of this entry »
Quickie: Using Vim for Actionscript
October 9th, 2009Okay, we all know vim is the best IDE out there. But what is a fella to do when he wants to use the best IDE with the best closed-source vector-based browser plugin scripting language? Why, hack at his vim install!
First, download the actionscript.vim file from this place. The actionscript.vim file is a syntax file, so it should go in the appropriate folder as you see fit. However, note that in OS X the .vim folder seems to have no impact, so you have to put it in the /usr/share/vim/vim72/syntax folder. (Use sudo, and you may need to use a different vim folder if it has a newer version.)
Next, we have to hack at the filetype.vim file in the /usr/share/vim* folder in order to disable the default treatment of *.as files. Change the lines that say:
" Atlas au BufNewFile,BufRead *.atl,*as setf atlas
…into the following series of lines:
" Atlas au BufNewFile,BufRead *.atl setf atlas " ActionScript au BufNewFile,BufRead *.as setf actionscript
Voila! Opening .as files in vim should work now.
Compiling CouchDB
October 9th, 2009So, in the last post I gave an introduction to the concepts behind CouchDB and other document store systems. For this post, I had intended to overview compiling on both Mac OS X and Ubuntu 9.10 Beta. However, on the Mac front, it turned out there was already project with a nicely cooked binary that would be significantly easier to install, and, let’s face it, just more Steve Jobs than compiling from source. If you are running Mac OS X Leopard (10.5), you can download the CouchDBX binary here.
CouchDB and Me
October 8th, 2009So, as per the advice of my friend Yuce, I have begun blogging about various types of software, technology, and whatever else I see fit to project onto the masses. I decided to start with a recent “crush”, CouchDB.
Relational databases are simple. Anyone with experience using spreadsheet software understands the basic functionality – a series of rows conforming to a specific, pre-defined series of columns and data types. A lot of data can be easily organized in this manner. Most data can be roughly shoved into it. However, ubiquitous does not necessarily mean appropriate.