I might need this crazy javascript obfuscation one day. Either that, or its fun to look at:
http://discogscounter.getfreehosting.co.uk/js-noalnum.php?txt=alert%28%22hai%22%29
Wednesday, July 28, 2010
Friday, July 23, 2010
Make a Map from a list, perl style
Make a Map from a varargs list. Useful for iBatis parameterClass objects.
Thursday, July 22, 2010
Charles Schwab reconcile button in online banking
I made a grease monkey userscript to add a reconcile button to chuck schwab online banking checking site, so you can balance your checkbook more easily.
Bank of America had this feature on their online banking website and i missed it, so i added it to chucks site.
Get the script here: http://userscripts.org/scripts/show/82095
Bank of America had this feature on their online banking website and i missed it, so i added it to chucks site.
Get the script here: http://userscripts.org/scripts/show/82095
catman
How to autowire things in spring
In order to autowire something the following things must be true (that i know of)
- - The object you are autowiring needs to be annotated with @Component
- - The object that will contain the autowired object needs to come from the spring context, meaning:
- - applicationContext.xml needs to have a bean definition of it
- - the place where its is newed needs to be replaced with the call to pull it from the WebApplicationContext
Thursday, July 15, 2010
intellij 9 autoscroll to/from source
Intellij 9's autoscroll to source/autoscroll from source is broken.
Sometimes it doesn't actually scroll to source when i view a file.
Why?
I don't know.
I don't know how to fix it either.
I wanted to blog about it so that maybe someone will find a fix and leave a comment.
Thanks.
Sometimes it doesn't actually scroll to source when i view a file.
Why?
I don't know.
I don't know how to fix it either.
I wanted to blog about it so that maybe someone will find a fix and leave a comment.
Thanks.
Tuesday, June 29, 2010
IE8: content-disposition:inline, opens as download
Problem:
We just had a pretty weird problem. Internet Explorer 8 decided to open some links as downloads instead of just navigating to the files as per usual. All normal browsers did not have this problem. I immediately checked the headers which revealed nothing out of the ordinary:
Solution:
My coworker who i now owe 6 beers suggested that because of IE's stupidity it is looking at the entire Content-Disposition line, and doing substring matching on first 'attachment' and then 'inline'. He was correct. IE stupidly saw this line as basically Content-Disposition:attachment;
The fix was to change the filename to something that did not include 'attachments'.
We just had a pretty weird problem. Internet Explorer 8 decided to open some links as downloads instead of just navigating to the files as per usual. All normal browsers did not have this problem. I immediately checked the headers which revealed nothing out of the ordinary:
Server: Apache-Coyote/1.1 Cache-Control: public Expires: Thu, 12 Jul 2012 19:13:38 GMT Pragma: Thu, 12 Jul 2012 19:13:38 GMT Content-Disposition: inline; filename="Recipe_Details_Attachments.htm" Content-Type: text/html Content-Encoding: gzip Vary: Accept-Encoding Date: Tue, 29 Jun 2010 19:13:38 GMT Connection: close
The Content-Disposition: inline; part tells me that the browser should not open this as a download.
Solution:
My coworker who i now owe 6 beers suggested that because of IE's stupidity it is looking at the entire Content-Disposition line, and doing substring matching on first 'attachment' and then 'inline'. He was correct. IE stupidly saw this line as basically Content-Disposition:attachment;
The fix was to change the filename to something that did not include 'attachments'.
Monday, June 14, 2010
NPR's On Point Theme song
For years now ive been trying to figure out NPR's 'On Point' theme song. It sounds like a pretty cool song but they only play 10 seconds of it or so. I was listening to some Four tet today and figured it out the song is:
Four tet - Everything is Alright
And sadly it seems like everyone else on the internet knows this already. i wonder why i failed at googling it so many times.
Four tet - Everything is Alright
And sadly it seems like everyone else on the internet knows this already. i wonder why i failed at googling it so many times.
Wednesday, June 09, 2010
viewport resize event in IE
There is no viewport resize event in internet explorer, there is a window resize event, but its not the same. A window resize can mean that the size of the document within the view port has changed, for example 10 pages were added to the document.
I needed to know when the actual window was resized, so i wrote this hack to make that easy:
I needed to know when the actual window was resized, so i wrote this hack to make that easy:
Friday, June 04, 2010
Thursday, June 03, 2010
Disabling an input is slow on IE
So we ran into a problem today where disabling a massive amounts of inputs was really slow in IE8. It would take several seconds to disable 200 inputs. Caching the DOM elements in an array did not seem to help much. Setting the actual html attribute was the slow part.
My coworker came up with a pretty great IE hack to speed up the process of disabling and enabling the inputs:
faking it turns out to be faster then doing it the real way.
My coworker came up with a pretty great IE hack to speed up the process of disabling and enabling the inputs:
faking it turns out to be faster then doing it the real way.
Friday, May 14, 2010
Code Ericisms
I know some guy who writes pretty funny stuff in code. I am going to write some of it down for my own amusement.
returnStatus = "HTTP/1.1 500 Done blowed up\r\n"
returnStatus = "HTTP/1.1 500 Done blowed up\r\n"
Saturday, April 24, 2010
Migrating to syntaxhighlighter 2.1.x
Problem:
I recently decided to upgrade to syntaxhighlighter 2.1 from 2.0 on my blogger blog. I thought it was going to be as easy as dropping in a new version. I was wrong, the TEXTAREA in which i was putting my code is no longer supported. instead SCRIPT tags are used to enclose the code! AHHH! I have about 40 code snippets on my blog and conversion seems very not-fun.
Solution:
I started to hand convert some of the entries, to find that the new blogger post editor was also losing all of my tabs! This was going to be painful to do by hand..
Alas, i decided to try to do it with javascript, and it worked!
I pulled in the latest jquery into my template to ease the pain. Instead of the regular synataxhighlighter init i now have this:
Now, i dont need to hand convert all of my textareas to the new format, and the tabs are saved. Good deal!
I recently decided to upgrade to syntaxhighlighter 2.1 from 2.0 on my blogger blog. I thought it was going to be as easy as dropping in a new version. I was wrong, the TEXTAREA in which i was putting my code is no longer supported. instead SCRIPT tags are used to enclose the code! AHHH! I have about 40 code snippets on my blog and conversion seems very not-fun.
Solution:
I started to hand convert some of the entries, to find that the new blogger post editor was also losing all of my tabs! This was going to be painful to do by hand..
Alas, i decided to try to do it with javascript, and it worked!
I pulled in the latest jquery into my template to ease the pain. Instead of the regular synataxhighlighter init i now have this:
Now, i dont need to hand convert all of my textareas to the new format, and the tabs are saved. Good deal!
Friday, April 23, 2010
Populate a DTO with mock data
Problem:
Every so often i need to have a list of some simple DTOs in order to build a screen. The DTOs need to be populated from the database, but the query is not ready. Its somewhat painful to write dummy data creation methods over and over again.
Solution:
Using Groovy(though not required), Spring and a bit of reflection i cover most of the simple DTOs.
To use, pass the class a list of which you expect
Every so often i need to have a list of some simple DTOs in order to build a screen. The DTOs need to be populated from the database, but the query is not ready. Its somewhat painful to write dummy data creation methods over and over again.
Solution:
Using Groovy(though not required), Spring and a bit of reflection i cover most of the simple DTOs.
To use, pass the class a list of which you expect
Wednesday, April 21, 2010
jQuery plugins: default options
jQuery plugins should expose their default options as a global hash. This is useful if you want to always override the defaults in the exact same way across your entire site.
Most good plugins already do this, for example jQueryUI plugins do this. Here is the plugin code that will let you expose your defaults as a global variable:
Tuesday, April 13, 2010
Tibetan Prayer Flag Cat Toy
Thursday, March 25, 2010
Bogdan Raczynski Samurai Math Beats Lyrics
i just wanna play checkers, one and together
i just wanna play checkers, one and together
learnin ninja-moves
karate battle stars we'll become
you and I together, let's learn ninja moves
lets learn to battle the galaxy for ownership of the kingdom
and whats to come
we'll do battle in outer-space and fight the bastardly citizens of who resist tem.bu....
you and i doin ninja moves
doin karate moves
doin black-belt style
black belt
lets just fight the forces of evil in our galaxy, together
with our light sabers
with our pistols and guns and sticks and bones and rabbits and dogs and poop and all we can find
la la la la.. waaa...
black belt
these are the kenji's samurai math beats yes uh, yes uh
i just wanna play checkers, one and together
learnin ninja-moves
karate battle stars we'll become
you and I together, let's learn ninja moves
lets learn to battle the galaxy for ownership of the kingdom
and whats to come
we'll do battle in outer-space and fight the bastardly citizens of who resist tem.bu....
you and i doin ninja moves
doin karate moves
doin black-belt style
black belt
lets just fight the forces of evil in our galaxy, together
with our light sabers
with our pistols and guns and sticks and bones and rabbits and dogs and poop and all we can find
la la la la.. waaa...
black belt
these are the kenji's samurai math beats yes uh, yes uh
Friday, March 19, 2010
Tuesday, March 16, 2010
jQuery: Detect Windows XP Theme

