Cookie Notice

As far as I know, and as far as I remember, nothing in this page does anything with Cookies.

2012/06/22

Everything Is Preceeding As Planned. Excellent! (Webcam hack)

I was just given this swing-arm desk lamp/magnifying glass.

You might ask yourself, "Why does Dave need a desk lamp/magnifying glass?"

In all honesty, I don't. Part of the requirements of this gift is that I return the magnifying glass when done.

What I need is the long arm.

What I want to do is replace the lamp part with a webcam, so I can move it around, set it up in a good angle if I'm doing a Google+ Hangout, or set up software to take a shot every few minutes when I'm doing a project, so I might blog it or make it an Instructable or whatever. (If I could do it over again, I'd blog the heck out of rewiring my Tele.)

I was inspired by this Instructable (linked from this Lifehacker post) but I'm thinking I have to do something better with the mount than a ball of Sugru (not that Sugru isn't magic). Thing is, I'm not sure what. A big part of it will have to rely on what sort of webcam I get to stick on the end of this. I have two cameras on eBay I'm following, but I don't know if I'll go for one or the other.

In other hacking news, I have an Easy button. I now need two things to create my one-button keyboard to handle my Unifying-vs-KVM issue: a Teensy microcontroller and the knowledge of how to send a Scroll Lock character in Arduino. One of those is only $16 away. The other? Dunno.

In barely-related hacking news, I've recently found a great thing. Ever heard of X10 home automation modules? At the most atomic, they're boxes you can plug a thing into and turn it on and off by your whim, being either via computer or via a remote. Their problem, by my experience, was that they talk over power, and this meant that you had to segment your stuff all over. I never got it working to the point I was happy with it. Imagine the same sort of thing, communicating over your WiFi network. Belkin calls it WeMo. I call it magic. There's also a motion-sensor module. Even better, they are connected to the magic of IFTTT, which makes scripting things so easy! Setting triggers on motion to do things like tweet or log to Evernote or even turn on a light with WeMo are such a good idea. I don't know if I can get conditionals, like if (motion && time > 6 && time < 23 ) { turn_on( light ) } , but I'd like to give that a try.

But, ultimately, I'm more interested in shades of gray than black and white. Or rather, variations of brightness over on and off. I have just found that there are dimmable compact fluorescent bulbs and dimmer switches for use with compact fluorescents. Now, if I could replace/augment the actual switch in that with a Netduino or something, I could make a lamp that's entirely controllable online. CF dimmer switches are $20, so I'd roll up my lamp first, have the non-networked dimmer implementation going, then work on tearing apart a second dimmer switch to Arduino-connect it. But that strikes me as the future.

2012/06/21

Addition to my EDC: FitBit Ultra

In situ
Yesterday, I received a FitBit Ultra as a gift, and today, I've taken a walk and a run with it. I let it charge overnight, so I don't have any of the sleep data yet.

There is an API. I expect to write up my experiences with that API here, put my code on Github, and publish the results on Posterous.

2012/06/18

Gotta Ask: Javascript Library Development

By High Performance Web Sites, you should be putting all your Javascript into one file so there's one download, then minifying it and gzipping it to make that download as small as possible.

Does anyone actually do this? And if so, what tools do you use to manage your workflow? How do you test? Is there already prior art here?

I Like What I Did Here

I'm writing some Javascript to work this user interface I'm making. By one suggestion, you're supposed to work out the UI, set up the backend DB, and once both are as you like 'em, work on connecting them./

I am not quite there yet, but I'm close. I have n similar select boxes and n entries for each, and I would like each one to be unique, so, select box i has option i selected by default. The user can override if necessary, but in most cases, that should not be necessary.
I'm pulling each of the options from the database, so this is fairly dynamic. This is what I came up with.

// --------- --------- --------- --------- --------- --------- ---------
// fill the "i5" select boxes, and fit in order
// --------- --------- --------- --------- --------- --------- ---------
pr.fill_i5s = function ( assay ) {
    $.get( pr.url , function( data ) {
        var assay_barcodes = data.assay_barcodes ;
        var assay_data = assay_barcodes[assay].data ;
        var i5_list = assay_data.i5 ;
        $( 'select.i5' ).each( function () {
            var id = $( this ).attr( "id" ) ;
            var id_array = id.split("") ;
            var id_letter = id_array[3]  ;
            $( '#' + id ).html( '' ) ;
            for ( i in i5_list ) {
                var i5 = i5_list[i] ;
                var i5_name = i5.name ;
                var i5_bases = i5.bases ;
                var i5_array = i5_name.split("") ;
                var i5_num   = i5_array[3] ;
                if ( pr.check_i5( id_letter, i5_num ) ) {
                $( '<option/>' )
                    .text( i5_name )
                    .val( i5_name )
                    .attr( 'selected' , 'selected' )
                    .appendTo( '#' + id )
                    ;
                    }
                else {
                $( '<option/>' )
                    .text( i5_name )
                    .val( i5_name )
                    .appendTo( '#' + id )
                    ;
                    }
                }
            } ) ;
        } , 'json' ) ;
    } ;

