Sunday, August 21, 2016

Launch Chrome by Profile Name (Updated)

Now for my once a decade update... Chrome eliminated white space from the JSON format used to store profile preferences. This broke the simple file parsing of the previous script. This update switches to the jq command-line JSON parser to fix the parsing. Enjoy: Send peer bonus, please :-)

Tuesday, June 11, 2013

Launch Chrome by Profile Name

Chrome allows you to launch it under a given profile if you give it an argument of --profile-directory="Directory Name". The directory names are "Default", "Profile 1", "Profile 2", etc.. Obviously this is not super convenient as you need to know the profile directory that goes with a given profile name. Here is a script that allows you to launch Chrome by profile name instead, followed by some bash code to allow bash auto-completion of profile names. First the gchrome script: and next, the bash completion code. Throw this in .bashrc or somewhere: Note that this relies on a certain layout of the Preferences file json which I have found to hold so far, however, it wouldn't be too surprising to find json that breaks it. This should work for Chrome on most Linux installs. This could probably be adjusted to work on OS X but the config file is located elsewhere. Enjoy.

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:

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.

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.