Friday, December 26, 2008

LG VX8300 USB driver download

LG VX8300 usb drivers are hard to find on the internets for some reason...

download them here: LGUSBModemDriver_4.6_WHQL.zip

also, the unofficial user guide is a good thing to have

edit: wow this post is popular, please click on my ads to help me pay for the bandwidth that hosting these files for you is costing me. Thanks.

edit: fixed links

Wednesday, December 17, 2008

jQuery: responsiveness plugin for fast UI

for demo go here

Problem:
I was working on a dropdown widget where the user could scroll down using the arrow keys, and while he was scrolling, two things needed to happen:
  1. UI need to be updated, showing his new selection, and removing his old selection.
  2. Some costly DOM operations had to happen in the background to set the selected item in the widget.
I noticed that the scrolling was slow in IE6 on a P3-1000. Mind you, scrolling 1 item was fast, but holding down the arrow key and scrolling 50 items was painfully slow, because the DOM operations had to happen for every item scrolled.
I also knew that i only really needed to do the DOM operations for the last item selected, that is the one the user really wanted.


Solution:
Javascript is single threaded, but there is a timer function that makes faking multi-threaded execution possible.
What i needed to do was to split up the scroll function into two components, first call the UI update every time the arrow was pressed, and second, queue up the expensive DOM operations to happen in the future, but dont execute them until no new DOM operations have been queued for some interval of time. This would give the user the visual feedback of "something is happening" while not executing the costly operation that would make everything feel slow and unresponsive.

The plugin i came up with lets you specify the interval that you will wait for further requests until you execute the last request, and the number of times you will wait that interval.


One thing to be aware of is that this plugin does not implement any queing internally, so if you should only use one instance of it per function. make a new instance if you want to improve the performance of a different function.

For more info such as:
  • A simple typing demo
  • A crappy implementation of hoverIntent plugin
  • API
go here

Friday, December 12, 2008

jQuery: Conflict free events

Problem:
I had to validate an input, both onBlur and when the user pressed enter. If there was an error, in both cases, an alert would pop up. The problem was that when the user clicked 'ok' on the alert, the field would lose focus and cause the blur event to fire, and thus cause another alert to pop up. I only wanted one alert per error, so i made this little plugin to solve this problem.

Solution:
To use this plugin, you can pass in a hash with 2 keys: {blur: function(){}, enter: function(){}}, or a single function that you want run both onBlur and onEnter.



Example usage:

Saturday, November 15, 2008

How to make a pie crust from scratch


Making a pie crust is harder than programming, i have decided. It is one of the hardest things a man can undertake. Anyway, i am a pie crust making beginner. I just made a great pie crust and i need to remember how to do it.

You will need:
a food processor with a metal blade
1 1/4 cups white flour
2 teaspoons sugar
1/8 teaspoon salt
1 stick (1/2 cup) of cold butter, diced
1 egg, beaten to a pulp
1 table spoon of water

First, the butter needs to be pretty cold, think, freezer cold. The colder, the better.

  • combine flour, surgar and salt in the food processor and turn it on, let it do its thing while you do the next step
  • dice your stick of butter, and put it in the food processor, leave it on until the mixture looks like corn meal, make sure that all butter gets mixed in well.
  • beat the egg and add that into the food processor. at this point the dough should start forming into a ball.
  • add 1 table spoon of water and let it get mixed in.
  • remove the dough from the food processor, and form it into a ball. refrigerate the ball for about 15 mins
  • get some clear plastic wrap, lay it on your counter. put the ball on the wrap and start forming into a circle, about 1/8 inch thick. (it has to be bigger then your pie pan by about 1 inch)
  • after you make the circle, cover it with some wrap, and put it on a pizza pan, and freeze it for 5 mins
  • take dough out of the freezer, it should be hard, and easily broken. DO NOT BREAK IT. put it on top of your pie pan and remove the plastic wrap from under it. let it rest there for 3-4 minutes to warm up
  • when dough warms up it will be more pliable. form the dough into the pie pan. if it breaks, uses peices to patch up cracks. you might have extra dough on the sides. use food scissors to cut off excess. you can make something cool with the extra on top of the pie.
  • freeze the dough in the pie pan for 5 minutes, covered.
  • put a piece of foil in the pie plate, and form it around the dough, add pie weights (i dont have these, so i use a pan top)
  • bake at 400 deg for 20 minutes
  • remove foil and bake at 350 deg for 5 minutes or until crust is golden.

