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]

Yup this is my favorite book on Ajax. I love Head First books but this one far exceeded my expectations.
Head First Ajax
Let me tell you a little bit about myself. I am a Java programmer with little bit of experience in web technologies. Before reading this book I had used JavaScript libraries such as Script.aculo.us. So Ajax was not a totally brand new technology for me.

I bought this book because for upcoming project, I wanted a deeper understanding of Ajax. Also sometimes, while using Scriptaculous, debugging was not easy, because I didn’t know what was really going on behind the scenes.

After reading this book, I have better understanding of Ajax. This doesn’t mean I am Ajax expert now and ready to write my own library. I will stick with existing libraries. But I feel this book has given me enough basic concepts of Ajax (and also some general web design concepts) that I can use Ajax libraries without breaking anything unintentionally.

I don’t think I will read another book on Ajax unless I am doing some custom Ajax coding.

Here is Amazon Affiliate link (make me rich (: Head First Ajax

Reblog this post [with Zemanta]

In PHP4, constructor has same name as class:

class Welcome {
function Welcome() {

}}

In PHP5, constructor is always __construct():

class Welcome {
function __construct() {
}}

In PHP4, when you extend you call parent constructor like:

class Welcome extends Parent{

function Welcome() {
parent::Parent();
}}

In PHP 5, you extend like:

class Welcome extends Parent{

function __construct() {
parent::__construct();
}

I am using PHP5 but I was using PHP4 to extend my classes. Lovely!

These 2 posts made integrating Facebook Client with CodeIgniter piece of cake:

Now I am working on making Facebook Connect integrate with Facebook Client. This one should be easy (fingers-crossed).

My friend asked me how to create pages in Wordpress which are not shown in navigation menu. He basically wants a page which he can e-mail to friends but which is not visible to regular site visitors. The simplest solution I found was from Glen Scott.

Simplest solution is just add

wp_list_pages('exclude=1,2,3');

somewhere in the header.php. Where 1, 2 & 3 are the page numbers of hidden pages. For complete list of wp_list_pages parameters check: http://codex.wordpress.org/Template_Tags/wp_list_pages.

(Glen’s post has a few more options listed, I just wanted to add the simplest solution here.)

Just found out that PHP has totally different variable scope than Java. In PHP you have specify global keyword inside the function not outside. I am so used to Java type variable scope.

For more info read here