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

I will forget about these tracks because i constantly listen to new stuff, but its good, and should be remembered.

Kylian - Lappi Inzoo (A1)
cEvin Key - Diagnosis
dntel - last songs

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

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!

Monday, April 14, 2008

Music for April

finally found some nice open directory:

http://www.artofassassin.com/Music/