ATTiny85 WAV Audio player for Halloween

It has been ages since I last posted. I wont get in to the reasons for it right now. Lately I have been working on a project for next years Halloween fun.

A few years ago I built a “Lightning Box” based upon a color organ circuit, and a halogen flood light. The unit works, but is a bit clunky, and relies upon an external CD player boom box unit I bought at the Dollar store for $5. The whole contraption definitely could use some re-working.

The current plan is to make the unit fully self contained (with the exception of the speakers) and solid state. The C player will be replaced with a audio player circuit I located that is based upon the ATTINY85 processor. I also plan to remove the amplifier board from a set of old computer speakers, combine that board with the audio player, and then feed the amplified audio into the color organ as well as the speakers. This entire collection of hardware should be able to be housed in a standard Carlon 4x4x4 PVC watertight junction box. More on that later…

I have attached a picture of the working prototype Audio board.

Heave Away

Ok, I have checked logs, identified the punk responsible, banned their IP, and banned the IPs of around 30K known spammers. Behold the power of a decent blacklist, sed and awk and a pissed off sysadmin at 3 a.m. Tomorrow when I’m more lucid ill do a little analysis on the block list and trim it down by just banning whole netblocks where I get no traffic but spammers and bots from. For now though I need sleep!

(In case you are wondering? This is a final test message I’m not just blogging for the sake of blogging)

Software fun

We had an update to our library system again today. This one was on the test server. Once again the vendor insisted we don’t have a test system. I spent another five minutes of my life arguing with them to convince them that we did indeed have the system that they installed incomplete six months prior. This is at least the fourth time I’ve had to argue this point with them. Yet again today it is supposedly now entered in their inventory system. We will see what happens next time I have a problem.
The upgrade itself went fine, however as expected, it wouldn’t run because the system was never fully setup initially. After a few hours of work the upgrade tech did manage to get it working though. I took the opportunity to ask what she did and replicated it on our production system so it now works correctly too.

Twitter Cross Posting

Just so everyone knows, I’m trying out a different setting for the twitter plugin for WordPress. It should now, in theory, only make a single daily post that is a summary of my days twitter postings, rather than be annoying and post a new blog posting EVERY time I say something on twitter.

This should keep you all form being overly bombarded by that stuff. Now that the faire season is back into swing, I will probably have actual posts again.

The suitcase is packed… mostly…

Tonight I think I may have managed to pack 3 personalities into one suitcase. It wasn’t an easy task believe me. “Why are you packing?”, you may ask. You may even ask, “Where are you going?” Well, its that time of year again when I get to travel for work to the location of the yearly conference for our user group for our Library Automation Software vendor. This year I struck gold with the trip though. It just so happens that the conference is nestled all nicely in the middle of the week that falls between Opening and second weekend of the Scarborough Renaissance Faire in Waxahachie, TX. Waxahachie is 30 minutes south of Dallas and the conference is, yep, you guessed it, in Dallas!
So, this year I get to attend both the conference and the faire. Work agreed to fly me down early and back late, (same price just different days than I normally would have) allowing me to attend the faire on the weekends. Work will pay for my hotel while I’m at the conference, and thanks to a VERY generous friend and his wife, I have a place to crash when not at the hotel.
WOOT! So, look out Scarborough here I come!

For those keeping score, the three personalities include:

  1. Work John
  2. John T. Hawser
  3. Relaxing John

Oh, also, while packing I found a pocket in the suitcase that I had apparently missed when unpacking from the Germany trip, and I found the gift I bought for my mother that I was sure I had lost! She was very pleased.

Bizzare

I am still unable to get the web server to email me when anyone comments on the blog. This is very annoying to me, as I can see no reason for it. The ports are open, I can manually send mail from the server to my inbox, but for some strange reason it doesn’t want to work from php.
I have checked,and re-checked the php.ini path to sendmail, and it matches the path on the server…

Blog comments – ooops

This morning I updated my blog client on the iPod only to discover a ton of comments on the blog. Comments I was never notified that they had been posted. If you have commented on my blog since probably mid feb and I have not responded I appologize. It seems the new server has been blocked from sending out any email. I will look into this and get it fixed hopefully today sometime. I thought it had been kinds quiet out there… Sorry folks!

Nested ReWrite Maps

