Cookie Notice

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


Low Wattage Lighting from LumenCache

I've been thinking about the subject of lighting recently, looking to make myself a computer-controlled fading lamp. I've gone from thinking "I'll wire up a bank of modern LEDs" to "I'll figure out how to hook a digital potentiometer to replace the slider in a CF dimmer switch". I hadn't really given great thought about the future of how lights work.

Thinking about the future of lighting is what LumenCache is there for, and that's not at the lamp level, but at the building level. Let's hit a few ideas.

  • LED lights have a life of 100,000 hours, but the drivers burn out more like 25,000 hours. (I'm reciting from a presentation where I didn't take notes, so I could have it wrong, but I believe I have the jist of it right.) So, we're talking about a quarter of the life of the bulb thrown away.
  • So, we get better drivers, kicking out DC power, which does not have to be high wattage, and we put 'em in a central location.
  • Lower wattage means lower costs for lighting (and LEDs are getting brigher for less all the time) and lower heat. It also means that putting a battery with the system means you can keep the lights on and the system going through small power interruptions.
  • The wiring doesn't have to be the high-wattage wiring we use to push standard electrical power. It can even be kicked over CAT5. It isn't Power Over Ethernettm but it is power over ethernet cable. CAT5 has four pairs, and the standard only uses the outer pairs, so they're putting power over the center while keeping bits on the outside. (It has been a decade since I last crimped an ethernet cable, so I might have some of those details mixed up, please see your cabling professional.) So, you can use some of your runs to go to your WiFi access points.
  • Control is also at the center, but definable to the switches (and they can be standard switches) and also (presumably) via computer controls, web applications and smartphone apps. Or at least in the future.
  • And, it isn't just on/off. You can fade lights, too.
I don't expect that sort of wiring setup any time soon, but I hope it is clear that I love this idea.


The Quest For Javascript Templating

I first heard about templating several years ago at YAPC::NA 2006, when Ingy döt Net talked about Template Toolkit. I honestly did not get it then. I was putting my HTML in my code at the time, and I just didn't get it.

Soon after, I started working at the Lab, and Lab standard was to use CGI, so I started to do that, and my code went from:
print qq{
    <a href="$link">Link</a>
    } ;

to something more like.

print $cgi->a( { href=> $link } , 'Link' ) ;