Wednesday, November 12, 2008

How to debug UI display issues

i spent far too much time tracking down stupid UI issues in IE. This is an attempt to write down some techniques that yielded results.

  • If the issue is on a screen with a javascript UI widget:
    • Does the issue occur oh pages without the widget? no:
    • Does returning early from the widget rendering function fix it? yes:
    • Move the return statement down the render function, until the UI breaks.

Tuesday, October 14, 2008

Use Selenium RC in Firefox 3

How to use Selenium RC in Firefox 3

For a while now i have been told that selenium RC does not work in firefox 3. This is a huge bummer for anyone who wants to run functional tests and has to downgrade to firefox 2.

Edit 1/12/2009:
A new version (1.0 beta 2) of selenium RC was released today that fixes this issue once and for all!
get it here. You shouldnt need to do this hack now, unless you want to use the old non-beta version. If you do need to use the old version of selenium, here is how to get it to run firefox 3:

Edit 2/8/2009:
Today i was told that there is a firefox extension that allows you to turn of extension version checking. Also, you can do it by editing about:config.

Today i found a workaround to this problem, which works, and is really simple.

Here is what you need to do:
1. Open selenium-server.jar using winrar
2. locate 2 dirs: customProfileDirCUSTFFCHROME and customProfileDirCUSTFF
3. recursively explore each of those dirs, and when you find a file called install.rdf drag it to some temp location, and edit the following line:
<em:maxVersion>2.0.0.*</em:maxVersion>
change it to:
<em:maxVersion>4.0.0.*</em:maxVersion>
4. drag the install.rdf back into the archive and overwrite the old one.
5. do this for all the install.rdf files in those 2 dirs.


you can now use "*firefox" in selenium RC. "*chrome" was giving me problems though, complaining about a malformed rdf file, i might have made a mistake in one of them. Either way, i use *firefox, so it does not matter to me.

if you want, you can get my modified selenium jar here - modified to run in firefox3.
the version of selenium that this jar contains are:
selenium.core.version=0.8.3
selenium.rc.version=0.9.2
selenium.rc.revision=2006
selenium.core.revision=1879

also, there is a 1.0-beta1 compatible modified jar here

Edit 12/10/2008:
Some people have been asking for help with selenium errors in the comments. I cannot help you with those, they are probably specific to what you are doing. If you have question about selenium RC errors, you should try asking them on the Selenium RC User Forums.

Monday, October 13, 2008

IE beeps on enter in an input

Problem:
I have an input box where the onKeyDown event will check if the key pressed was enter, and submit the form on enter. This works fine, but in IE 7 the browser beeps when you press enter, and submits the form.

Solution:
This happens because 'enter' is not valid within the context of an input box, according to IE. Thus, pressing it will cause the beep. What you need to do to remove the beep, is to return false from the function which does the submit. It looks something like this:

<input onkeydown="return postOnEnter(event)"/>



obviously, i am calling some custom functions in the snippet above, but the location of the return statements, and their values is all that matters.

Wednesday, October 01, 2008

jQuery: constrain input chars plugin

Problem:
you need to only allow the user to input certain characters into the input box, and you want a jquery plugin to do it!

Solution:




