Pro tip for debugging auto-layout

Here is a neat protip. While running your app in iOS simulator, hit ‘pause’, and run following command `po [[UIWindow keyWindow] _autoLayoutTrace]`. This will give you the trace of the autolayout.

Disk usage is a bitch

I, with my 128gb main hdd, struggle a lot.

I list the big files in a folder like this (or folders changing the -type switch to d)

find . -type f -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}

Or I use mac apps like `DiskDiag` or `OmniSwipe` to visually analyze what’s eating my space.

I even wrote a small script to delete iOS simulator’s unneeded data.

Lately I discovered a great tool called `ncdu`. Using shell, it displays the information about your hdd usage. and it’s very fast. Get it from here or do this `brew install ncdu`.

Following are similar tools that I copied from the website:

gt5 - Quite similar to ncdu, but a different approach.
tdu - Another small ncurses-based disk usage visualization utility.
TreeSize - GTK, using a treeview.
Baobab - GTK, using pie-charts, a treeview and a treemap. Comes with GNOME.
GdMap - GTK, with a treemap display.
Filelight - KDE, using pie-charts.
KDirStat - KDE, with a treemap display.
QDiskUsage - Qt, using pie-charts.
xdiskusage - FLTK, with a treemap display.
fsv - 3D visualization.
Philesight - Web-based clone of Filelight.

Goz hastane ucretleri

Birilerine faydali olmasi umidiyle:

Medical park goz muayene ucretleri:
SGK yok: 130TL (normal) 200TL (prof)
SGK var: 80TL (normal) 200TL (prof)
Emekli icin de ayni fiyatlar gecerli.

Dunyagoz ucretleri
SGK Var: 90+12TL
SGK Yok: 250

Yedikule surp pirgic hastanesi ucretleri
SGK Yok: 70TL
SGK Var (emekli): 22TL
SGK Var (calisan): 34TL

Model inheritance with node.js and mongoose

I am disappointed that mongoose documentation didn’t mention inheritance of models. To follow object-oriented principles, it is inevitable that you’ll want to have some inheritance in your models. Here is how:

First things first, let’s include mongoose and connect to db. It’s obvious that you should have a working mongodb instance. Run `mongod` in terminal.

  var util = require('util');
  var mongoose = require('mongoose');
  var db = mongoose.connection; 
  var Schema = mongoose.Schema;

  db.on('error', console.error.bind(console, 'connection error:'));   
  db.once('open', function callback () {                              
    console.log("mongodb is opened");                               

Now, here is the fun part. I will create an abstract animal class that will hold the base structure of our model. All our animals will have a name.

function AbstractAnimalSchema() {           
    Schema.apply(this, arguments);          
        name: String
util.inherits(AbstractAnimalSchema, Schema);

`util.inherits` is the key part here. This is the javascript way of inheritance. Basically you’re saying, I want to extend `Schema` with `AbstractAnimalSchema`.

var AnimalSchema = new AbstractAnimalSchema();  
var KittySchema = new AbstractAnimalSchema({    
    tail_type: String                           

var DogSchema = new AbstractAnimalSchema({                
    leg_type: String                                      
var Animal = mongoose.model('Animal', AnimalSchema); // our base model   
var Dog = Animal.discriminator('Dog', DogSchema); // our derived model (see discriminator)
var Kitten = Animal.discriminator('Kitten', KittySchema); // our derived model (see discriminator)

Now, we defined `Animal` model which is the base model of all animals. And 2 derived model `Kitten` and `Dog`. Let’s add some data to db.

var mycat = new Kitten({ name: "My Kitten", tail_type: "Long" });, mycat) {                                   
    console.log("kitten is saved"); // no error checking, we're so cool.
var mydog = new Dog({ name: "My dog", leg_type: "Short Legged" });, mydog) {
    console.log("dog is saved");

Now, fetch all animals

Animal.find(function(err, animals) {
    console.log("all animals: ");

The result should be something like this:

[ { name: 'My Kitten',
    _id: 53049e22d1c2380000d3fb3f,
    __v: 0,
    __t: 'Kitten' },
  { name: 'My dog',
    _id: 53049e22d1c2380000d3fb40,
    __v: 0,
    __t: 'Dog' } ]

I learned all these things from here

First thoughts of node.js, expressjs and mongoose

I am very new to node.js (in fact, I wrote my first program in node just an hour ago). It is cool, really cool environment. I like it very much but it still seems a bit raw. Expressjs documentation for instance, is not comprehensive. There is a concept called “middlewares”, and expressjs documentation believes that people already know it by heart, so why bother with definitions (luckly, I can tell thanks to my experience with django).

Another problem I see is that the 3rd party apps aren’t in their stable versions yet (most of them). In comparison with `django`, it is not then reliable imo.

Another comparison with `django`: express doesn’t come with a model layer, but you can use mongoose, or any other orm that I am not aware. Also, django comes with lots of out-of-the-box solutions like authentication/authorization, admin panel, etc. expressjs doesn’t.

On the other hand, having to develop non-blocking web apps is amazing, it changes the whole way of programming web. I think node.js and its apps will be way more mature in the near future that will be inevitable for anyone to switch. For now I stick with django for relatively big projects because it’s a great and mature framework and I do things reaaaaaly fast. But I can say that I am in a slow transition to node.

How to query Cname’s

Easy, issue following command on your terminal

nslookup -q=mx

Weird missing icon file error on iOS AppStore submission

I migrated icons of my xcode project to `xcassets`. Then I started to getting this error:

missing required icon file. The bundle does not contain an app icon for iphone / ipod touch of exactly '57x57' pixels, in .png format

If you, too, getting this error, don’t fret. Just add `Icon files (iOS 5)` key to your info.plist and add your icons. woila.

Unique numbers algorithm

Recently, I was asked how to remove duplicated (get unique numbers) out of a given array of numbers. My answer is to use hash tables if returning unordered numbers are okay. Otherwise sorting the array then testing each item in a loop if it’s different then the next one is my solution. I am not sure that it is the greatest solution.

I have created a github repo for implementing this kind of little data structures problem for excersize.

Debugging php with XDebug

I’ve been developing other technologies than PHP for a quiet while. But the shadow of the past chased me and I find myself adding some new features to an old project.

The problem was that I didn’t even have a decent php/apache installation on my mac. I remember that it was a quite painful process to install and configure it. Hopefully this post will help you to get started quickly.

First get homebrew if you didn’t. It’s the nicest package manager for mac. Don’t forget to `brew update` and `brew upgrade`. Then install php related packages.

brew install php55 php55-xdebug phpunit

Apache web server is already installed on your mac, so no need to install another one. Just make sure that you change you `DocumentRoot` and tweak the settings a little bit from `/etc/apache2/httpd.conf`. Comments in this file is great help.

For `xdebug` you need to configure your `php.ini` a little. It’s path should be something like `/usr/local/etc/php/5.5/php.ini` but you can see it from your `phpinfo()`. Entries should be like this:


Now, go ahead and grab MacGDBp. It’s a great visual debugger for mac. `remote_autostart` will trigger MacGDBp if it’s opened, and the debugging session will start.

In order to put a breakpoint in your code, just place the following statement in your code:


Now whenever you visit the page you want to debug, MacGDBp will kick in and allow you to step-through and debug your code.


Changing umask of folders to 755, and files to 644
chmod -R 755 *
chmod -R 644 $(find . ! -type d)