MongoDB Courses

Hi everyone!

It has been a long time ago since the last post. I’ve been working an a very interesting course MongoDB for DBA. I will recommend this very interesting and useful course to anyone who wants to understand NoSQL databases, there is a lot of theory in the course, and at the same time it’s very practical, with exercises and a very interesting final exam!

Take a look, and if you have time to involved it, it’s a very good option to improve your knowledge!

And the best of all, it’s free ;D

And once you finished, they send you a certificate, here is mine 😉 Click

MongoDB $regex not working

This will be a quick tip of Mongodb:

I usually try my regular expressions in a Regular Expression “helper” I use gskinner and it’s really nice. My problem appears when here it perfectly works, and not in Mongodb shell.

My regexp:


This regular expression match with any word that starts with a decimal [0-9]

What was my mongodb query?

db.zips.find({ "city" : { $regex : "\d\w*" } })

Where was my mistake?


I thought that the regexp has to be inside “” and it has to be between / /

The solution

 db.zips.find({ "city" : { $regex : /\d\w*/ } }) 

It works perfectly!

This happened to me later in Nginx, I think mongodb and nginx use Perl PCRE.

Useful links

MongoDB $regex doc: $regex
Regular Expression Cheat Sheet
Regular Expression helper: gskinner

Working with local Git and remote

Hi everyone!

Today I will talk about Git. As I suppose you know very well, or at least, you know a little bid of what is it. Git is a code version control software. There are others like SVN, Mercurial… but today I will talk about working with Git locally and deploy your source changes into remote machines. If you need more information about Git, check wikipedia, always useful ;). Link

First of all you have to have Git installed, this guide is quite simple and help you to install GIT in any OS.

Once we have git, we can initialize our first repo.

git init
git add *
git commit -m "First commit with all my initial source"

Here we have the first step, and this could be enough if you’re not going to deploy your code outside your box.

For example, if you have your webserver and you want to deploy your local changes in the source, you may have to do something like this. Other reason could be to have a external backup. If your source is replicated in other box, the possibilities of loosing all your work decreases, everything fails, sooner than you think 😉

Remote repos

In this example I will deploy my changes to my Amazon AWS EC2 machine.

I connect throw SSH to the machine and type this commands:

mkdir -p /var/git/example
cd /var/git/example
git init --bare

Now what we have to do is add a remote repository to our local repo.

We go to your local repo directory and type:

git remote add aws
git push -u aws master

At this point, we have replicated our repo in the cloud ;D easy, isn’t it?

Now what we want to do is to deploy our repo into the working directory, for example the Apache2 directory. In our remote machine, we go to the working directory and type the following:

cd /var/www/workingDirectory
git clone /var/git/example .

At this time we create a copy of the repo, with master branch prepared to serve your pages!

Now any changes you push to AWS you’ll have to enter in your working directory and pull changes. Easy!

cd /var/www/workingDirectory
git pull origin master

First post of GIT, more tricks soon!

Stay in the cloud!

Google Maps div grey?


Hi again!

This will be a very short shoot of a recent problem I have been in a project. The problem was related with Google Maps (gmaps V3).

The problem was in the div of the map, I get part of it in grey. But all the functionalities work, I get my pointers, I can zoom, move the map, but I still getting grey zones.

This picture will help you to understand if you have similar problem.

The most amazing think was that all the code that generate the map, and the position of the map were OK! I tried the same code outside where is has to be placed and everything works. My first thought was the CSS. I have been using complex CSS styles, but nothing worked.

The solution, of course, StackOverflow has the solution. The problem was that the div where GMaps is placed, in this case, in the beginning of the stage the div was hidden, it causes gmaps scripts doesn’t get correct sizes and prints locations in grey.

How to solve? In Stackoverflow they try to use fixed position, in my case, not the best solution. My solution, generate gmaps at the same time that the user try to show the hidden part of the page where where the map is it placed. The bad think, user will have to wait until Google returns all the data of the map, just a second. Strange problem, with difficult problem source, but with easy solution 😉

Stay cloud!

Uso de cookies

Este sitio web utiliza cookies para que usted tenga la mejor experiencia de usuario. Si continúa navegando está dando su consentimiento para la aceptación de las mencionadas cookies y la aceptación de nuestra política de cookies, pinche el enlace para mayor información.plugin cookies