Monday, January 17, 2011

Monitor Comcast Usage Data

The good folks at Comcast have decided to put a 250GB cap on monthly usage as a direct assault against my beloved Roku.



I decided to put a script together to notify me in case I start approaching the monthly limit. My first thought was that this was a perfect task for mechanize, a Ruby library for interacting with web sites. I put that aside, however, to make an attempt to script the scraping with curl.

Those folks at Comcast are whack. When logging in to the home page, what is sent back is a redirect - no not an HTTP redirect. You are sent back a page that has a form in it with a "cima.ticket" that submits itself in the body onload event. Here is the somewhat functional script to pull the your Comcast bandwidth usage:



I say somewhat functional because it doesn't work every time. It will fail to pull a result every now and then. There is a lot of wonkiness in the way the Comcast login works - and it appears this results in some kind of timing issue. Hopefully I have a chance to investigate a solution for this in the future.

Oh - back to mechanize. I googled for another solution to this problem and found this. It shows off the elegance and ease of use of mechanize, however, it seems to fail intermittently just like my script.

Saturday, January 15, 2011

Emacs Find File in Project Updated Plus defun toggle-test

I've updated my fork of the Emacs Find File in Project with caching and storage of the file list in a map instead of an alist. Both of these should improve the performance with the latter possibly being a bit of an overkill for anything but very large projects.

I also put together a little function to toggle back and forth between class and test case for Java code per the directory layout we use at work. If the corresponding toggle file does not exist you will be prompted to create it:



Emacs rules with its quick customizations.

Saturday, December 18, 2010

pagiborder Chrome Extension Comes Alive!

Please welcome Chrome Extension pagiborder. It temporarily drops a line on the screen indicating the previous page border position when you paginate with the space bar.


I use it - so maybe someone else will find it useful as well.

Thursday, December 09, 2010

Emacs Find File in Project

Note: This is already out of date. I have found, forked, and tweaked a github repo that did most of what I wanted and my version can be found there. Further tweaks may include caching and other speed increases for large projects.

Increasingly for Java projects I've been relying on IntelliJ IDEA, an amazing IDE. There are still times, however, when I need the sharp tool capabilities of Emacs. I've never been completely satisfied with the "find file in project" capabilities I have been able to configure in Emacs (especially after using IntelliJ IDEA) so I set out to fix that. Building on the ideas found in Stuart Halloway's What you can learn from ido.el and the find file in project snippet given on the emacs wiki page for ido.el I can up with the following improved find file in project approach - well actually two approaches as I have created approaches that gather their file lists from either 1) a TAG file or 2) by issuing a shell find command.

The main tweaks provided are:

  • I am limiting the search to file name rather than full path. This makes the flex finding much more effective and much faster when working with large projects
  • I turn on case sensitive searching making capital letter camel case matching work very well
  • Name conflicts are handled by a second disambiguation prompt.

I'm sure there is still plenty of room for improvement here so you can check for updates in my .emacs file. The following indicates the present state of things with hopefully enough comments so that you can follow along:

Sunday, November 28, 2010

Monday, February 01, 2010

jQuery Shell Google Chrome Extension

I've written a handy Google Chrome extension for jQuery developers. The extension allows you to bring up a console window and run Javascript and jQuery commands against the current web page. It is great for learning or experimenting with jQuery. I call the extension the jQuery Shell and it can be found here. The source code can be found here. Here is a screen shot for your viewing pleasure:


Google Chrome has a really nice extension framework.

A couple of other useful Javascript tools (not Chrome extensions) I've discovered on the web lately are http://jsfiddle.net and http://jsbin.com/.

Sunday, January 31, 2010

Truncate all Tables in a MySQL Database Revisited

Since this old post still manages to get a fair number of hits I thought I should fix it up to encourage people to not reveal their MySQL passwords in history logs and process lists by entering it on the command line. The new version uses getopts for parsing command line options. If you pass in "-p", it will prompt you for your database password for each mysql command. If you really want the old bad behavior then "-P password" will do the trick. Enjoy:



It is also possible to put your password in your my.cnf file to have it picked up automatically. You can read more about MySQL password for version 5.4 security here.