Showing posts with label development. Show all posts
Showing posts with label development. Show all posts

Friday, February 4, 2011

MongoDB Error

0 comments
If you happen to pass by this error

[02:33:05] mongodb$ mongo
MongoDB shell version: 1.6.3
connecting to: test
Sat Nov 13 02:33:10 Error: couldn't connect to server 127.0.0.1 (anon):1137
exception: connect failed


Check if your mongo is running by issuing "mongod" command. If you get something like this,

Sat Nov 13 02:30:41 MongoDB starting : pid=294 port=27017 dbpath=/data/db/ 64-bit
Sat Nov 13 02:30:41 db version v1.6.3, pdfile version 4.5
Sat Nov 13 02:30:41 git version: 278bd2ac2f2efbee556f32c13c1b6803224d1c01
Sat Nov 13 02:30:41 sys info: Darwin erh2.10gen.cc 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_40
Sat Nov 13 02:30:41 exception in initAndListen std::exception: dbpath (/data/db/) does not exist, terminating
Sat Nov 13 02:30:41 dbexit:

Sat Nov 13 02:30:41 shutdown: going to close listening sockets...
Sat Nov 13 02:30:41 shutdown: going to flush oplog...
Sat Nov 13 02:30:41 shutdown: going to close sockets...
Sat Nov 13 02:30:41 shutdown: waiting for fs preallocator...
Sat Nov 13 02:30:41 shutdown: closing all files...
Sat Nov 13 02:30:41 closeAllFiles() finished

Sat Nov 13 02:30:41 dbexit: really exiting now


You can see a lot of things to do here but you should probably check on your log file to see some errors while your mongo wouldn't start. When I tailed my logs, I saw a different error stated like so

**************
old lock file: /usr/local/mongodb/data/mongod.lock. probably means unclean shutdown
recommend removing file and running --repair
see: http://dochub.mongodb.org/core/repair for more information
**************


And yes I did came from a crash. So I checked and removed the file and it automatically ran again based on my existing tail on the logs and it was back again.

Hope this helps somebody else as well.

Monday, September 6, 2010

MongoDB start!

0 comments
I'll be playing around with MongoDB in the coming years and I think changing to this schema-less style works.

Installation


I've followed this link to install MongoDB on Snow Leopard. If you happen to get some errors here, make sure that all paths stated in the that document are created or else you'll get nasty errors. I was trying to mimic the errors I had before but I can't seem to get them again. Anyway, afterward, install the ruby driver to use here.

And now I'm looking at some mappers to use. I'm looking at MongoMapper or Candy or looking also at mongomatic while looking at tutorials and documents to play with mongoDB.

If you guys have any suggestions to help me out, please post on the comments.

Manipulating HTML checkbox using jQuery

0 comments
A small simple example or tutorial on how to manipulate HTML checkboxes with javascript with the help of jQuery (v1.4.2).

Here, I've given a sample on how to
  • select (check) checkboxes
  • deselect (uncheck) checkboxes
  • reverse select (check/uncheck)
  • do something with your selected checkboxes

Hope anyone finds it useful as I have.

Here is the HTML of the selectors and the group of checkbox. A textbox is written below as I will use it to sample what you have selected.
<div>
  <a id="select_all">Select all</a> | <a id="deselect_all">Deselect all</a> |
  <a id="reverse_select">Reverse</a> | <a id="submit_select">Submit</a>
</div>
<ul id="checkbox_container">
  <li>
    <input id="checkbox_1" type="checkbox" value="1" />
    <label for="checkbox_1">Checkbox 1</label>
  </li>
  <li>
    <input id="checkbox_2" type="checkbox" value="2" />
    <label for="checkbox_2">Checkbox 2</label>
  </li>
  <li>
    <input id="checkbox_3" type="checkbox" value="3" />
    <label for="checkbox_3">Checkbox 3</label>
  </li>
  <li>
    <input id="checkbox_4" type="checkbox" value="4" />
    <label for="checkbox_4">Checkbox 4</label>
  </li>
</ul>
<input id="write_to_me" type="text" />

Here is the Javascript (jQuery) to use.
$(document).ready(function() {
  $("#select_all").click(function() {
    $("#checkbox_container").find(':checkbox').attr('checked', 'checked');
  });

  $("#deselect_all").click(function() {
    $("#checkbox_container").find(':checkbox').removeAttr('checked');
  });

  $("#reverse_select").click(function() {
    $("#checkbox_container").find(':checkbox').each(function() {
      if (this.checked)
        $(this).removeAttr('checked');
      else
        $(this).attr('checked', 'checked');
    });
  });

  $("#submit_select").click(function() {
    checks = new Array();
    $("#checkbox_container").find(':checked').each(function() { checks.push($(this).val()); });
    $("#write_to_me").val(checks.join(','));
  });
});

Good luck!