Temassız Mart

Geçtiğimiz ay, temassız ödeme çözümleri üzerine minik bir araştırma yaptım. Amacım bu çözümlerin Türkiye’deki kullanılabilirliğini ve yaygınlığını incelemekti. Bir ay boyunca banka kartım ile yaptığım her ödemede temassız ödeme seçeneğini özellikle sordum.

1 Mart – 31 Mart tarihleri arasında banka kartım ile 45 ödeme yaptım. Bu ödemelerin sadece 15 tanesinde temassız ödeme seçeneğini kullanabildim. 11 tanesinde işlem yapılan cihazın temassız özelliği yapılandırılmamış olduğundan kullanamadım. Diğerlerinde ise temassız özelliği hiç mevcut değildi.

Market ve gıda zincirlerinde temassız ödeme sistemleri ile karşılaşmanız neredeyse kesin gibi. Üstelik destekleyen tüm POS cihazlarının temassız ödeme için yapılandırılması tamamlanırsa ödemelerinizin %60′ını temassız gerçekleştirmeniz mümkün olabilir.

Bu teknolojinin daha da heyecan verici yanı, NFC destekli akıllı telefonların artması ile birlikte banka kartı (hatta cüzdan) taşıma eziyetinden kurtulabilecek olmanız. Temassız bir gelecek çok da uzakta değil.

Creating an Instance of an Object without Calling Its Constructor in PHP

Today, I stumbled upon an article in a local PHP developers group. It was about creating an instance of an object without calling its constructor (as mentioned in post title).

At first, the idea made no sense to me. Because, constructor method is run every time an object is instantiated, this property is the whole point of writing a constructor. Out of curiosity, I started reading the article. As it turns out, it is really beneficial for testing and mocking purposes. The more interesting thing is the method used to achieve this is simply brilliant.

The trick which originally occurs in PHPUnit source code is as follows:

