Sunday, September 07, 2008

cheese stuffed chicken

I made some food last night that was good, using a recipe which i mostly made up. I need to write this down.

feeds 4:
  • 2 chicken breasts
  • 1/2 of a brick of frozen spinach 
  • 1 medium onion
  • some phylo dough
  • mozz cheese, atleast 3 cups
  • some melted butter
  • salt and pepper
Hammer the shit out of the chicken breasts so that they are flat. put some salt and pepper on them. Dice the onion and cook with olive oil on a pan, add the spinach. Cook until onion is cooked.
On each chicken breast, put 1/2 of the onion and spinach, and a ton of cheese, and roll the chicken up into tubes filled with cheese, onion and spinach. Get out the phylo dough, place 2 sheets on top of eachother and brush with melted butted until soaked. wrap each chicken roll in 2 peices of phylo dough.  place on baking sheet and bake for about 20-25 mins on 450.

yum

Tuesday, August 05, 2008

Debug Javascript in IE

When googling for best ways to debug javascript i found that there are plenty of articles out there about it, but most are old, and some that give bad advice.

Here is what i found works in August 2008 (with updates from Jan 2010 at the bottom):

For inspecting DOM:
  • Best: Firebug lite - gives you most of the dom inspection features of firebug, in IE. Lacks on the fly editing of dom, but shows computed styles well, allows to select elements on mouse over. Can sometimes be slow.
  • Useful: IE Developer Toolbar - Also allows to inspect DOM, but the interface sucks. You can change styles on the fly with about 10 mouse clicks per change. Allows you to see the "generated source" as IE sees it. This tool is nice when firebug lite is being slow
  • Not so good: Debug Bar - I found that this is not very good for DOM inspection, it lacks most features that the above 2 tools have. It does seem to be in constant development, so it might be good to check it out.
For debugging javascript:
  • Bestest-est: Microsoft Visual Web Developer 2008 Express - There is a pretty good tutorial on how to set this up on this blog (make sure to read the comment by James if you are a firefox user). This gives you a debugger as good if not better as Frontpage's for free. It is somewhat more painful to set up and use because you have to run the actual visual web dev program. Cant beat free though.
  • Best: Microsoft Frontpage 2003 (script editor) - After installing frontpage 2003, you can use the debugger that comes with it, it has the following useful features: breakpoints, watches, evaluation, viewing the stack and a few other features i havent looked at yet. This is the best script debugger for IE.
  • Useful: Companion JS - This tools seems to be able to pinpoint the line number where a javascript error occurs better then the script editor. This is actually really useful because IE sucks at telling you what the error is, and what line number it is on. It can do evaluations, but does not really have breakpoints or anything else useful. The error reporting is really good though. NOTE: you will need to disable this debugger in order to use any of the other ones.
  • Worthless / Horrible: Script Debugger - God this tool sucks. It is the worst excuse for a debugger ever. You cant set watches. The evaluator sucks.
For making your life suck less:
  • Matt pointed out a little javascript he wrote to quickly show you the generated sourcecode in IE.
  • Erik mentioned an IE 7 plug-in to make IE have some modern browser features. For some reason this is the first time ive heard about this thing. Pretty sweet, i see no reason not to install it.
edit 7/29/2009:
Finally i found a good javascript console that works in IE. It does a few extra things other then giving you expression evaluation. its good.

edit 1/14/2010:
Found an even better bookmarklet that gives you on-the-fly css editing in IE6 etc! Looks like firebug when loaded, and has DOM inspection like firebug. Very nice. No JS debugger because its a bookmarklet, but a very useful tool for the toolbelt indeed. Dungbeetle

Wednesday, July 30, 2008

foreach to iterate over a map in 1.5

When you iterate over a map you need to usually get the key and the value, use this to get them both without having to use the key to get the value!



This also happens to not raise any unchecked warnings which you would have to @SuppressWarnings("unchecked")

Custom tags: passing in maps or other datatypes that arent strings

problem:
I needed to pass a hashmap into a custom tag. This hashmap was to be created on the jsp page using jstl, and then passed into the tag as an attribute.
For some reason i was not able to find the solution with just one google query.

