Tuesday, September 21, 2010
Finding your way around JSON
Today if you are doing web development and if you don't know what is ajax and what is JSON probably you are not what you say you are...... I always use a tool pretty print JSON which is very handy when I want to compare the objects.. it's http://jsbeautifier.org/ . You can use a diff or meld to compare files pretty printed by this..........
Tuesday, November 24, 2009
Using GNU C __attribute__
Just realized how wonderful is this little feature.. more on this is available from http://unixwiz.net/techtips/gnu-c-attributes.html
Wednesday, September 3, 2008
Triggers wont work with jdbc queries
I wanted to execute trigger creation through ant scripts so that whole installation process will be automated. But unfortunately trigger creation script kept failing. After some googling I figured out that problem is in the command DELIMITER |. This command is one of commands available in mysql client and is not included in sql specification. Mysql default delimiter ; is used in trigger which is unfortunately mis guiding clients like jdbc query to stop at wrong delimiters, thus creating errors.
For the moment it seems like I have to invoke triggers using command line. Anyway if I found out a solution I will let you all know.
For the moment it seems like I have to invoke triggers using command line. Anyway if I found out a solution I will let you all know.
Tuesday, September 2, 2008
My first trigger...
I've been occupied with lot of work and could not find the time to sit and write some posts...
But this was sooo interesting and couldn't keep from coming here and posting it for ur knowledge...
This is the first trigger I have written.. It's something that is used to update a tables called values_table and template_table. I have changed some of the names of the table since it's from my cmpny project ;)
DELIMITER |
CREATE TRIGGER xxtriggername AFTER INSERT ON channel
FOR EACH
ROW BEGIN
INSERT INTO values_table
VALUES
(NULL , NEW.channel_id, 1, 1, 0.0),
(NULL , NEW.channel_id, 1, 2, 0.0),
(NULL , NEW.channel_id, 1, 3, 0.0),
(NULL , NEW.channel_id, 1, 4, 0.0),
(NULL , NEW.channel_id, 1, 5, 0.0),
(NULL , NEW.channel_id, 1, 6, 0.0),
(NULL , NEW.channel_id, 1, 7, 0.0),
(NULL , NEW.channel_id, 1, 8, 0.0),
(NULL , NEW.channel_id, 1, 9, 0.0),
(NULL , NEW.channel_id, 1, 10, 0.0),
(NULL , NEW.channel_id, 1, 11, 0.0),
(NULL , NEW.channel_id, 1, 12, 0.0),
(NULL , NEW.channel_id, 1, 13, 0.0),
(NULL , NEW.channel_id, 1, 14, 0.0),
(NULL , NEW.channel_id, 1, 15, 0.0),
(NULL , NEW.channel_id, 1, 16, 0.0),
(NULL , NEW.channel_id, 1, 17, 0.0),
(NULL , NEW.channel_id, 1, 18, 0.0),
(NULL , NEW.channel_id, 1, 19, 0.0),
(NULL , NEW.channel_id, 1, 20, 0.0),
(NULL , NEW.channel_id, 1, 21, 0.0),
(NULL , NEW.channel_id, 1, 22, 0.0),
(NULL , NEW.channel_id, 1, 23, 0.0),
(NULL , NEW.channel_id, 1, 24, 0.0);
INSERT INTO template_table VALUES (1,'Default template',NEW.channel_id);
END;
|
DELIMITER ;
Btw these links should help you get started if you are also new to triggers...
http://dev.mysql.com/doc/refman/5.0/en/create-trigger.html
http://www.digitalpropulsion.org/Programming/Triggers_in_MySQL_5_0
But this was sooo interesting and couldn't keep from coming here and posting it for ur knowledge...
This is the first trigger I have written.. It's something that is used to update a tables called values_table and template_table. I have changed some of the names of the table since it's from my cmpny project ;)
DELIMITER |
CREATE TRIGGER xxtriggername AFTER INSERT ON channel
FOR EACH
ROW BEGIN
INSERT INTO values_table
VALUES
(NULL , NEW.channel_id, 1, 1, 0.0),
(NULL , NEW.channel_id, 1, 2, 0.0),
(NULL , NEW.channel_id, 1, 3, 0.0),
(NULL , NEW.channel_id, 1, 4, 0.0),
(NULL , NEW.channel_id, 1, 5, 0.0),
(NULL , NEW.channel_id, 1, 6, 0.0),
(NULL , NEW.channel_id, 1, 7, 0.0),
(NULL , NEW.channel_id, 1, 8, 0.0),
(NULL , NEW.channel_id, 1, 9, 0.0),
(NULL , NEW.channel_id, 1, 10, 0.0),
(NULL , NEW.channel_id, 1, 11, 0.0),
(NULL , NEW.channel_id, 1, 12, 0.0),
(NULL , NEW.channel_id, 1, 13, 0.0),
(NULL , NEW.channel_id, 1, 14, 0.0),
(NULL , NEW.channel_id, 1, 15, 0.0),
(NULL , NEW.channel_id, 1, 16, 0.0),
(NULL , NEW.channel_id, 1, 17, 0.0),
(NULL , NEW.channel_id, 1, 18, 0.0),
(NULL , NEW.channel_id, 1, 19, 0.0),
(NULL , NEW.channel_id, 1, 20, 0.0),
(NULL , NEW.channel_id, 1, 21, 0.0),
(NULL , NEW.channel_id, 1, 22, 0.0),
(NULL , NEW.channel_id, 1, 23, 0.0),
(NULL , NEW.channel_id, 1, 24, 0.0);
INSERT INTO template_table VALUES (1,'Default template',NEW.channel_id);
END;
|
DELIMITER ;
Btw these links should help you get started if you are also new to triggers...
http://dev.mysql.com/doc/refman/5.0/en/create-trigger.html
http://www.digitalpropulsion.org/Programming/Triggers_in_MySQL_5_0
Saturday, August 2, 2008
Positioning div tables in center
Sometimes tables gives pain in the neck compared to divs. I needed to replace a table made with rounded corners using images to be replaced by a div tag because dojo Tree widget start going woo hoo with the table. Thus I created a table with rounded corners which got rid of problems with tree widget. But initially I couldn't center the table as there were no css attribute to center the div element. If you know the width of the div you are messing with there is a way to do this using css without the use of javascript!
So if you come across a situation to center the table horizontally here is the style to do it
So if you come across a situation to center the table horizontally here is the style to do it
#centered{
position: relative;
left: 50%;
width:600px;
margin-left:-300px;
}
Wednesday, July 23, 2008
Customizing dojo DateTextBox
Sometimes things aint that easy when you really want to get something done in your way. I too felt like that when I wanted dijit.form.DateTextBox to display date in format dd-mm-yyyy. Many talked about using right locale. But I was not concerned about any locales but the format I wanted to get. So here is how you do it in dojo.
<input id="date"
value="2008-12-01"
dojoType="dijit.form.DateTextBox"
constraints="{datePattern:'dd-MM-yyyy'}"
invalidMessage="Invalid date dd-mm-yyyy"
promptMessage="dd-mm-yyyy"
/>
Tuesday, June 24, 2008
Understanding JSON
Some pple get scared when they see strange words like JSON. But if you take a closer look they are nothing ;). So here is a basic guide for JSON. JSON stands for JavaScript Object Notation. Also remember there is no "A" in between J and S ;P.
Here is a simple JSON object
There is another way to write this
Both are same. Then how do we use JSON in javascript? Answer is pretty simple... here it is..
Done! That is it. Wait a sec how about if a person have many interests.. that needed to be represented in an array.. ok! here we go
who la! We are done! So this should be a good foundation for you to start! Next time when your fellow developer or interview board ask for a JSON don't freak out! Just hit them back with a good example! cheers!!!
Here is a simple JSON object
{name:'Dilan'}
There is another way to write this
{'name':'Dilan'}
Both are same. Then how do we use JSON in javascript? Answer is pretty simple... here it is..
var person={'name':'Dilan'};
alert(person.name);
Done! That is it. Wait a sec how about if a person have many interests.. that needed to be represented in an array.. ok! here we go
var person = {'name':'Dilan', 'interests':['watch movies','play crickets','code']}
who la! We are done! So this should be a good foundation for you to start! Next time when your fellow developer or interview board ask for a JSON don't freak out! Just hit them back with a good example! cheers!!!
Subscribe to:
Posts (Atom)