Quick development CGI server in Python
I'm playing with a new cgi project; it's not complex enough to make something like django worth using, and I didn't particularly want to install a full fledged web server on my laptop for this project, nor run it on a remote server. So a bit of googling led me to this, a really simple web server built on python libraries:
#!/usr/bin/env pythonfrom BaseHTTPServer import HTTPServer
from CGIHTTPServer import CGIHTTPRequestHandlerserveradresse = ("",8080)
server = HTTPServer(serveradresse, CGIHTTPRequestHandler)
server.serve_forever()
And that's it. I've experienced two small downsides. First, I couldn't get it to serve CGI out of /, so I've needed to build the project under /cgi-bin, and second, it seems to get angry if I try to output unicode. But both of these are bearable for a simple dev setup, and will be easy enough to fix when I deploy to a real server.
Cyanogenmod (Android) on touchpad
I recently got an android phone (I'm using it to write this blog post, over an ssh tunnel no less) and the joy of all these great apps tempted me to try to install Cyanogenmod's Android port on the touchpad on the weekend. The process was very smooth, and it is working quite well. I got a couple of sleeps of death, but disabling the screen lock seems to have clearwd it up.
Vive les logiciels libres!
HP Touchpad running Ubuntu Linux!
We managed to get our hands on an HP touchpad in the fire sale, and I've been playing with getting Linux running on it. Here are a couple of videos of where it's at so far. About the only thing not working at this point is screen rotation, which I personally don't have the skills to implement. Hopefully the webos-internals crew will get it figured out soon.
A couple of key tools making it workable on the tablet are easyswipe for gestures and onboard for the onscreen keyboard. I had to build my own onboard keymap for the device. The desktop environment is LXDE, to keep things light and snappy.
For instructions on how to do this, check out this thread at precentral. The first post will get you into a basic Ubuntu environment, then my instructions on how to get to a nice desktop are down on page five of the thread.
Why I Love Free/Open Source Software (or, unity maildir indicator applet take 2)
EDIT: with Chris' consent, the script is now released under the WTFPL.
So this morning I wandered over here to my blog to post about ethics and software, specifically on the topic of why I appreciate Free Software and avoid Apple products, but I noticed this comment on a post about a script I had written (good thing I decided to look through my auto-filtered comment spam folder!). Chris Irwin had found the script, and made it better, implementing a feature I had not bothered to figure out how to do for myself, and posted the source.
This is the greatness of open software: find something that is almost what you need, but not quite, so change it! Share, and share alike!
I took a look at his code, and adopted it myself. And then I modified it more, to make it a little better still. Here's the latest version: maildir-indicator.py Chris licensed his changes under the GPL3, so the same license applies to this.
Antisocial Networking
Facebook. Everybody has it. Everybody uses it. It is worth billions. Google is trying to muscle in on its game with Google+. But exactly what does it do?
Honestly, it seems like the answer to that question is not much. It allows us to share photos. It allows us to keep up to date on what our friends are doing. It allows us to write blog posts, comment on friends' interactions, photos and posts. The thing is, we've had applications to do all of this for decades. Think about it: blogs, flickr and its ilk, message boards... facebook hasn't actually developed anything new here. Yes, now they're moving into voice & video chat, but again, that's nothing new. The only thing that facebook does that's new is to aggregate these activities together in one centralised, easy to use place. And they make a boatload of money by manipulating all that data we've entrusted to them to sell us stuff.
Now, my opinions on centralised, monolithic cloud apps are well known (short version: I think they're terrible for freedom, personal data ownership, and privacy). And yet I use facebook on a daily basis. But wouldn't it be nice if we could simply add the aggregating glue that facebook excels at on top of the technologies that already ran the social content before FB existed? I mean, build a facebook-like interface that would let us see and interact with friends blogs, photos, statuses, etc, but let the data stay on those distributed systems? So if you comment on a friend's blog post that shows up on your social feed, that comment gets pushed out to their actual blog, be it wordpress, blogger, drupal, or whaever other platform, instead locking everything in Facebook's own servers? It's kind of like an RSS aggregator, with the twist of pushing data out rather than just pulling it in.
I've been mulling this idea for a goodly while, and this week (since I wanted a vacation project) I started coding up a prototype. It's still in really early development, but it's gradually coming together, and is showing promise. I'll surely post more information in the coming days. Here are a few notes on what it does/will do:
- Aggregate social data from a number of sources (blogs, twitter, image feeds, etc). So far, I've got twitter and rss incoming
- Allow a Person (or friend) to not simply be linked to one such service, but many -- ie, Joe could have a blog, twitter feed, image feed, etc, all of which are attributed to a unified Person on the feed (this is implemented)
- Allow transparent replying to each of these feeds. This is without a doubt going to be the most difficult part, particularly to open up as many services as possible. I'm hoping to build this on OpenID as much as possible.
It actually seems pretty simple, doesn't it? I'd love to hear what others think of the idea. While I realise that it's unlikely that this will spark a revolution, I'm hoping it'll prove interesting at least to a certain community. If and wen I get it to a point where it's useful, I'll release the source and set it up as a public service.
If by any chance you have programming inclinations and would like to help out, drop me a line. I'm building it on python and django, so obviously familiarity with these technologies would help...
Unity indicator applet: maildir check
UPDATE: My code was found by another mutt user and modified, his changes are here, and I've changed it a bit more here. It now integrates with the unity messaging menu and shows notifications like it should!
As I mentioned in my last post, I've been transitioning to a local Maildir for my email. One downside to this is that the mail indicator included with Ubuntu's Unity desktop requires you to run Evolution to get mail updates. Now I know it also works with certain other MUAs (ie, Firebird), but I like Mutt, so I just wanted a simple indicator in Python to check my Maildir. So I did some googling and found some examples of indicator applets in Python, and coded up as simple applet. Voilà:

So all it does is poll my Maildir, and turn the icon red when I have messages; pretty simple. As you can see I currently have two little mail icons in my indicator; that's because I'm not integrating at all with the Ubuntu messages indicator. If I get a coding itch I'll investigate doing that. Other things I'd like to add are configurability for mailboxes as well as MUA of choice (the Config menu item is just a stub right now) and popup notifications for new messages. If I get those things done I might actually feel inclined to submit the code to someone, somewhere. For the moment, I'll leave the code here in case anyone wants example code of a really simple indicator applet. Feel free to do whatever you want with this code.
#!/usr/bin/env python
import sys, os, gtk, appindicator
CHECK_FREQUENCY = 60 # seconds
MAILDIRS = [ "/home/brad/Maildir/" ]
DEBUG_LEVEL = 0
class mailIndicator:
def __init__(self):
self.ind = appindicator.Indicator ("debian-doc-menu",
"indicator-messages",
appindicator.CATEGORY_APPLICATION_STATUS)
self.ind.set_status (appindicator.STATUS_ACTIVE)
self.ind.set_attention_icon ("new-messages-red")
self.buildMenus()
self.ind.set_menu(self.menu)
def buildMenus(self):
self.menu = gtk.Menu()
self.mutt_item = gtk.MenuItem("Launch Mutt")
self.mutt_item.connect("activate", self.launch_mutt)
self.mutt_item.show()
self.menu.append(self.mutt_item)
self.maildir_item = gtk.MenuItem("Configure Maildir(s)")
self.maildir_item.connect("activate", self.maildir_clicked)
self.maildir_item.show()
self.menu.append(self.maildir_item)
self.quit_item = gtk.MenuItem("Quit")
self.quit_item.connect("activate", self.quit_clicked)
self.quit_item.show()
self.menu.append(self.quit_item)
def run(self):
self.check_mailbox()
gtk.timeout_add(CHECK_FREQUENCY * 1000, self.check_mailbox)
gtk.main()
def maildir_clicked(self, widget,data=None):
# stub
m = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE, "STUB")
m.run()
m.destroy()
def quit_clicked(self, widget,data=None):
sys.exit(0)
def launch_mutt(self, widget,data=None):
os.system("gnome-terminal -e mutt &")
def check_mailbox(self):
DEBUG("Checking Maildirs")
newmail = False
for maildir in MAILDIRS:
newmail = (newmail or (len( os.listdir(maildir + "new") ) > 0))
if newmail == True:
self.ind.set_status (appindicator.STATUS_ATTENTION)
DEBUG("new mail detected.", 2)
else:
self.ind.set_status (appindicator.STATUS_ACTIVE)
DEBUG( "no new mail detected.", 2)
return True
def DEBUG(message, level = 1):
if DEBUG_LEVEL >= level:
print message
if __name__ == "__main__":
indicator = mailIndicator()
indicator.run()
RSA: Profit is not a good motive
Just watched a very interesting video on RSA Events, talking about psychological and sociological studies that have shown purpose to be a much better motivator than profit, and how economic motives are often far from the best motives.