solution:

1. first, to create a hashmap on the jsp using jstl and add some stuff to it:


2. next, add another attribute to your tag in the tld file:


3. finally, pass the hashmap into your tag .. <tag someName="${something}" /> and make sure that the setter in the tag takes in a Map

Tuesday, July 22, 2008

Intellij escapes strings on paste

I started using intellij, and coming from eclipse, some things are just wrong, or missing.
One thing that was driving me crazy was that when pasting strings that contain escaped literals, intellij would escape the escapes in the paste.
This string:
"something \" \t cool"
would become:
"something \\" \\t cool"
this was bad, especially for pasting around html tags with attributes.

some googling shows a long and old thread of people bitching about the same on the intellij forums:
http://intellij.net/forums/thread.jspa?threadID=43296

Dont bother reading that thread though, there is no solution in it.

The solution is this:
http://plugins.intellij.net/plugin/?id=1464

This plugin unescapes your characters when you copy, so when you paste, intellij ends up escaping the characters and nothing breaks.

Friday, June 27, 2008

Music that ill forget about

Tracks:
Kylian - Lappi Inzoo (A1)
cEvin Key - Diagnosis
dntel - last songs
num num - foot switch
trans am - white rhino
four tet - she moves she
four tet - unspoken
Dubtribe Sound System - Wednesday Night
slowdive - rutti
Arovane - Pink Lilies
twine - plectrum
tosca - suzuki
con brio - apple
duo505 - facing it
duo505 - nochwas
duo505 - Just An Illusion
Herrmann & Kleine - Blue Flower
Kidneythieves - Mustard Seed
Kidneythieves - Crazy
Luomo - Tessio (from album Vocalcity)
Apparat - Not a Number
Apparat - Birds
Apparat - Komponent (Telefon Tel Aviv remix)
Swod - Fugitif 1
Opiate - Opittt
Boc Scadet - Sel Alterat
Beaumont Hannant - RS 364C
Kid Spatula - Trike
Loess - Viscer
Ladytron - Ghosts
Ladytron - Tomorrow
Quinoline Yellow - Eu Jach
Quinoline Yellow - Tradmacr9
Buraka Som Sistema - Kalemba (wegue wegue) feat pongo love
Tesendalo - Laura 1
Architect - A Monkeys Testdive In A Highspeed Car With A Broken Stereo
Lusine - Two Dots
Stendeck - Like Falling Crystals
The Mitgang Audio - Minor Causes
M83 - We Own the Sky
B-Complex - Beautiful Lies [listen]
Isolee - Initiate II [listen]
Bearsuit - Going Steady
Vitalic - Poney, Part 1 [listen]
Four tet - Everything is Alright
Destroid - Leaving Ground (Assemblage 23 RMX)
Mount Kimbie - Maybes[listen]
Christopher & Raphael Just - Popper (Shinichi Osawa Distortion) [listen]
Nautilis - Mofpex [listen]
$.99 Dreams - Rockland Psych Ward [listen]
Jello - O'verb [listen]
I Awake - Life Cipher [listen]
Bitcrush - The Days We Spent Within (Near The Parenthesis Remix)
Laub - Wortspur

Albums:
VA - Everything is Green
Arovane - io
num num - unknown sources
Opiate - Sometimes Ep
M83 - Saturdays = Youth
Goldfrapp - Head First
Diaphane - Samdhya
Emmon - Nomme

Albums good once in a while:
Ladytron - Witching Hour
Ladytron - Light & Magic
Ladytron - 604
Metric - grow up and blow away
Populous with Short Stories - Drawn in Basic
Computer Cougar - Rough Notes on High Stress
Ms John Soda - No P or D
Bearsuit - Cat Spectacular
Rocket Or Chiritori - Tokyo Young Winner
a guy called gerald - Essence (has the girl from lamb in it)
Telepopmusik - Breathe (Extended Mix)

edit this post

Tuesday, June 24, 2008

list of music i should get more of

