Best movies that I’ve seen in 2012

This is a very difficult list to make since I’ve seen many movies this year. But I will update it when I remember others.

Marigold Hotel

El Clasico


Life of Pi

Midnight in Paris

The words

Dark Knight Rises

Xcode run scripts

I found some useful scripts here and there. I collect them here.

Adding git commit count as the build version automatically

# Set the build number to the current git commit count.
# If we're using the Dev scheme, then we'll suffix the build
# number with the current branch name, to make collisions
# far less likely across feature branches.
# Based on:
git=`sh /etc/profile; which git`
appBuild=`"$git" rev-list --all |wc -l`
if [ $CONFIGURATION = "Debug" ]; then
branchName=`"$git" rev-parse --abbrev-ref HEAD`
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $appBuild-$branchName" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $appBuild" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"

Printing the total line of codes to logs

echo "Total lines of code:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" \) -and \( -path "${SRCROOT}/Pods/*" -prune -o -print0 \) | xargs -0 cat | wc -l

You should see it on logs (View->Navigator->Show Log Navigator)

Moving TODOs and FIXMEs to warnings

So it will bug you forever until you fix them.

find "${SRCROOT}" \( -name "*.h" -or -name "*.m" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/"


iOS debugging tips

  • Use Instruments to see memory leaks, core data fetches or auto layout workflow.
  • Debugging console: pausing and investigate the variables by commands like po or p. Full list is here.
  • See device logs and read StackTrace, if any
  • Activate NSZombieEnabled flag at scheme settings. This will provide a warning when you try to access a variable which is already deallocated.
  • Use `exception breakpoints`, which will stop when there is an exception threw.
  • Use breakpoints to log messages instead of NSLog. Edit breakpoint for it.
  • Use `conditional breakpoints`.
  • Use  `symbolic breakpoints`, when you want the execution stop if a certain message sent. It is particularly useful when you don’t have access to the source.

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.