Thursday, May 5, 2016

MongoDB cheat sheet

To run mongodb do
>mongod
This will start the deamon.

Then to query the DB start the client by
>mongo
 To use a DB do
use

To see the databases do
show databases

You can see the collections in a database after opening that database by
show collections

Collections correspond to Tables in mysql.

db.collection.find({key:value})

can be used to query the DB. If you want to perform "like" queries do
db.collection.find({"my key": /term/})

Do not use quotes around term in the previous example to perform like queries. If you do, then it will be an exact match.

This will not work within pymongo and you need to use $regex directive for this.
db["mycollection"].find({"key":{"$regex":"%s" % query}})

You can use count do count the number of matching records.
db.collection.count({key:value})



Friday, March 4, 2016

Bibdesk annotations in TeX preview

If you would like to display the annotations you do in bibdesk in the TeX preview then you can do so as follows.

The annotations you make are kept in a bibtex field called "Annote".

We need a bibtex style file (bst) that supports this annote field.
You can copy paste the plainannotate.bst file at the end of this post.

Next, create the following directory
~/Library/texmf/bibtex/bst
and put the style file there.

Now from Bibdesk set the preferences as follows


That is it



Continuously monitor GPU usage

 For nvidia GPUs do the follwing: nvidia-smi -l 1