I started building a jquery dropdown widget, and i ran into a problem where i was not styling the dropdown arrow correctly because i developed the widget in the classic theme, but the xp theme styled widgets differently.
Clearly i needed to be able to assign different classes to my widget depending on the user's theme if i wanted the widget to look natural to that user.
The problem is that the user's theme setting is not something available through a javascript api call, nor is it in the user agent string. I used a javascript technique called feature detection to get this information. Here is how it works:
We create a button element and assign it background color called 'ButtonFace'. This is a special system color that is different depending on what theme you use. Next we need to get the computed color of the button element, and remove the element from the DOM. The idea is that a user in XP theme will have a slightly different colored button than a user in the classic theme.
I used some jQuery to make my life easier, but it would be easy to port this code to any other framework, or do it in plain javascript.
The code above plugin will create a new jquery.support object $.support.windowsTheme which contains a name member that will be set to 'xp' if user is using the XP windows theme, 'classic' if they are using the classic theme, and undefined if they are using a custom theme, or another operating system.
To see this code in action look at this demo page
For further updates to this code please visit the jquery plugin page
Caveats:
- This code does not check if the user is actually using windows, you would need to add that check yourself.
- I have tested this code in firefox 3.6 and IE6,7 on windows XP. This code should really be also tested on Vista and Windows 7.
It has come to my attention that someone has already done this before
Wednesday, February 17, 2010
Pear Infused Vodka Recipe
I had a really great tasting pear infused vodka over the weekend. It was full of flavor and very sippable. I got the recipe of how it was made from the dude who made it:
Ingredients:
- 2 pears
- 1 liter vodka
- 4 whole pods of cardamom
- 2 whole cloves
- 1 cinamon stick
Directions:
Take 2 pears, chop them up into chunks (discard the core/stem, but leave the skin on). Put them in a bowl or other infusing vessel. Pour about 800-850 ml vodka over the top (I add extra because some of the vodka inevitably disappears. I guess the pears drink some and some of it evaporates. Annoying.) Cover the vessel and let it sit for a week at room temp. After a week, add 4 whole pods of cardamom, 2 whole cloves, and a cinnamon stick. Then, let it sit for another week. Strain, pour in bottle, chill, enjoy.
Ingredients:
- 2 pears
- 1 liter vodka
- 4 whole pods of cardamom
- 2 whole cloves
- 1 cinamon stick
Directions:
Take 2 pears, chop them up into chunks (discard the core/stem, but leave the skin on). Put them in a bowl or other infusing vessel. Pour about 800-850 ml vodka over the top (I add extra because some of the vodka inevitably disappears. I guess the pears drink some and some of it evaporates. Annoying.) Cover the vessel and let it sit for a week at room temp. After a week, add 4 whole pods of cardamom, 2 whole cloves, and a cinnamon stick. Then, let it sit for another week. Strain, pour in bottle, chill, enjoy.
Subscribe to:
Posts (Atom)