Note to self: (updated constantly)
get more of the following bands because they are good:

Styrofoam - 6/24/08
ground zero - 8/15/08
arovane - atol scrap - 9/12/08
arovane & Phonem - 9/12/08
Apparat - Duplex - 10/3/08
wendy page - 3/25/09

Monday, June 23, 2008

obfuscated java code sample

This piece of java code compiles and runs. It is the most obfuscated java snippet i've ever seen.




requires java 1.5

Monday, June 16, 2008

iwlocal event fails - teamsite


Problem:
Today we had a horrible problem with teamsite. It appeared that no submit deployments were running since the box was rebooted for some patching.

Our submit deployments are configured in [TS_HOME]/local/iwlocal.cfg
where on 'iwatsub' event, a custom script kicks off the deployment.
This custom script logs to a file, and tailing that file showed that the script never ran, ever!

Solution:
after a bit of digging, i realized that the event subsystem was probably down. This is how you restart it, to fix this problem:

sudo /etc/init.d/iw.local stop
sudo /etc/init.d/iw.local start

after restarting iw.local the submit deployments started running again. It may be the case, that iw.local needs to run after a reboot, and does not do so automatically.

Thursday, June 05, 2008

apache vhost maintenance switching

problem:
i need to put my site into maintenance mode when some work is being done on the app servers.

solution:
add this rewrite to all vhosts that need to be taken down. When the switch needs to happen, create /system/maintenance.html
delete the file, or rename it when the maintenance is finished.

RewriteCond /system/maintenance.html -f
RewriteRule ^.*$ /system/maintenance.html [L]

NOTE:
this solution will cause all your images/js/css files to redirect to the maintenance page. Modify the regex if that is a problem, otherwise, dont use any image/js/css on the maintenance.html page.

Friday, May 30, 2008

music for may

this ftp has a little bit of everything:
ftp://194.44.214.3/pub/music/

.. and none of anything i like.

DBD: Exception Message: ORA-01407: cannot update to NULL


Here is another evil teamsite / opendeploy error that makes no sense:

DBD: INSERT INTO TABLE_NAME(row_id) VALUES (?)
DBD: Column: row_id, field: main/0/uid, Index: 1,Converting '100' to DECIMAL
DBD: DELETE FROM TABLE_NAME row_id = ?
DBD: Column: row_id, field: null, Index: 1,Converting '200' to DECIMAL
DBD:
DBD: *******************************************************
DBD: SQLException occured in TDbSchemaGroupCfg
DBD: Exception Message: ORA-01407: cannot update ("PRDLIVE"."TABLE_NAME"."ROW_ID") to NULL

At first glance it seems like you are updating a row, and setting a column to a null value that is configured as "not null"

but really you are trying to delete a row that does not exist! You can verify this:
in your db run the following queries:


so, now you have deleted the record of the row from your IWDELTRACKER that does not really exist in your database. re-run the deployment and it should not fail this time

Sunday, April 27, 2008

check if a website is responding script

recently i needed to check if a website was responding, and if not, page myself (by sending an email to my pager). Here is the unix shell script i used to make this happen.

Required programs:
wget
working mail (i use xmail on solaris 8 in this script)

script:

#!/bin/sh
## Script will check if the "host" is up, if the host is down, send an email
## You should cron it every 5 mins or so.

#uncomment to debug:
#set -x

## change these:
host="http://dogself.com"
email="my-pager-number@skytel.com,my-real-email@gmail.com"

## locations of stuff:
mailx="/usr/bin/mailx"
wget="/usr/bin/wget"
log="/path/to/a/writable/log/file.log"

now=`date '+%m/%d/%Y %H:%M:%S'`
rm ${log}
#when checking connection, do 2 tries, and time out in 7 seconds
${wget} -O /dev/null -t 2 -T 7 ${host} -o ${log}
grep "saved \[" ${log}
if [ $? = "1" ];
then
echo "site:[${host}] is down"
${mailx} -s "PRODUCTION is DOWN at ${now}" ${email} < ${log}
else
echo "site:[${host}] is up"
fi