Today, in helping out a co-worker I came up with a pretty cool ModRewrite rule set. The rule is to be used to migrate users web pages to a new server with new user names. The rewrite will map the old user names to the new user name automatically, allowing existing sets of web pages to easily transition to the new user name without any old links breaking. This was accomplished using two RewriteMaps. The first map is used to convert any case of the old user name to lowercase. This is handled using the int:tolower function.
RewriteMap upper2lower int:tolower

The second RewriteMap is used to perform the actual user lookup. This is accomplished by creating a map file that contains a space separated pair of the form: lowercase_old_user_name new_user_name

oldusernameone Z00000001
oldusernametwo Z00000002
...

The map file is then put into play by using the line:

RewriteMap usermap txt:/etc/apache2/userlist.txt

There were two prospects to the overall rewrite that posed a bit of a challenge to me. The first challenge was to prevent the rewrite from occurring when the URL request contained the new format of user name. This was ultimately accomplished using the RewriteCond statement.

RewriteCond %{THE_REQUEST} !/~[Zz][0-9]{8}

The new user names takes the format of a single, specific, alpha character followed by 8 numeric digits. This made for an easy regular expression to match on, and using the ! character negates the normal “does match” condition of the regular expression into a “does not match” condition.

After that was solved the next problem to solve turned out to be the most difficult of all. I could not find any instructions on the net about how to properly nest two RewriteMap maps inside of each other. My first solution was slightly creative, in that I used two chained ReWrite rules. The first rule assigned the lower cased user name to an apache environment variable, then the second rule used that variable as the input to the second map. While this solution did work, it seemed really convoluted, and I knew there had to be a simpler way to do it. After walking away from the rule for a little bit, I came back to it and hit upon the correct method to nest the two maps.

${usermap:${upper2lower:$1}}

Translated into English this essentially reads as, take the first match and pass it to the upper2lower RewriteMap, and take the results of that RewriteMap and pass it into the usermap RewriteMap. Or more simply, make the user name from the URL lower case, and then lookup the lower case value in the file userlist.txt.

Next up, I just had to iron out the regular expression needed to match and replace the old user name and still retain the remaining parts of the URL, while preventing user names that do not match in our lookup to still trigger a standard 404 error.

^/~([A-Za-z0-9]+)/?(.*)

Pretty straight forward over all. In English it essentially reads:
Match the beginning of the line with /~. Take the next one or more (+) A-Z, a-z, or 0-9 characters and place them into variable $1. Place any characters following an optional / into $2. There is a flaw in this, but it should not be an issue in our implementation. If you can identify it, or better yet fix it, please post your solution in the comments. 🙂

One additional touch, that I felt was important to add was the R=301 flag. This causes apache to generate an HTTP 301 permanent redirect header. This should help Google and the like properly index the new URLs. The final rewrite code block follows.

RewriteEngine On
RewriteMap upper2lower int:tolower
RewriteMap usermap txt:/etc/apache2/userlist.txt
RewriteCond %{THE_REQUEST} !/~[Zz][0-9]{8}
RewriteRule ^/~([A-Za-z0-9]+)/?(.*) http://www.example.com/~ ${usermap:${upper2lower:$1}}/$2 [L,R=301]

I’d love to hear comments, or improvements on the rule set.

Installing VMware Player 2.5.1 in Ubuntu 8 via rpm

I have been running VMware player 2.0.4 since August to launch a windows XP Virtual Machine.  I don’t really use the VM all that often, but when I am doing web development, I need to be able to test in IE, and thats the only way I can do it w/o rebooting to Vista *shudder*.     Towards the end of September it started telling me there was an upgrade available.  I went to the VMware website only to discover they had stopped providing the .tar.gz version of VMware player.  My only options were .bundle or .rpm.    Not really feeling like I wanted to be all that adventurous I ignored the upgrade requests.    Finally after installing the latest kernel patches last night I decided to go ahead and upgrade VMware Player as well since I would have to re-compile the kernel modules again anyway for the new linux kernel.  Having never tried to install and RPM on Ubuntu I was at a loss.

Continue reading

Foxmarks in the Library

Recently I was asked by one of our librarians to come up with a way to easily add bookmarks to our Internet workstations.   A little background on this situation follows.  Our Internet workstations are all Linux based, with a custom version of FireFox.  This custom version of FireFox has a lot of things disabled to keep the browser in a stable stat.   I have removed the ability to modify the bookmarks on the workstation in any way. The event code for drag and drop, the menu items, you name it, its gone.   This has made it impossible for the librarians to manage the bookmarks on the workstations themselves.   Any bookmark changes have required me to connect to the machines via SSH and manually update the bookmarks.html file.    This method was just not convenient, and did not allow for easy updates by any means.