the following lets you specify which chars (regexes or'ed together) are allowed in the input.

i added a small demo for the plugin, check it out here

get the plugin here

Saturday, September 13, 2008

beer mushroom chicken with potatos

another thing i made up, and it was good.

you will need:
  • 2 chicken breasts
  • 1/2 cup dried mushrooms
  • 1/2 package of mushrooms
  • 4 large potatos
  • sam adams seasonal beer, 2 bottles
  • 2 cloves of garlic
  • 1 medium onion
  1. slice the potatos into round thin slices, and boil them in some water until soft-ish
  2. put the dried mushrooms into a food processor and chop into small peices
  3. meat hammer the chicken breasts to flatten and dredge the chicken breasts in the mushroom powder
  4. slice the non-dried mushrooms
  5. put some olive oil into a pan with the chopped up garlic and cook until garlic gives off some flavor
  6. dice the onions and add that to the pan, cook until translucent
  7. add the mushrooms and let cook for about 3 mins
  8. turn the heat to high and add the chicken letting it brown on the outside
  9. add the potatos which are now softish to the pan and cook with the chicken and the mushrooms, turn the heat down to low, cover the pan while the stuff cooks.
  10. when the stuff starts looking pretty cooked, add the beer, but not all of it right away, do it in stages. When the beer evaporates your stuff should be cooked
  11. drink the 2nd bottle of beer while you cook.
make sure the chicken is cooked through. serve with more beer. yum.

Thursday, September 11, 2008

find table contstraint in oracle database

problem:
free toad does not provide a constraint view.

solution:
select * from user_constraints where constraint_name = 'THE_CONSTRAINT_NAME';

TABLE_NAME is the name of the table that has the constraint, and probably is the table you need to delete stuff from to clear the constraint

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

Thursday, March 13, 2008

email regex that doesnt suck

why is it so hard to find a good email java regex on google? They all suck.

Here are a few regexes that i would use in a production system to check if an email is valid:

"([\\w-]+(?:\\.[\\w-]+)*@(?:[\\w-]+\\.)+\\w{2,7})\\b"


Something a little more light weight:

"[^\\s]+@[^\\s]+([.]\\w{2,3})+"


and if all else fails, this might be useful:
Apache Commons EmailValidator class API

Friday, March 07, 2008

Path does not start with a "/" character

Problem:
I get this error when using the tiles plugin when building out some tiles:

java.lang.IllegalArgumentException: Path .some.tiles.path does not start with a "/" character

first, lets pretend that the tile in question looks like this:
<definition name=".some.tiles.path" extends=".some.other.tiles.path"> ..some stuff.. </definition>

Solution:
ive noticed that the reason for this error can be one of the following:

1. if you look at the tile that this tile extends, and what that tile extends, until you find the tile that extends nothing, that tile should have a definition like this:
<definition name=".some.base.tile" path="/a/real/path/to/some/jsp/somejsp.jsp"> ..some stuff.. </definition>
the key thing, is that the path of the parent tile starts with a "/" character

2. if #1 is not your problem, then you might have a duplicate definition of the tile name which the error talks about.

3. Another thing that can happen is that your tiles path that you are referencing in struts-config.xml does not exist at all, because maybe you misspelled it, in which case that same error is thrown.

Friday, February 22, 2008

B. Fleischmann - Gain Lyrics

I have looked everywhere for the lyrics of the song "Gain" by B. Fleischmann which is found here on you tube by the way. They dont seem to exist on teh intarwebs.

Anyway, i have transcribed them as best as i can, if anyone thinks i got something wrong, please leave a comment.


B. Fleischmann - Gain Lyrics

lets face another day
lets see another fence
lets have another crash
lets get another chance

where all reason ends, i put my heart
where foresight ends, i want to start
as long as i haven't tried to gain
i will not stop, will not complain

lets give it one more try
don't want to make you cry
how else can we survive
unless we dry our eyes try our lives

where all reason ends, i put my heart
where foresight ends, i want to start
as long as i haven't tried to gain
i will not stop, will not complain

Thursday, February 21, 2008

JSP syntax: empty checks, params, misc

This stuff is so elementary that i am always annoyed to forget it every time i dont use jsp for a few months.

1. Get params from the url request, ie http://dogself.com?param1=test&something=poop
<c:out value="param1 is: ${param.param1} something is:${param.something}"/>

also there is ${params} for getting lists, but i would need to read up on that

2. checking if a request attribute is null or empty:
<c:if test="${param.page != null && not empty param.page}">
<c:import url="${base_html_dir}${param.page}"></c:import>
</c:if>


3. setting variables:
<c:set var="thingToSet" value="${1+ 3}">
this by default has the scope of 'page', also can be 'session' defined by attribute 'scope'

ill add more as i go

Wednesday, February 13, 2008

Document base /path/to/ROOT does not exist or is not a readable directory

I recently installed tomcat 5.5 on my slicehost, and it was somewhat painful, probably because i deviated from the basic setup so much.
Anyway, one last error (in /var/log/tomcat5.5/catalina.out) that i was getting was this:

SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base /home/mk/public_html/ROOT does not exist or is not a readable directory

I was setting up my app context path using CATALINA_HOME/conf/Catalina/localhost/ROOT.xml and so it was strange that tomcat was looking for a directory called ROOT.

Solution:

I was overlooking this warning before the error:
WARNING: A docBase /home/mk/public_html/dogself.com inside the host appBase has been specified, and will be ignored

the problem was that i set my appBase inside of /etc/tomcat5.5/conf/server.xml to be /home/mk/public_html/ and this was a parent directory of app's docBase.

Changing the appBase to /home/mk/public_html/webapps solved this problem.

Wednesday, February 06, 2008

Music for february

this place has lots of rock from back when i used to listen to rock:
http://saintsmythe.illemonati.com/tsx/

Recently i've been interested in a progressive metal band called "Sonata Arctica", this place as a decent selection of them:

http://www.rockandroll-server.com.ar/GOD/mp3/Sonata/


a ton of DnB:
http://www.riotnerd.com/nmp3s/

thats all until i find more betterer stuff

Thursday, January 31, 2008

find duplicate files on your machine

ive had need for this before. A program to find duplicate files on your computer. i have been told by a very reliable source that this is good:

http://www.beautylabs.net/software/dupseek.html

so i am going to write it down so that next time i need this, i will have it

dupes are evil

Thursday, January 24, 2008

Java: reading / writing international characters

It is actually very easy to support international characters in java. The only trick is knowing the charset that the text is encoded in. Most of the time is a safe bet to try UTF-8 if you dont know. If you use Apache's HTTPClient it has methods to get the charset of the stream you are reading from.


Tuesday, January 22, 2008

Music for January

this place has lots of kraftwerk and other interesting stuff:

http://elf.art.pl/

this place has a BUNCH of music, lots of normal music with weird Japanese bands i've never heard of:

http://side7.homeunix.net/s/mp3/

Unix: Compress or delete files older then X days

Problem:
I have some logs in some directories that i need to back up if the file is at least 12 days old, if the file is older then 24 days, i need to delete it

Solution:

to compress:
find <path within you're looking> -xdev -mtime +<number of days> -exec /usr/bin/compress {} \;

to delete:
find <path within you're looking> -xdev -mtime +<number of days> -exec /usr/bin/rm -f {} \;


Note: This was tested on Solaris 8

Examples:

find /usr/local/apache/logs/ -xdev -name "sar.*" -mtime +24 -exec /usr/bin/rm -f {} \;
find /usr/local/apache/logs/ -xdev -name "sar.*" -mtime +12 -exec /usr/bin/compress {} \;

Tuesday, January 15, 2008

Cooking: How to make sushi rice

Making perfect sushi rice is hard, it has to be cooked though, soft and sticky. Ive always had trouble doing it because i would end up burning the rice on the bottom of the pot (i dont have a rice cooker). My rice wouldnt be sticky enough to stick to the seaweed. My friend Sam always emphasized to me how important it was to make the rice "just right" when making sushi.

Enough, babble! i found a blog entry that makes cooking sushi rice easy! it actually came out great the first time i tried the oven method.

http://beyondsalmon.blogspot.com/2006/02/technique-of-week-how-to-make-sushi.html

Thursday, January 03, 2008

how to: use cron

ok, now that i really know how to use the cron i should blog it incase i forget

this assumes you have nothing in your cron / or your crontab is in sync with hostname.cron because you always use this method to modify the crontab.

0. run crontab -l to make sure your crontab is empty, if its not, paste what it has to the bottom of the file you make in step 1

1. make a file called hostname. cron and add this into the top of it for later:
#########################################
# #
# Cron file for [username] #
# #
#########################################
# min hour dom month dow usr cmd
# use '*' as skipped element

2. add your stuff to it, here is a better explanation on what to add:
01 * * * * echo "This command is run at one min past every hour"
17 8 * * * echo "This command is run daily at 8:17 am"
17 20 * * * echo "This command is run daily at 8:17 pm"
00 4 * * 0 echo "This command is run at 4 am every Sunday"
* 4 * * Sun echo "So is this"
42 4 1 * * echo "This command is run 4:42 am every 1st of the month"
01 * 19 07 * echo "This command is run hourly on the 19th of July"

3. save your file.

4. run this:
crontab < hostname.cron

done!

useful info happily stolen from here: http://www.unixgeeks.org/security/newbie/unix/cron-1.html

Wednesday, January 02, 2008

do you like guns, knives or real estate?


I recently made a website using adobe contribute and i need it to start being found on the internets:

http://TheTraditionalHunter.com <- go here if you want to see some 600$ pocket knives, or muzzle loading guns and other neat stuff. I have some high res pictures up that are pretty neat.

http://www.BayStateHomesForSale.com
<- go here if you are planning to buy/sell a house in MA or NH, they have a nice MLS search (thing that lets you look up houses for sale in the area).