Tuesday, December 29, 2009
Thursday, October 22, 2009
PHP Regular expressions tool
Regular expressions can be a pain. This tool is designed to help developers learn, practice, and compose regular expressions.
http://gethifi.com/regexp/
http://gethifi.com/regexp/
http://gethifi.com/regexp/
http://gethifi.com/regexp/
http://gethifi.com/regexp/
http://gethifi.com/regexp/
Thursday, July 30, 2009
Mysql Timestamps
All that you want to know abouy MySQL timestamps is well documented here.
http://www.gizmola.com/blog/archives/93-Too-much-information-about-the-MySQL-TIMESTAMP.html
http://www.gizmola.com/blog/archives/93-Too-much-information-about-the-MySQL-TIMESTAMP.html
Wednesday, July 29, 2009
Twitter extensions
Twitter is on rage these days.
Twitters apps as firefox extensions just keeps on increasing
https://addons.mozilla.org/en-US/firefox/search?q=twitter&cat=all
Twitters apps as firefox extensions just keeps on increasing
https://addons.mozilla.org/en-US/firefox/search?q=twitter&cat=all
Friday, June 5, 2009
MySql GROUP_CONCAT() tip
Recently I found myself into a silly problem because of misunderstaning / confusion relating to data type of variable set in SELECT commmand using GROUP_CONCAT()
I wanted to get all integer ids as comma separated string to be used in other update query
my query:
SELECT GROUP_CONCAT(spm_ids) INTO @csvIds FROM someTable WHERE is_active = 1;
Whenever my select executed correctly it gave e.g. '2,5,6' as a string and when it failed it gave me '0' as a string.
before updating I checked
IF @csvIds <> 0 THEN
// perform some update on some other table
END IF;
I changed to below and my Stored procedure worked perfectly fine.
IF @csvIds <> '0' THEN
// perform some update on some other table
END IF;
Some of mysql String comparison
> select if('2' <> 0, 1, 0)
> 1
> select if('0,2' <> 0, 1, 0) //my problematic condition
> 0
> select if('0' <> 0, 1, 0)
> 0
> select if('2,5,6' <> 0, 1, 0)
> 1
MySql tip 2:
If you are writing too many Stored Procedures(SP) and also including below code in your SPs
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
SELECT 2 AS `error_code`, 'Fail to update ' AS `error_message` ;
END;
Then I would suggest that you first create your SP entirely run it many times under different conditions, if all working fine than include above code and test it again for failure.
This is because you will save some of your precious time by knowing exactly where the query failed.
I wanted to get all integer ids as comma separated string to be used in other update query
my query:
SELECT GROUP_CONCAT(spm_ids) INTO @csvIds FROM someTable WHERE is_active = 1;
Whenever my select executed correctly it gave e.g. '2,5,6' as a string and when it failed it gave me '0' as a string.
before updating I checked
IF @csvIds <> 0 THEN
// perform some update on some other table
END IF;
I changed to below and my Stored procedure worked perfectly fine.
IF @csvIds <> '0' THEN
// perform some update on some other table
END IF;
Some of mysql String comparison
> select if('2' <> 0, 1, 0)
> 1
> select if('0,2' <> 0, 1, 0) //my problematic condition
> 0
> select if('0' <> 0, 1, 0)
> 0
> select if('2,5,6' <> 0, 1, 0)
> 1
MySql tip 2:
If you are writing too many Stored Procedures(SP) and also including below code in your SPs
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
SELECT 2 AS `error_code`, 'Fail to update ' AS `error_message` ;
END;
Then I would suggest that you first create your SP entirely run it many times under different conditions, if all working fine than include above code and test it again for failure.
This is because you will save some of your precious time by knowing exactly where the query failed.
Wednesday, February 11, 2009
Python Type Conversions
Function | Description |
---|---|
int(x [,base]) | converts x to an integer |
long(x [,base]) | converts x to a long integer |
float(x) | converts x to a floating-point number |
complex(real [,imag]) | creates a complex number |
str(x) | converts x to a string representation |
repr(x) | converts x to an expression string |
eval(str) | evaluates str and returns an object |
tuple(s) | converts a sequence object to a tuple |
list(s) | converts a sequence object to a list |
chr(x) | converts an integer to a character |
unichr(x) | converts an integer to a Unicode character |
ord(c) | converts a character to its integer value |
hex(x) | converts an integer to a hexadecimal string |
oct(x) | converts an integer to an octal string |
Use:
totalRings = int(userInput)
//where totalRings and userInput are variables
Friday, February 6, 2009
Clone node issue in IE
Hi all,
I am writing after a long time.
If you are wondering why so long?
didnt I had anything worthwhile to type?
Yes, I didnt had anything to write, coz whatever I learnt in last few months its well documented all over internet.
Not to forget an important fact that during my free time last year i Played a lot with my Canon SLR-Like Camera.
You can check my photography @ Sinless Photography
But this Time again our big time sucker IE(Internet Explorer) showed his ugly face and delayed our work and entangled us in DOM herarchies.
IE Sucks it AGAIN.
cloneNode doesnt work for all elements in IE.
yes
cloneNode doesnt work for all elements in IE.
My Problem.
I wanted to upload an image form without submitting the original form (in page1).
What I wanted to do:
1. Created a hidden form outside original form.
2. Copy / Clone input (type = file) element from original form to hidden Form.
3. Submit hidden form via JavaScript and view output in a frame (in page1).
What I did:
1. var clonedFileObject = document.forms['originalForm'].fileElement.cloneNode(true);
( where fileElement is input type = file element)
2. document.hiddenForm.appendChild(clonedFileObject);
3. hiddenForm.submit();
And What Happened.
var clonedFileObject = document.forms['originalForm'].fileElement.cloneNode(true);
Above statement worked perfectly fine in Firefox but in IE nothing happened.
No cloning was done and on form submission / image upload button All I could see was empty $_FILES array with error code = 4.
What all I tried:
1. hiddenForm.fileElement.value = originalForm.fileElement.value // didnt in FF either
2. Created a outer div and copied innerHTML of first div to hiddenforms div // didnt worked for input type file (didnt wasted much time either...should have worked)
3. Finally I did a shabby Patch work in my code which i really hated but in the given time limit and set conditions this was only I could think of.
var OriginalFileObj = document.getElementById('fileElement');
//this will remove fileElement from Original Form
var clonedFileObj = OriginalFileObj;
document.hiddenForm.appendChild(OriginalFileObj);
document.hiddenForm.submit();
divObj.appendChild(OriginalFileObj); //restoring of original file object in original form
//if you dont do this there wont be any file object in original form
I am sure there would be other better ways to do the same.
If you are aware of it please add in comments so as others can benefit from you including me.
I am writing after a long time.
If you are wondering why so long?
didnt I had anything worthwhile to type?
Yes, I didnt had anything to write, coz whatever I learnt in last few months its well documented all over internet.
Not to forget an important fact that during my free time last year i Played a lot with my Canon SLR-Like Camera.
You can check my photography @ Sinless Photography
But this Time again our big time sucker IE(Internet Explorer) showed his ugly face and delayed our work and entangled us in DOM herarchies.
IE Sucks it AGAIN.
cloneNode doesnt work for all elements in IE.
yes
cloneNode doesnt work for all elements in IE.
My Problem.
I wanted to upload an image form without submitting the original form (in page1).
What I wanted to do:
1. Created a hidden form outside original form.
2. Copy / Clone input (type = file) element from original form to hidden Form.
3. Submit hidden form via JavaScript and view output in a frame (in page1).
What I did:
1. var clonedFileObject = document.forms['originalForm'].fileElement.cloneNode(true);
( where fileElement is input type = file element)
2. document.hiddenForm.appendChild(clonedFileObject);
3. hiddenForm.submit();
And What Happened.
var clonedFileObject = document.forms['originalForm'].fileElement.cloneNode(true);
Above statement worked perfectly fine in Firefox but in IE nothing happened.
No cloning was done and on form submission / image upload button All I could see was empty $_FILES array with error code = 4.
What all I tried:
1. hiddenForm.fileElement.value = originalForm.fileElement.value // didnt in FF either
2. Created a outer div and copied innerHTML of first div to hiddenforms div // didnt worked for input type file (didnt wasted much time either...should have worked)
3. Finally I did a shabby Patch work in my code which i really hated but in the given time limit and set conditions this was only I could think of.
var OriginalFileObj = document.getElementById('fileElement');
//this will remove fileElement from Original Form
var clonedFileObj = OriginalFileObj;
document.hiddenForm.appendChild(OriginalFileObj);
document.hiddenForm.submit();
divObj.appendChild(OriginalFileObj); //restoring of original file object in original form
//if you dont do this there wont be any file object in original form
I am sure there would be other better ways to do the same.
If you are aware of it please add in comments so as others can benefit from you including me.
Subscribe to:
Posts (Atom)