That example is simple enough, but it gets complicated when you're putting together a large table of tabular data. (I feel I must explain that I'm tables for their proper purpose.) The Lab is now moving toward using Dancer as our framework (we don't have it fully implemented yet, but I have some things very close) and thus use Template Toolkit fairly regularly, and I foresee a day in which I won't need to have massive bricks of code to put together my HTML. At least in Perl.

Javascript, that's another matter.

        apr.chip_url ,
        function ( data ) {

            $( '<fieldset id="chip_field">')
                .addClass( 'narrow_fieldset' )
                .appendTo( chip_div ) ;
            $( '<legend>')
                .text( "Chips" )
                .appendTo( chip_field ) ;

            $( '<div id="select_div" />' )
                .appendTo( chip_field ) ;
            $( '<select name="chip_sel" id="chip_sel">')
                .appendTo( select_div ) ;

            $( '<div id="control_div" />' )
                .text( ' Include Control?: ' )
                .appendTo( chip_field ) ;
            $( '<input type="checkbox" />' )
                .prependTo( control_div ) ;

            $( '<div id="submit_div" />' )
                .appendTo( chip_field ) ;
            $( '<div class="button" />' )
                .text( 'Choose Chip' )
                .appendTo( submit_div )
                    function () {
                        apr.write_chip() ;

            // Fill the Select
            var d_list = [] ;
            for ( var i in data ) { d_list.push( i ) }
            d_list = d_list.sort() ;
            for ( var d in d_list ) {
                var i = d_list[ d ] ;
                $( '<option/>')
                    .text( data[i].name )
                    .val( i )
                    .appendTo( chip_sel ) ;
            } ,
        ) ;

This is some live Javascript I wrote. It uses jQuery, because if you don't use a framework of some sort to handle then differences between browsers, you are asking for trouble, and I've since discovered some ways to do appends better, but this is exactly the big block of ugly stuff that I hated with CGI and made me pledge my babies to Template Toolkit.

So, what I'm in desperate need for is Template.js to go with Or the like. I am sure that this is not just my problem. I am sure that other people have hit this problem and created a solution. Can anybody point to a good solution?


We can Shoot Mosquitos OUT OF THE AIR with Lasers!

The laser here was pulled from a DVD player, if I remember right.

It is aimed by an older PC, using NVIDIA's  CUDA technology, which turns the GPU you're using to get lots of frames of 3D acceleration in your FPS games into a gob of massively parallel processors. This technology is being looked at for places where mosquitoes contribute to the problem with Malaria.

We're solving Malaria by blasting insects out of the sky with lasers aimed by video-game technology. We live in the future.


Planning My Lamp Project, with Pictures

Have I gone on about my lighting plan? No?

It connects a few of my interests and plans.

  1. I'm starting to become a morning person, which gets a bit hard during the winter, when sunrise is several hours away when I get up. Darkness is important for serotonin is important for sleep, but lightness is important for waking up. But sunlight alarm clocks are both expensive and a single-tasker in my mind. Multitasking might be bad for people's heads, but to my mind (and Alton Brown's) our tools should be multitaskers. 
  2. The Android@Home talk at Google I/O 2011 really inspires me, too.
  3. The key to the sunlight lamp is the fade of it. It strikes me that jarring changes from dark to light would not be as good for waking up well as a gentle increase of light. Like sunrise. 
  4. I'm learning about the Arduino and electronics in general and want to develop those skills more. I'm also a programmer, so these things I build, I'd ultimately want to be able to control via web interface and/or crontab.
  5. I like torchiere lamps, the kind that bounce light off the ceiling, but the one I still have is a halogen lamp, and the problem with halogen lamps is that they get crazy crazy hot, and my current one is either broken or has a burned-out bulb. I'd rather replace it.
  6. The means I know so far to control the dimming of lights is phase width multiplexing, which means turning on the LED for a number of milliseconds and then turning it off for another number of milliseconds to make it seem like it's dim, but you know? There exists an entire industry which involves itself with creating of light from electricity, and I'd rather work with that and involve the greatest amount of industry standard and the smallest possible amount of individual invention.
So, I went searching in Menards on Sunday, and I found a few things. There's a torchiere lamp that's $21 and a wall switch that'll dim CF bulbs for $17. (I'm going to have to live with a lamp with a hacked wall switch on it. I'll live.) The CF is $7, but it'll pay for itself over time. The one-gang outlet box will be < $1. Somehow, I'll have to mount it, but I can dream about that later. I'll need to get two switches, I think. One to make work and one to tear down and connect the Arduino to. That makes it $21 + $17 + $17 + 7, which brings us to ~$60. Before the cost of an Arduino. And I'll have to get a shield

Thing is, I get something like this $7 switch and I won't get the graceful increase or the control, but I get something I know works. Maybe I should think this through some.

Petdance says if you have SELECT * in your code, you have a bug

Or, he retweeted it. I think. He knows where to yell at me if I got that wrong.

I don't really agree, except maybe the memory hit when you get tons more data than you expected or need, but the case I'm talking about here is a structured database dump. I'm proud of this query, and I'll expand on it.

        SELECT *
        FROM  sequence_sample
        LEFT JOIN accessions
            ON  sequence_sample.accession_id = accessions.accession_id
        LEFT JOIN requests
            ON  accessions.request_id        = requests.request_id 
        WHERE run_id = ?

A sample is an accession, except that a sample is an accession associated with a run, and that accession can be associated with many runs but only one request. I could see adding several joins to bring in controlled vocabularies, where, for example, the library types come in.

I've worked with SQL for a while, but only now am I integrating the joy of joins. I can thank Coding Horror for his excellent explanation on what the different joins mean, and Learning SQL for the use of ON to specify  the JOIN joins to distinguish it from WHERE which brings in the unique constraints