Earlier this week, thanks to the offloading of some tasks to our new employee, I was able to put some thought into this problem.   I needed a solution that was easy to maintain, simple for the librarians to use, and most of all, easy to implement.   That last criteria ruled out creating something from scratch, which I really didn’t want to do anyway.   Earlier in the week a co-worker had mentioned how he had just setup foxmarks on his machine and how it was going to sync his bookmarks both at home and work.   It hit me then, why not take a look at foxmarks.  I downloaded and installed it in my browser, and it did exactly as it was designed to.    I realized then that it was a purely native chrome based app.   This fact about its design made it a perfect candidate for what I needed.

I set to creating a generic account for the library, a simple task thanks to the easy to use interface.  Once that was done, I installed foxmarks into the browser on one of the Internet stations.  Due to the customizations, this was not as easy as it normally would be. ( I have all installation menus, and handlers disabled.  Ooops…) I finally worked out a way to install the extension, and once I did I set it to use the newly created account, and checked the box to save the sync password.   Foxmarks  performed its initial sync, and I was able to confirm the success by browsing the foxmarks website.   I then closed the browser, clicked yes on the dialog to clear all stored personal information and felt confident I had a good start.   I re launched the browser, hit sync, and foxmarks asked me for the password for the sync account.  What? I was certain I checked to save the password.  I checked it again, and restated the browser, again clearing the personal information.  Sure enough, foxmarks asked for the sync password again.   It then occured to me that clearing the personal information was probably clearing the foxmarks password.   That would be a problem for sure.  Confident that the password hurdle could be overcome, I set about to modifying the chrome files, and was able to hid the configuration menu items, and remove the keystroke sequence for accessing the configuration menu.

foxmarks-overlay.xul
    <menupopup id="menu_ToolsPopup">
        <menu id="foxmarks-menuitem" label="Foxmarks" class="menu-iconic"
            image="chrome://foxmarks/skin/images/foxmarks_bug.png"
            accesskey="&menu.accesskey.foxmarks;"
            insertafter="devToolsSeparator" hidden="true">

After the UI modifications were complete I  again launched the browser, and checked over the browser to make sure nothing was visible that could allow malicious patrons to manipulate the setup.    Everything I could think of was tested and it passed with flying colors.  I then added a bookmark via the website, and triggered the sync process.   After entering the password, foxmarks synced and the new item appeared.  Again, I still had to fix the password problem.   I  closed the browser again, this time un-checking the options to clear the password store.  After re-launching foxmarks synced perfectly, remembering its password.  This then confirmed for me that foxmarks was indeed using the firefox password store.  It makes perfect sense that it would, but of course in this situation, it’s very inconvenient.    I again dove into the code that comprises foxmarks.  I found, in the foxmarks-settings.js file two functions that handled the username and password.    As I suspected they ultimately called “return” with the value for the username and password.   A simple one line change to each of these functions resulted in a hard coded username and password that would stay put after a clearing of the password store.  By placing a return() just inside the function declaration we essentially bypass the default actions of  the functions.

 get username() {
	return "our_foxmarks_user_account";
        return this.getCharPref("username", "");
    },

 get passwordNoPrompt() {
        return "our_foxmarks_account_password";
        if (!this.rememberPassword && this.sessionPassword) {

After saving the modified file, I started up firefox and hit the sync keystroke, presto, no request for password or user name, and the browser synced.  I restarted again, making sure to clear the password cache, and again foxmarks worked perfectly.   At this point I deployed the modified version of foxmarks to all of our workstations, and sat back and watched the fun.   Within a short period of time, every workstation had correctly synced its bookmarks and all was well.

Finally I  sat down with the librarians and explained how to work with foxmarks’ website interface.  By the end of the first evening after foxmarks was installed we had a healthy collection of frequently used websites all bookmarked, and categorized.   The sync process has been working well and we have had no real problems.  (there was one point where I had accidentally left one of the browsers restored to its default state and some things were modified, but I caught it quickly and fixed the problem.

This alone would have been a fantastic solution, but not being one to rest on my laurels, today I used foxmarks ability to create RSS feeds from links in folders, and used that data to allow the library to randomly select a link and twitter it.  Yup, more fun with twitter.