BLOG

standard

Bouldering gym in Kadıköy, Istanbul

2.03.2014 Posted in Travel No Comments

I would like to just contribute more to the bouldering in Istanbul. Since, I have been in Istanbul for over a month and I like bouldering. However, after a bit of searching I found little information about bouldering gyms in Istanbul. So far, I have been to two gyms and I’d like to share one of them first.

It’s called Boulder Istanbul.

How to get there
This one is quite easy to get to and the location on the map below is quite accurate. I have checked in myself.

You can get the metro to Kadıköy and then walk from there for only 10-15 minutes or you can get the metrobus to Söğütlüçeşme which is the terminal station at the Asian side and then walk for 15-20 minutes. It’s quite a nice walk through kebab shops.

Some pics

Boulder Istanbul

Boulder Istanbul

Boulder Istanbul

Boulder Istanbul

Boulder Istanbul

Boulder Istanbul

Price
It’s only 15 TL for a day pass.

Official address

Nüzhetefendi Sokak No:54 (Rıhtım caddesinin 3 üst paraleli)
Kadıköy

Istanbul

standard

Example of Require.js optimizer.

9.02.2014 Posted in Javascript No Comments

I decided to write this blog post to show how easy it is to setup require.js optimizer and how many bytes it saves.

To make it as simple as possible, I created this repository on github to show the real example.

This is the results of optimisation.

optimized version.

optimized version.

And this is the result of non-optimized version.

Require.js

It’s clear to see that the optimized version takes shorter to load the script, where as the non-optimized version in the files might be smaller but with a lot of calls, it takes longer to load all the scripts.

standard

Merge documents from two collections together in MongoDb

23.01.2014 Posted in Knowledges No Comments

The problem is I have a lot of documents in one collection and even a lot more documents in another collection. I want to merge those documents together but I don’t want to write a lot of code to merge those documents together. It also might take a lot of time to do it.

MongoDb comes with map/reduce which is a cool feature you can use to achieve something like this. If you don’t know what map/reduce is I wrote an article like this sometime ago.

Let’s say you have one collection with this document. Let’s say it’s products collection.

1
2
3
4
5
{
  "_id" : ObjectId("52e05133c68f0b2a95e2b67b"),
  "product_id" : 1,
  "title" : "Sharpie"
}

And another document in prices collection.

1
2
3
4
5
{
  "_id" : ObjectId("52e05473c68f0b2a95e2b682"),
  "product_id" : 1,
  "price" : 99
}

I want to end up with this.

1
{ "_id" : 1, "value" : { "title" : "Sharpie", "price" : 99 } }

Here’s what you can do. Insert your data first.

1
2
3
4
db.products.insert({"product_id" : 1, "title" : "Sharpie"});
db.products.insert({"product_id" : 2, "title" : "Sticky"});
db.prices.insert({"product_id" : 1, "price" : 99});
db.prices.insert({"product_id" : 2, "price" : 30});

Then you build maps to get key/value from the documents

1
2
3
4
5
6
7
products_map = function() {
  emit(this.product_id, {"title" : this.title});
}

prices_map = function() {
  emit(this.product_id, {"price" : this.price});
};

Then you build your reduce function

1
2
3
4
5
6
7
8
9
10
11
12
13
14
r = function(key, values) {
  var result = {
      "title" : "",
      "price" : ""
    };

    values.forEach(function(value) {
      if(value.title !== null) {result.title = value.title;}

      if(value.price !== null) {result.price = value.price;}
    });

    return result;
}

Then you run your map/reduce function.

1
2
res = db.products.mapReduce(products_map, r, {out: {reduce : 'joined'}});
res = db.prices.mapReduce(prices_map, r, {out: {reduce : 'joined'}});

Then you will get another collection joined with the information you want. One caveat is right now map/reduce function will result in value : { “field” : “value” }.