// --------- --------- --------- --------- --------- --------- ---------
// function to move checking into a subroutine, so that i5s flow
// automatically
// --------- --------- --------- --------- --------- --------- ---------
pr.check_i5 = function ( position , barcode ) {
    if ( position == 'a' && barcode == '1' ) { return true ; }
    if ( position == 'b' && barcode == '2' ) { return true ; }
    if ( position == 'c' && barcode == '3' ) { return true ; }
    if ( position == 'd' && barcode == '4' ) { return true ; }
    if ( position == 'e' && barcode == '5' ) { return true ; }
    if ( position == 'f' && barcode == '6' ) { return true ; }
    if ( position == 'g' && barcode == '7' ) { return true ; }
    if ( position == 'h' && barcode == '8' ) { return true ; }
    return( false ) ;
    } ;

I perhaps should use a case statement, but honestly, I haven't used one of those in production code in years, and I'm not sure that you can case off two variables. I suspect I should use === for strong typing, but I can always change that. I know that, if I had ands and ors like this in the center of the first subroutine, it would be ugly. As is, I like this.

2012/06/06

What I want in Google Voice

I found a post in my Google Reader where a person listed his wish list, pointing to a Pocketables post called "Here's my Google Voice wishlist".

I honestly just have one point, and if I didn't work in a place with no cellphone access, I wouldn't have that one.

I want my Android phone to be able to make and receive Google Voice calls over WiFi. I can do that on my laptop. I could do it with Skype, but I don't have a Skype-In number and if I did, that still wouldn't be the number I give out everywhere. This would be the real lifesaver for me.

I get "Integration beyond Sprint" but as I use Sprint, it isn't a crucial issue for me. I barely use SMS and MMS, as it's hamstrung email, but I get why some would want GVoice to do MMS as well, but it isn't a seller to me.

I scratch that. Being able to upload my voicemail greeting would be wonderful, too.

2012/06/05

Addendum to Yak Shaving and such

First, let it be known that my issue with minification seemed to be a bug in the code being run through it, and making my code more JSLint-compliant (not yet compliant, but more so) solved that issue.

But it was suggested that I should use JavaScript::Minifier::XS, and that works, too. Plus, this is a library that's on CPAN, which is somewhat a stamp of quality and portability, so I'm sure I'll work with that. I suppose I should head-to-head the compression and JSLint of both minifiers, but that can happen later.

Do I Get This? (A Rant on Nutrition)

This blog is about ranting, not technology. Since I work in technology, most of my rants are tech rants, so it is easily mistaken for a tech blog, but I reserve the right to rant about my health, as I have done recently.

I have lost a fair amount of weight, to the point that I'm a four-year-old's weight* away from my college (first time) weight. People ask me what I have done to lose the weight. First and foremost, I've started to eat more.

Specifically, I have started to eat breakfast, lunch and dinner. Before, my tendency was to wake up, go to work or school, do that through the day, go home, and have my first meal at the day at dinner. Sometimes, this was after 10pm. Of course, when I was there, I was famished and would eat everything, quickly. Of course, I'm exhausted, so soon after I ate, I slept. From what I understand, this is about as close to shutting down your metabolism as you can get.

Recently, I've started to keep oatmeal in my desk and frozen meals in the office freezer. I get to the office and pour my coffee while I nuke my oatmeal, and eat while I start my day. Since this is after I get to the office at 9am, this is usually about 3 hours after Tim Ferriss would suggest I do it (and much less protein), but I've been running on exhaustion, using caffeine to keep me moving, for long enough that moves I can take that keep me from feeling groggy are fine, and right now, being awake in my bed for an hour or more before my feet touch the floor is fine. I'll have a protein-rich breakfast in the office before I'll jump up at 6 am to cook eggs or something, but I could see both happening.

Today's purchase is two boxes at my local supermarket. One is the 10-to-a-box apples and cinnamon oatmeal I normally get, and one is "Active Lifestyle" Chai Apple, promising to support "weight control", at 8-to-a box for the same price. The packages are bigger, and they suck up more water than my normal breakfast, but they are comparable.

Aren't they? There's a few percentage points here and there, but by and large, they are similar. I guess the bit thing is that the Active Lifestyle oatmeal has more fiber.

The other on-the-box claim is no cholesterol, and that's shared by both boxes of oatmeal.

My take on it is that, beyond the fiber, it's pretty much a wash between these two, but as long as I like the taste of apple oatmeal (and, in case it isn't clear, I love the taste of apple oatmeal) I'm fine to choose between these two. Is my analysis of this correct?

