Search This Blog


Check out these Pages


javascript select opt group from son sample

As shown in and

<div id="somewhere"></div>

var json = [{"Foo":[{"id":1,"name":"aaa"},{"id":2,"name":"bbb"}]},{"Bar":[{"id":3,"name":"ccc"},{"id":4,"name":"ddd"}]}];

var $select = $("<select>");
$.each(json, function(i, optgroups) {


    $.each(optgroups, function(groupName, options) {
        var $optgroup = $("<optgroup>", {label: groupName});

        $.each(options, function(j, option) {
            var $option = $("<option>", {text:, value:});

Solved : ERROR: type "geometry" does not exist

ERROR:  type "geometry" does not exist 

I fixed this error by running following code in SQL editor of your selected database in pgAdmin.


Comments are welcomed!. Cheers!! ;)

svn working copy locked.

Just to remember if your svn working copy locked, do the following steps to resolve.

1. Open your project
2. Right click on the project
3. Choose Subversion -> Working Copy -> Cleanup.

Problem solved.
These steps work on NetBean IDE.

Create custom sequence for PostgreSQL Primary Key with auto-increment.

You can use standard sequence and formatting functions to customise the value.
to_char(nextval('test_seq'), 'TS0000000FM') 
FM : prefix fill mode (suppress padding blanks and trailing zeroes)

CREATE TABLE test_table
 s_no CHAR(8) NOT NULL DEFAULT to_char(nextval('test_seq'), 'TS0000000FM'),
 txt TEXT
ALTER SEQUENCE test_seq OWNED BY test_table.s_no; 

You can read more on this example and about postgresql formatting functions in following links.

sources :

Display name of the month from the current date using javascript

This code is to display name of the month from the current date.
<p id="demo"></p>
function myFunction() {
    var month = new Array();
    month[0] = "January";
    month[1] = "February";
    month[2] = "March";
    month[3] = "April";
    month[4] = "May";
    month[5] = "June";
    month[6] = "July";
    month[7] = "August";
    month[8] = "September";
    month[9] = "October";
    month[10] = "November";
    month[11] = "December";
    var d = new Date();
    var n = month[d.getMonth()];
    document.getElementById("demo").innerHTML = n;
source :
  pic screenshot from :

JQuery 12/24 hours Clock

<span id="clock"></span>

function updateClock() {
    var currentTime = new Date();
    var currentHoursAP = currentTime.getHours();
    var currentHours = currentTime.getHours();
    var currentMinutes = currentTime.getMinutes();
    var currentSeconds = currentTime.getSeconds();
    // Pad the minutes and seconds with leading zeros, if required
    currentMinutes = (currentMinutes < 10 ? "0" : "") + currentMinutes;
    currentSeconds = (currentSeconds < 10 ? "0" : "") + currentSeconds;
    // Choose either "AM" or "PM" as appropriate
    var timeOfDay = (currentHours < 12) ? "AM" : "PM";
    // Convert the hours component to 12-hour format if needed
    currentHoursAP = (currentHours > 12) ? currentHours - 12 : currentHours;
    // Convert an hours component of "0" to "12"
    currentHoursAP = (currentHoursAP == 0) ? 12 : currentHoursAP;
    // Compose the string for display
    var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + " / " + currentHoursAP + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;
$(document).ready(function () {
    setInterval(updateClock, 1000);

source :

Committing PostgreSQL Transaction with PHP.

Committing PostgreSQL Transaction with PHP.

$constring = "host=localhost port=5432 dbname=yourdb user=youruser password=yourpassword"; 

$pglink = pg_connect($constring) or die('Could not connect');

pg_query("BEGIN") or die("Could not start transaction\n");

$user = pg_query("insert into users values(1, 'JJ')");
$staff = pg_query("insert into staffs values(1, 'JJ','Staff')"); 

if($user and staff){
       //Committing transaction
       pg_query("COMMIT") or die("Transaction commit failed\n"); 
      //Rolling transaction
       pg_query("ROLLBACK") or die("Transaction rollback failed\n"); 


The purpose of my posts is to keep the note of my works and, at the same time helping others. I hope this post will help someone.  Anything?? Please leave a comment. Good Luck!! ;)

How to reset your mac OSX user account if you are locked out.

How I Reset my MacOSX
1. Shutdown your computer if it is on.
2. Start your computer and immediately press and hold Command + S to enter Single-user mode
3. When the terminal is opened. Enter these command one at a time and press Enter after each command:

mount -uw /
rm /var/db/.AppleSetupDone

Above commands will do the following things:

- Mount the internal hard drive with write permission
- Remove the Mac setup file. This is the file that OSX checks to determine if the system is ready to setup.
- Reboot the Mac.
After rebooting, you will see the setup screen of your Mac. Go through it and, once you get into your mac, Go to System Preferences > Users & Groups:

There, you will see your user account, open it and change your password (don't forget to change your keyboard back to English),
then you can restart your computer and you can get back into your account and continue your work.....

hope this helps someone else...