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



Tuesday, March 24, 2015

texshop 日本語入力

texshopで背景色を黒にしている場合,日本語入力がまだ未確定の場合,入力している文字が見えなくなるという問題がある.これは良くするためには次のコマンドを使えば良い.

defaults write TeXShop ResetSourceTextColorEachTime YES

しかし,これでバグがでることもあるようなので注意.

参照:
http://pages.uoregon.edu/koch/texshop/version.html

Tuesday, January 6, 2015

Monday, January 5, 2015

Python tricks and tips

If you want to assign incremental ids to a list of words then you can define a defultdict as follows:

wpids = defaultdict(lambda: len(wpids))

Thursday, December 11, 2014

boost-python

Here is a minimum working example of boos-python from the official web site.

First create a hello.cpp file and put this.

#include YOU HAVE TO INCLUDE boost/python.hpp within tag markers.

char const* greet()
{
   return "hello, world";
}


BOOST_PYTHON_MODULE(hello)
{
    using namespace boost::python;
    def("greet", greet);
}

Now compline .so file by doing the following.

g++ -g -shared -fPIC -I/usr/include/python2.7 hello.cpp -lpython2.7 -lboost_python -o hello.so

Open IPython and import hello
now call hello.greet()


Monday, September 22, 2014

Distributed vs. Distributional Representations

Distributed Representations = Learnt using Deep Learning methods. Distributed over the parameter space. Dense, lower dimensional embeddings.

Distributional Representations = Counted from a corpus. Classical distributional hypothesis. Sparse, High dimensional.

Continuously monitor GPU usage

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