Skip to main content

Posts

Installing Google styleguide in Intellij on Mac

Download the   intellij-java-google-style.xml  file from repo:   http://code.google.com/p/google-styleguide/ . Download it and go into  Preferences -> Editor -> Code Style .  Click on  Manage  and import the downloaded Style Setting file.  Select  GoogleStyle  as new coding style.      Additional Java Style Guides:       https://google.github.io/styleguide/javaguide.html       https://github.com/twitter/commons/blob/master/src/java/com/twitter/common/styleguide.md
Recent posts

Running Docker on Linux Mint

Docker doesn't come natively installed on Linux Mint. To be able to run it you will need apparmor and cgroup-lite packages. Follow the steps below to get it working: Add repository to APT sources sudo echo deb https://get.docker.com/ubuntu docker main > /etc/apt/sources.list.d/docker.list Import repository keys sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 Install Docker  sudo apt-get update sudo apt-get install -y docker.io cgroup-lite apparmor  Check if Docker daemon is running  ps aux | grep docker If docker daemon is not running, try the following command: sudo service docker start Check if docker.sock exists. This file needs to be owned by docker group to be able to connect to it without root permissions   ls -al /var/run/docker.* Check if user is part of docker group   id -a If user is not in the docker group you can add them using this command:  s...

Geospatial queries in MongoDB - Part 2 : {"err": "location object expected, location array not in correct format" "code": 16804}

In my last post we saw we had to create a geospatial index on the " pos " field as follows: > db.foodtrucks.ensureIndex({pos:"2d"}) However, when executing the command above we get the following error:   > db.foodtrucks.ensureIndex({pos:"2d"}) {     "createdCollectionAutomatically" : false,     "numIndexesBefore" : 3,     "ok" : 0,     "errmsg" : "location object expected, location array not in correct format",     "code" : 16804 } After some further investigation I realized that we had some documents which didn't had any latitude/longitude information. Due to this some of the documents looked like this: {     "_id" : ObjectId("53d07bf1e3e11dacc21056a8") ,     "locationid" : 437222 ,     "Applicant" : "Natan's Catering" ,     "FacilityType" : "Truck" ,     "cnn" : 188101 ,     "Locatio...

Geospatial queries in MongoDB - Part 1

While building a food truck service using which a user can browse and search for food options in a given area, I had to work with geographic latitude/longitude information. I was using MongoDB as my data store which supports geospatial queries. A sample document in my foodtruck collection looks like this: > db.foodtrucks.find().pretty().limit(1); {     "_id" : ObjectId("53d07bf1e3e11dacc2105697"),     "locationid" : 559777,     "Applicant" : "Mang Hang Catering",     "FacilityType" : "Truck",     "cnn" : 131000,     "LocationDescription" : "02ND ST: JESSIE ST to MISSION ST (69 - 99)",     "Address" : "85 02ND ST",     "blocklot" : 3708019,     "block" : 3708,     "lot" : 19,     "permit" : "14MFF-0109",     "Status" : "REQUESTED",     "FoodItems" : "...

Remove and ignore files like .DS_Store, .classpath so that it doesn't get added to your github repo

When promoting code on github it is usually a good idea not to promote files like .DS_Store. .classpath etc. To accomplish this you can include a .gitignore file in your first commit . Git uses it to determine which files and directories to ignore, before you make a commit. Here is what my .gitignore looks like: /.buildpath /build/ */archive/ # Compiled source # ################### *.com *.class *.dll *.exe *.o *.so   .project .settings .classpath # Packages # ############ # it's better to unpack these files and commit the raw source # git has its own built in compression methods *.7z *.dmg *.gz *.iso *.jar *.rar *.tar *.zip # Logs and databases # ###################### *.log *.sql *.sqlite # OS generated files # ###################### .DS_Store .DS_Store? ._* .Spotlight-V100 .Trashes ehthumbs.db Thumbs.db Icon?     Alternatively, you can create a global .gitignor...

Installing Tomcat on Mac OS X

Installing Tomcat on Mac can be done in three steps. Following the steps below you can have tomcat running on your Mac in no time. Step 1: Download and Install Tomcat Binaries Download the most recent stable build of Tomcat from an Apache project mirror site . Unzip the binaries into a simple location (I did it in /Users/username/Documents).  By default, the unpacked folder name will be something like "apache-tomcat-x-x-xx".  I recommend changing it to "tomcat" for ease of use. Step 2: Configure the env variables  For our purpose we need to set up JAVA_HOME and CATALINA_HOME variables. Setting up these variables will ensure we don't have to use the complete path name. To set the variables, open a new Terminal window and use the following command to open the system profile for editing. vi ~/.profile Once you've opened the profile, add the following lines to set the JAVA_HOME and CATALINA_HOME variables: export JAVA_HOME=/Library/Java/Home ...

Commits not showing up on the contribution page in Github

I recently ran into an issue where my commits were not showing up on my github account. Initially I thought it had something to do with settings on my new machine as I started having this issue after I switched machines. However, the public activity page was listing all my contributions just fine which led me believe something else was wrong. After spending some time trying to debug this, I contacted github. They told me I was using an email address 'robin@Robins-MacBook-Air.local' in my .gitconfig which was the system login. Due to this, changes were not being attributed to my account. To change this I ran the following command: git config --global user.email <my_email_on_github_account> The email needs to match an email address in your GitHub account in order for the commits to be properly attributed to you. However, I also wanted my previous commits to be attributed to me. For that I had to add 'robin@Robins-MacBook-Air. local' to my GitHub account here...