Saturday, December 03, 2011

configure boxee to work as a second monitor with sound over hdmi

My HTPC setup is simple:
I ran a 40 foot HDMI cable from my computer room into my bedroom through the basement. I hooked up my TV in the bedroom to be the 2nd monitor on my PC and set boxee to run on that monitor.

The problem:
I wanted to have Boxee use sound over hdmi, but also be able to listen to to music and play games on my computer as usual without the sound coming from the bedroom TV.

In your windows sound prefs set:
  • "Speakers" as your default audio device
  • "HDMI digital output" as your default communication device
In boxee sound config set:
  • primary soundcard: HDMI digial sound
restart boxee. Now you should be able to hear HDMI sound only on the TV, and all other sound will come from your speakers. 

Tuesday, October 18, 2011

Photosmart CN216 no LCD or power lights

I have a brand new (POS) HP Photosmart CN216 all in one print/scan/copy/web printer.
The only trouble is that sometimes it will power on, but no lights come on. The power light is not not blue, and the LCD is off. At the same time, the printer is on because its making the normal noises.

I was about to return it to HP since once this happens no amount of pressing the power button will "turn it back on". I found a solution:

The fix is to open the printer as if you were about to replace the ink cartridges, then SLAM it shut. It helps if you are are angry, but you will be when your brand new 100$ wireless printer doesnt work. This will cause it to turn on properly.

The downside to this solution is that it cannot be done at night when people are sleeping

Thursday, September 29, 2011

mysql function example

delimiter //
create function mytest () returns char(50) deterministic
declare c int;
select count(*) into c from table;
return c;
delimiter ;

Friday, July 08, 2011

Python: remove some entries from a dict

Remove a bunch of entries from a dict in an elegant way

Solution 1:

map(lambda name: dict.pop(name, None), ['some_key', 'some_other_key', 'bleee'])

Solution 2:
My coworker Dave came up with an even better way to do this thing:

map(dict.pop, ['some_key', 'some_other_key', 'bleee'], [])

Wednesday, April 06, 2011

Grails: Securing CKEditor URLs

I am using the grails CKEditor plugin and i wanted to secure the file manager urls to be accessed only by a site admin. I am using the Spring Security Core plugin for site security, but i was already using annotations elsewhere on my site, so using a InterceptUrlMap was not an option.

So, how to keep using annotations and secure a plugin's urls?

The trick is properly using the controllerAnnotations.staticRules (which really isnt that hard if you pay attention to the docs).
Here is the mapping that works for ANY url mapping you define to CKEditor:

Thursday, March 24, 2011

manually set id of grails domain object

if you create a new domain object and set its id in the constructor like this:
Cat catman = new Cat(id:1000, name: "catman", kind: "domestic short haired")
later, if you look at the object the id will be null. what gives?!

Its madness, but it works to assign the id after the object is made. Just add
and you are in business.

Note: if you want to save the object into db after doing this, you must set the id generator to 'assigned'

Sunday, March 13, 2011

lg cdma usb modem driver

The lg mobile phone driver is hard to find. i am using it to make bitpim work with my phone.

It will work with all LG VX-something phones and also is sometimes called this:

Prolific USB-to-Serial Comm Port Driver
LGE CDMA Composite USB Device Driver
LGE CDMA USB Modem Driver
LGE CDMA USB Modem Diagnostic Serial Port Driver
LGE CDMA USB Modem Diagnostic Serial Port (VCOMM) Driver
LGE CDMA USB Serial Port Driver

get it here:

Monday, February 21, 2011

Class needed by SvnTask cannot be found

getting this error when trying to build:

taskdef A class needed by class org.tigris.subversion.svnant.SvnTask cannot be found: org/tigris/subversion/svnclientadapter/SVNClientException


I didnt unzip all libs that came with svnant into my lib folder. Only unzipped svnant.jar. need to put them all in there.

Sunday, February 06, 2011

Multiple domains with tomcat behind apache