$object = unserialize(
    sprintf('O:%d:"%s":0:{}', strlen($className), $className)

As of PHP 5.4, there is a built-in method for this in ReflectionClass:

$reflection = new ReflectionClass($className);
$object = $reflection->newInstanceWithoutConstructor();

Graphical Visualization of databases with PostgreSQL Autodoc

When it comes to software, database systems are beneficial in many ways. They offer us to keep our data organized and a fast way to access them. However as the number of components in a software project increases, it gets harder to preserve the organized structure. In situations like this, visualizing the scheme helps to understand the structure and the relations between the tables.

PostgreSQL Autodoc provides simple tools for description of the PostgreSQL databases in various formats such as HTML, DocBook, Dia and GraphViz. Continue reading

Sharing Screen Sessions

Recently, I learned a new feature of screen, it is referred as “multi display mode” in the manual. You can attach to a screen session that is not detached and the session is simply shared. In this mode, anything you typed are transferred simultaneously to the other display(s) as well. My mentor from my Google Summer of Code project used this feature to work collaboratively. In order to get in to multi display mode, you need to use “-x” parameter:

screen -x

If there are multiple sessions, you need to provide the session name as well:

screen -x session_name

Quick Guide to D-Bus with Python

Recent weeks, I dealt with D-Bus for my Google Summer of Code project. I was trying to control system services, and systemd has a D-Bus interface. In the beginning, D-Bus seemed a little confusing for me, but I believe I understand it now. In this post I will try to explain it in simple terms and an example.

D-Bus is a interprocess communication tool. It delivers messages to applications. The most confusing thing for me was that taxonomy of D-Bus having several terms such as bus names, objects, paths, methods, signals, properties, interfaces, proxies… But when you learn their meanings, the bigger picture gets more clear.

  • Bus names are applications. They often have well known names in a format similar to namespaces in Java (e.g “com.onurguzel.MyIntergalacticApplication”).
  • Objects are synonymous to the objects in programming languages, and paths are the object instances.
  • Methods are functions that is run on the object, and signals are the broadcasts from the object. Properties are the constants or variables in the object.
  • Interfaces are the types of the object. Thus, some object may support several interfaces. Their format is the same as bus names, but they should not be mixed with each other.
  • Proxies are higher level objects. When a method is invoked on the proxy, it is converted to D-Bus method call message, sent, and reply message is returned. They offer easier operation with D-Bus then manually creating messages, sending them and waiting for a reply.

Since all major Linux distributions use NetworkManager for network connections, I preferred to create this tutorial with it.

import dbus

bus = dbus.SystemBus()

# Warning: Bus names and interfaces are different terms.
# Just because they contain same format or even same data
# does not mean they are the same thing.
# I used these variables to denote the diffrance where bus names and
# interfaces are used.
NM_BUSNAME = 'org.freedesktop.NetworkManager'
NM_IFACE = 'org.freedesktop.NetworkManager'

# Create Python object from /org/freedesktop/NetworkManager instance
# in org.freedesktop.NetworkManager application.
nm = bus.get_object(NM_BUSNAME, '/org/freedesktop/NetworkManager')

# Get list of active connections from the properties
# "Get" method is in "org.freedesktop.DBus.Properties" interface
# It takes the interface name which has the property and name of
# the property as arguments.

connections = nm.Get(NM_BUSNAME, 'ActiveConnections',

# While invoking a method on the object, dbus_interface keyword
# argument is provided to specify which interface has the method.

# Now, lets disconnect. This time we are using the NetworkManager
# interface: "org.freedesktop.NetworkManager"
for path in connections:
    nm.DeactivateConnection(path, dbus_interface=NM_IFACE)

If you have questions about this tutorial, you can ask in the comments section below. For more information about D-Bus, my references:

A Very Delayed Update on My GSoC Status

It has been over a month since summer coding started. Unfortunately, although I am not a procrastinator, I could not perform my best on the project. Besides following news about #OccupyGezi, I have read the Pyramid documentation in the community bonding period. Coding time has also past reading documentations. I spent my time reading and understanding SQLAlchemy and designing the modules for the project in my head.

I have managed to get my focus on my work, two weeks ago. Now, I have several weeks to catch up. The mistakes I’ve made so far:

  • I did not ask my mentor for advices.
  • I got distracted a lot. It was very hard to handle both summer school and summer coding. Because, school has its own assignments, too.
  • Even though I make my commits atomic, instead of pushing them regularly, I kept them local until I finished working on the feature.
  • I did not write any blog posts about my status or what I have done.

I am not proud of this failure or mentioning it here. However, I have learned from my mistakes, and I will not repeat them. You will see more frequent updates on my project status here. Keep following!

Google Summer of Code Heyecanı

Google Summer of Code‘a kabul edilen projelere baktığım an muhteşemdi. Öğrenciler arasında arama yapmak için adımı yazdım ve sayfa “Yükleniyor…” ibaresiyle takılı kaldı. Aramayı tekrar tetiklemek için son harfi silip tekrar yazdım, ama ekrana bakamadım. Gözlerimi kapattım, gerçekten, ve cesaretimi toplayıp açtım. İçinde adım geçen bir sonuç vardı. İnanamadım, o yüzden az önce yaptıklarımı tekrarladım: adımı yazdım, gözlerimi kapattım ve tekrar açtım. Pardus’a stajyer olarak seçildiğimi öğrendiğim andan çok da farklı değildi. Yüzümdeki gülümsemeye engel olamıyordum, heyecandan titriyordum. Hiçbir şeye tepki veremeyecek kadar kilitlenmiştim ve bolca terliyordum. Kendime sürekli nefes almam gerektiğini hatırlatıyordum. Elimi telefona uzatım birkaç dakika önce görüştüğüm annemi tekrar arayıp anlattım. Bu iki buçuk dakikayı hayatım boyunca hatırlayacağım.
Continue reading

Passion of Google Summer of Code

It was an epic moment when I was checking the accepted projects for Google Summer of Code. I typed my first name and searched through students. The page stuck “Loading…” I erased the last letter ‘r’, and typed it again to trigger the search once more. I literally closed my eyes, and prayed, and dared to open. There was a result, with my name. I couldn’t believe, so I repeated my last process: typed my name, closed my eyes, and opened again. It was not so much different the moment I was selected for internship at Pardus. I could not stop myself from smiling, and I was shaking, a lot! I was shocked, and constantly reminded myself to breathe. I hit the redial button on my phone, told my mom. I will remember that two and half minutes forever.
Continue reading

Install LESS on Ubuntu with npm

LESS is available on Ubuntu repositories as “node-less” package. However, as of writing this post, it is an old version (1.3.1) which contains lots of bugs, while a newer and more stable one (1.3.3) is available. And you can install latest LESS version with npm:

sudo apt-get install npm
sudo npm install -g less

Because the command name of the node.js is nodejs (instead of node) on Ubuntu, when the installation is complete, you need to change this first line of lessc command. Open /usr/local/bin/lessc with your favorite text editor (with root privileges), and change the end of the first line from node to nodejs.

--- lessc.old	2013-05-21 13:50:00 +0300
+++ lessc	2013-05-21 13:51:00 +0300
@@ -1,4 +1,4 @@
-#!/usr/bin/env node
+#!/usr/bin/env nodejs
 var path = require('path'),
     fs = require('fs'),

After saving the file, you can test if lessc command is available, and the correct version is installed.

which lessc
lessc -v

If you have any trouble, you can ask me on the comment section below.

VirtualBox, Shared Folders and Cache

I have recently set up a virtual server environment using VirtualBox for quick web development. Using shared folders feature, I wanted to avoid file uploads between VM host and guest. However, when I make request to an updated a file, server responses with the old version.

First, I cleared and disabled my browser cache. The result was the same. Second, I checked the file both on host and guest machines. Both were up to date, so the issue was about the server. Then I have made some experiments with expires headers, again, no luck.

I continued searching on the internet and found this blog post. Sendfile option is disabled by default on Nginx (see documentation), but apparently Ubuntu had turned it on with the configuration file on the package. You can turn it off by setting the flag off or commenting the line:

# sendfile on;
# or
sendfile off;

Sendfile is enabled by default of Apache. In order to turn it off, you can refer to the official documentation here.