appfuse 1.8.1 ehcache NoSuchMethodError

Problem:
I installed appfuse-light-all 1.8.1, installed acegi security, and ajax. After doing a build i get the following error when Spring starts up:

Error creating bean with name 'userManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]
.... bunch of other errors ...
Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: net.sf.ehcache.Cache.<init>

Solution:
The problem here is that i am using an older version of ehcache for some reason. Doing a bit more digging shows that i have the following versions of ehcache in my M2 repository:
[M2_REPO]/net/sf/ehcache/ehcache/1.2.3/
[M2_REPO]/net/sf/ehcache/ehcache/1.3.0/

version 1.2.3 is what is messing things up for me, it gets loaded by Spring first and causes the error. Deleting that directory does not work because "ant deploy" does the following if the dependency is missing:

Buildfile: build.xml
[artifact:dependencies] Downloading: net/sf/ehcache/ehcache/1.2.3/ehcache-1.2.3.jar
[artifact:dependencies] Downloading: net/sf/ehcache/ehcache/1.2.3/ehcache-1.2.3.jar

Now, since i dont know how to use MAVEN, i cant remove the code that fetches the old version, so i do the evil hack to prevent it from being created:

remove the directory "1.2.3", make a copy of "1.3.0" directory, call it "1.2.3". rename all the files inside to say 1.3.0 instead of 1.2.3.

Also, if you are deploying to tomcat as a directory, you might need to go into the webapps directory in tomcat, locate your app, and its WEB-INF and delete ehcache-1.2.3.jar thats is probably there now.

Now you can use appfuse.

if anyone knows of a better way to solve this, leave a comment.

Friday, April 25, 2008

firefox: tab and enter do not work

I have been effected by the evil firefox bug which causes tab and enter to stop working. As of this writing there is no fix for this.

Here is what i have found out about living with this bug and other info:

Workarounds:
1. shift-enter works instead of enter. No replacement for tab exists.
2. opening a new windows or restarting firefox fixes this problem for a while
- people suggested using session fix addon to remember your tabs while you restart firefox

other info:
1. people claim its a firebug issue or a web developer issue. i have both of those installed, by the way
2. there is a firefox bug report on this here
3. some posts on message boards which might eventually find a fix for this problem are:
http://www.nabble.com/Enter-and-Tab-keys-stop-working-td14302706i20.html
http://support.mozilla.com/tiki-view_forum_thread.php?comments_parentId=38626&forumId=1


at this point the best solution seems to use that session fix plugin, or maybe do a reinstall.

shell scripting with /bin/sh

I found this half decent tutorial / how-to on shell scripting with /bin/sh which i do lots but suck at.

here it is:
http://ooblick.com/text/sh/

also, to check if a file DOES NOT exist:

if [ ! -e /path/to/file ];
then
# do something
fi

ok i am done!

Tuesday, April 15, 2008

common regex cookbook

I see nice regexes on the java forums from time to time, i am going to add them all here for use!

Thursday, April 10, 2008

Escape cp-1252 chars in HTML

This is for when people paste crap from MS Word into html and add all those funky characters that looks horrible.

My friend gave me this perl one liner (ok, you can use it as a one liner if you wanted to) to escape the the evil CP-1252 characters in your HTML.

Notes for porting:
ord($1) converts capture group 1 to ASCII.
assumes $str has your html

Bonus!
the above regex replaces control chars!

Wednesday, April 09, 2008

Teamsite DCR java parser


Working with teamsite DCRs is painful. This is my attempt to make it a little bit less painful.

I made this program in order to make it easier to edit and parse teamsite data capture records. I should have done this a long time ago, and actually this is the first step towards freeing myself from OpenDeploy.

Anyway, here is the code for the parser:



Note: The code above does not yet truly support replicants, as in, you cant say 'give me the 3rd text field from the 2nd replicant..' unless you can figure out the xpath for it, which somewhat defeats the purpose of having a DCR parser.


Here is a driver class that uses my parser in order to do something silly.



in order to use this parser you will need the following libs:
- JDOM
- JAXEN