Posts

Showing posts from February, 2015

Never Run Your Mongodb as Root User

We have recently had a "to many open files" problem in one of our Mongodb servers. Mongodb kept saying "Out of file descriptors. Waiting one second before trying to accept more connections." and accept no more connections. The first thing came to our mind was that the reason is too much load, our mongodb servers were no longer enough to carry it. But it was wrong. After first research it became clear that it was because of linux's user limits, so our wrong decision: running mongodb servers with the root user. In linux systems, every user has some limits which decide how much system resources they are allowed to consume. These limits prevent one devil user to drain all the system and to make other users to starve of resources. In our linux servers, root user had lower limits than mongodb's suggested limits. Even if the root user had the suggested limits, we could have had the problem any way. Because root user is responsible for other operational works, not

Euclidean Distance (similarity)

Bir kümedeki elementlerin benzerliğini ölçen, benzerlik puanı üreten avantajı ve dezavantajı duruma göre değişen algoritmalar bulunmaktadır. Collaborative Intelligence kitabında Euclidean Distance hesaplaması ile film eleştirmenleri arasındaki benzerlik hesaplanmıştır. Senaryoda, kişiler çeşitli filmlere puan vermişlerdir ve bu puanlar üzerinden bir kişinin diğer insanlarla arasındaki benzerlik hesaplanmıştır.Birkaç ekleme dışında kodların tamamını kitaptaki gibi aktarıyorum. from math import sqrt def sim_euclidan_distance(prefs, person1, person2): si={} for item in prefs[person1]: if item in prefs[person2]: si[item]=1 if len(si)==0: return 0 sum_of_squares=sum([ pow( prefs[person1][item]-prefs[person2][item], 2) for item in prefs[person1] if item in prefs[person2] ]) return 1/(1+sqrt(sum_of_squares)) critics={ 'Mustafa': { "The Matrix": 5, "The Godfather": 5, "Se7en": 3, "Babel": 2, "Troy": 4, &

Code is what, not how

Code is known to be written something by programmers for computers to do some tasks. Currently commanding by a language which is near to computers is not necessary for most use-cases. When we create a file on a disk, in most use cases we do not care how this process is carried out. When we fetch an URL’s content, we enjoy concise statements like ‘fetch_content(url)’, get_url_content(url)’. We are not interested in how, but what. We are migrating from the imperative paradigm to the declarative one. So that we invented high level languages such as Python, C#, Java, PHP; which are more similar to a natural language.

Predicting game results from fans’ emotions

Image
Facebook’s data science team published a post in which they claim it is possible to predict a football team’s performance mining emotions of its fans. The post tells us before a kick-off, fans seem positive. But the volume of positive emotion is higher in the fans who support the better team. After the match, the winner’s fans feel very high positive emotion, on the other hand other team’s fans feel negative. Actually we do not need any study to predict this correlation between teams and their fans. It is obvious when a team wins, its fans get happy and so they post positive status messages. Yet I think this study is not trivial. Every study does not necessarily bring about a breakthrough.

Migrating from PHP to Python

At last, I’ve made a strong decision to migrate from PHP to Python. Leaving a tool, leaving your bread basket would not be an easy decision if you used it almost for eight years. Otherwise, I believe that sometimes with a little bit courage to leave your conform zone and a lot of curiosity you can get a better bread basket, maybe a jar of jam too. if you want to be a sea, you must give up being a drop. Why am I leaving PHP? Actually I am not leaving PHP totally, but switching my primary language to Python because my works have been changing. Most of work required from me is related to natural language processing(NLP), machine learning(ML) techniques. And I, and many other developers, find Python much more capable to deal with this kind of works. It has already many libraries, tools, frameworks for NLP and ML. Another reason is that I think web programming will not grow as much as an intelligent system. Maybe I am wrong, but there is no doubt the future is about intelligent systems.

Debugging is not less important

In my programming circle, I’ve encountered many programmers who give most of their attention to debugging software bugs. And this is not bad, but not enough to be efficient. Efficiency includes both preventing possible bugs and removing existent one. Let me explain what programming and debugging are with a doctor-patient analogy, which I’ve just made out. As we all know, to be healthy the first thing we must do is not eating too much and junk food, doing enough exercise, not smoking, and not drinking too much drink. The list may vary for each individual. Even though we do all these, it is always possible to be ill. In view of possibility of being ill, we always require doctor to be around in case of anything. For example, not to be a diabetic you need control your eating. But does the controlling make medical improvement against diabetes unnecessary? Not at all. We need enough efficient cure to diabetes, so medical and science works on this. We need doctors. Analogously, in software