* I recall from my children's youth that they believe children should weigh 40 lbs and be 40" tall at 4 years. That was referred to as being "square". So, I'm within a square child of the weight where I thought I was fat in college. Strange how the metrics change over time.

2012/06/04

My Current Project

Image by LiminaMike
This relates to the Yak Shaving I mentioned recently.

I'm working on developing something in an MVC, and the specifics of it involve Javascript to handle the UI of it. As I'm expecting to have lots of unrelated Javascript libraries, I'd rather have one call for my stuff than several, so I'm working on a tool that

  • Allows me to write and test code both in individual library context and related to the whole code base
  • Automates the steps to get to combined, minified and gzipped code, as suggested in Steve Souders' High Performance Web Sites.
I have ugly code that I want to refactor — specifically, I have to programs (one for the minification and one for the test generation) when they could be easily and preferably turned into one — but it is functional. Except maybe not.

I think I'll have to get the admin to change the website config to announce gzipped files before I can get the test code going. I'm content to have that wait.

The bigger problem is minification. I found a Perl implementation of a Javascript packer called Packer, and my thought was "Yay! No more worrying about getting YUI-Compressor to work!" But, so far, it seems to be introducing errors. A working combined Javascript library fails to work when minified. So, I either look at Packer's internals or YUI-Compressor's internals.

Or, as I'm going to do, figure that combining is good enough for now, back burner the rest, and stop shaving this yak.

2012/06/01

My Caffeine Addiction

To the right is a picture of me in my office in 2009. I took it and like it because it has me with my preferred drink, Diet Coke.

In the 80s, I drank Mountain Dew and Mello Yello on occasion, and in the years since, I've put energy drinks and the like to my lips, but more often than not, when given a choice, I would go for the old standard.

Of all the addictive substances out there, caffeine addiction is the least harmful and the most socially accepted. You wouldn't expect a bar or a bong or a communal crack-pipe to be at the center of an office, but there is a coffeemaker. For some workplaces, an always-full cola fridge is one of the perks. Here's the Oatmeal on how coffee works in historical, economical and physical senses, here's C.G.P Grey's video on "the Greatest Addiction Ever", and here's Cracked on how caffeine gives you super-powers. Everybody loves caffeine.

Geeks especially love caffeine. Jolt was the geek drink with the phrase "All the sugar and twice the caffeine". Drinks have been judged by relative levels of caffeine. ThinkGeek has a category of Caffeine and Edibles which includes energy drinks, caffeinated mints and gum, and even caffeinated body wash. I don't know that caffeine is absorbed through the skin, but I understand the attraction. I wondered often when I was a Comp Sci student why more geeks take the next step from caffeine worship and just become speed freaks.

Last year, I decided that I've heard enough about caffeine to think, "Hey, I don't believe any of the scurrilous things they're saying about the magic bean, but I can't really say anything about it without trying to live without." Also, I was noticing headaches on Sunday, which seemed to come from not drinking any coffee or soda on Saturdays. So, I decided that I would have a month-long caffeine fast during the month of May.

May 1 was a Sunday, and I play guitar at church, and we talk in the church cafe during first service, and I always get a cappuccino, and I didn't think "no caffeine" until I was half done.

May 2 was the day we returned a rental car we got because of a car accident, and before I dropped it off, I stopped by McDonalds for breakfast, and what do I always get with my egg-burger every time I go to McDonalds for breakfast? A large Diet Coke. And I was again half done with the beverage before I said "Hey, wait."

This really put in mind what we mean by a habit. An addiction is when you mentally or physically need something to function, but a habit is an indication of behavior, what you do without thinking about it. I clearly did not think about what my beverage of choice was. Any thought about what I should be drinking came halfway into the process of drinking the beverage.

May 3, I remembered. I started the fast in earnest. I drank no caffeine. I felt okay.

May 4, in the midst of the horror, when I turned off my office lights and turned down the brightness of my monitors so my eyes would stop screaming, and filled my trash box with tissues filled with mucus and tears while breathing deeply in hopes that the cold air will still my nausea, my co-worker looked over and said "If you have the flu, you should just go home."

This is where it struck me.

This is where it struck me that regular doses of caffeine had left me reliant on caffeine, and when I don't imbibe it, my brain explodes.

This is the point where I decided to cut it out when I could. And I discovered that, to some extent, I can't get going with programming — my work, my hobby, my love — without juicing it up first. I wasn't sure and I'm still not whether this should be considered addiction or habit, but I recognized it as something, so, I decided to go by the rules of coffee at work but nothing after 5pm, and when I took vacation over Christmas, I went cold turkey again, but with few ill effects because I wasn't riding on a near-constant cloud of stimulation.

I'm not saying that everyone should clean up like I did. But you should consider. At the very least, you should keep some headroom so you can jolt up if you need to.