This is how you would host multiple domains/webapps on a single tomcat behind apache via mod-jk.

first setup tomcat behind apache

I am setting up a new domain called

in server.xml add this under last host:

<Host name=""  appBase="webapps-dogself"
  unpackWARs="true" autoDeploy="true"
  xmlValidation="false" xmlNamespaceAware="false">
and also add another connector port:
<Connector port="8010" protocol="AJP/1.3" redirectPort="8443" /> 

create a webapps-dogself directory next to webapps and give it the same permissions

in your virtualhost apache config:
JkMount  /* dogself 
in add dogself worker to list:

# Define dogself

If you want the manager app to work on the domain you need to:
mkdir /etc/tomcat6/Catalina/ 

and copy the manager.xml into it from /etc/tomcat6/Catalina/localhost

in /var/lib/tomcat6 create a webapps-dogself dir and give it 0775 perms and chown it to tomcat:tomcat

restart tomcat and apache

if you get error:
worker dogself can't resolve tomcat address
Check that your dns a/aaaa records point to your ip. Comment out the worker in and see if you can get to the apache vhost.

if any of the domains seems to point to another domain, ie the war that is running on one domain is incorrect. check if you are in the www.domain and if you have aliased the www both in tomcat and in apache. if you dont alias the www correctly tomcat will send you the the defaultDomain as defined in server.xml

Thursday, February 03, 2011

Linode: how to install mod_jk, tomcat behind apache

This "tutorial" is for Ubuntu 10.04 LTS (Lucid).
This is how you would set up Tomcat6 behind Apache2 via mod_jk

I am assuming that you have apache2 installed and tomcat6 installed. I also assume you have deployed and can find your tomcat app possibly on port 8080 of your linode.

  1. Install mod_jk:
    apt-get install libapache2-mod-jk
  2. Create in /etc/apache2/ and add the following into it:
    # this lives in /etc/apache2/
    # - ajp13
    # List workers
    # Define worker1
  3.  Edit your apache2 config in /etc/apache2/apache2.conf and add this to the end:
    # tomcat connector stuff:
    JkWorkersFile /etc/apache2/
    # Where to put jk shared memory
    JkShmFile     /var/log/apache2/mod_jk.shm
    # Where to put jk logs
    JkLogFile     /var/log/apache2/mod_jk.log
    # Set the jk log level [debug/error/info]
    JkLogLevel    info
    # Select the timestamp log format
    JkLogStampFormat "[%a %b %d %H:%M:%S %Y] 
  4. In your /etc/apache2/sites-enabled/ dir find the vhost you want to use tomcat and edit it, at the end of the vhost declaration put:
    #Everything under root goes to tomcat
    JkMount  /* worker1
    #html files should be served by apache2
    JkUnMount /*.html worker1
  5. Edit /etc/tomcat6/server.xml and make sure that the ajp connector is uncommented:
    <connector port="8009" protocol="AJP/1.3" redirectport="8443" />
  6. restart tomcat: /etc/init.d/tomcat6 restart
  7. restart apache: /etc/init.d/apache2 restart
  8. navigate to and you should be all tomcatted

Wednesday, January 26, 2011

How to make your bed for engineers

Being an engineer I am always looking for more efficient ways to do all manner of household tasks.
Making the bed has never been my strong point. My wife makes the bed faster than me, and it always looks better. I have long given up trying to figure out her technique, she probably just has many more years of experience than me. She is a principal bed maker while i am just a bed maker intern.

Yesterday a friend of mine shared a bed making technique with me that has improved the tidiness and speed of bed making. I would like to share this technique with you!

The secret to making large beds efficiently is to make the bed while you are in it! Being in the middle of the bed gives you maximum reach to both sides, where you can straighten out the covers. You no longer need to make several passes from one side of the bed to the other. After you get the bed looking nice, carefully roll out. Chances are that you will need just one more pass to fix the wrinkles in the covers.