Tagged: coding

Put

enctype="multipart/form-data"

in your form tag.

More info



If your modals are off, be sure to set width & height of container manaully:

$.modal({ containerCss { width:200, height:200 } });

Check here for more options: http://www.ericmmartin.com/projects/simplemodal/



Pulling changes from GIT repo without overwriting your changes, use stash command

In his case he needed to run:

git stash work

git pull

git apply work

via Git trick « Piku’s Blog.



Are you tired of checking data in your code before inserting? Well MySQL procedures are here to rescue.

This simple procedure shows how you can do that:

CREATE PROCEDURE `update_insert_user`( IN uid2 int  )
BEGIN
DECLARE last_login2 DATETIME;
SELECT `last_login` INTO last_login2 FROM `user` WHERE `uid` = uid2 LIMIT 1;
IF last_login2 IS NULL THEN
INSERT INTO `user` (`uid`,`last_login`) values (uid2, now());
ELSE
UPDATE `user` SET `last_login` = now() WHERE `uid` = uid2 LIMIT 1;
END IF;
END

You just call one line of SQL from your code, keeping your code cleaner and easier to debug.

I thought there was a function in Java which pads a string for you, so that string is certain length. I could not find the function but realized that there is a easier and simpler solution, a “while loop”.

e.g.

while ( string.length() < 8){

string = “0″ + string;

}

I am sure there is a better way to do this but if performance is not your concern then this is perfect.

Reblog this post [with Zemanta]