David Burger's Courtesy Flush
mostly rails, javascript and other programming related stuff
Sunday, August 14, 2011
Use MySQL's Modulo Operator to Update in Batches
Sometimes you need to roll out your nefarious plan slowly and MySQL's modulo operator can help. Here we do the first of ten batches:
Saturday, June 04, 2011
Javascript Binary Heap
Saturday morning javascript exercise - a binary heap in array and tree implementations. The tree implementation is faster as expected when you shove a lot of data as it as the array implementation must occasionally re-size the backing array. A demo or visualization would be nice but that takes more time than this Saturday morning allows. Code:
Labels:
algorithms,
javascript
Saturday, May 14, 2011
Emacs Batch Edit Example
Say the following function is in your .emacs file and lets you indent your C source code to your liking:
But you don't want to manually open each file into an Emacs buffer to execute this script. Emacs batch editing to the rescue:
The parameters load up my .emacs file as normal and runs the given eval. Apply a little command line magic and you should be able to exploit Emacs from the command line in a very efficient way.
But you don't want to manually open each file into an Emacs buffer to execute this script. Emacs batch editing to the rescue:
The parameters load up my .emacs file as normal and runs the given eval. Apply a little command line magic and you should be able to exploit Emacs from the command line in a very efficient way.
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.

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.
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.
Labels:
emacs lisp
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.
I use it - so maybe someone else will find it useful as well.
Labels:
chrome extension
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'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:
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:
Labels:
emacs lisp
Subscribe to:
Posts (Atom)
