Sunday, January 8, 2012

Viaport Tuzla Servisi - Tren yoluyla

Internet arşivinde yer alsın, başkalarına yol göstersin diye not etmek istiyorum.

Eğer Tuzla'dan Viaport'a gitmek istiyorsanız ve Tuzla'ya tren yoluyla ulaşacaksanız işte yol tarifi:

Trenden İçmeler istasyonunda inin.
Tren yolunun güneyine (deniz tarafına) geçin.
Tuzla Belediyesinin otoparkını göreceksiniz. Ana caddeye çıkın. (Hatboyu cd)
Tuzla Belediyesi Otobüs durağında bekleyin.

Yaklaşık saat başı Tuzla merkezden servis kalkıyor. Güncel saatlere Viaport'un sitesinden bakabilirsiniz. Kalkıştan yaklaşık 20 dakika sonra servis ulaşmasını bekleyebilirsiniz. Haftasonu erken gelirseniz soğuk havada bekleyebileceğiniz bir yer yok gibi. Haftaiçi belediye veya kaymakamlıkta beklenebilir.

Tuesday, December 27, 2011

PhD of Computer Engineering in Boğaziçi University

I forgot to write here for a long time. This fall I started my PhD studies in Boğaziçi University. I'm currently taking some courses but I'll be working on Complex Network Analysis in general. In these days I'll be starting to study for my final exams. This semester I've taken Complex Networks, Social and Semantic Web, Artificial Intelligence courses.

Django 'matching query does not exist'

When you encounter 'ClassName matching query does not exist' error in Django, it means that somewhere you have such code:

item = ClassName.objects.get(key=value)

but there's no item that satisfies key=value. So it gives this error. Be aware of this. There are some other sites which makes you confuse although this is a very simple error

Thursday, December 16, 2010

ParallelPython vs multiprocessing

Today I'm working on parallelisation of a process I have written. Process is simply a text conversion. I have a translator class, organism directories and files inside these directories. What I want to do is to split the data among the processors and perform the operation faster.

To do this, I tested multiprocessing and ParallelPython modules of python. Without using these modules, it took 38 seconds to perform the task whereas with the help of these modules, it went down to 29 seconds(multiprocessing) and 30 seconds (ParallelPython). Not a great deal but better than nothing. By the way, ParallelPython is way too complicated compared to multiprocessing.

Here is the code for ParallelPython:

import translator
import os
from utils.pp import pp

base = "/some/path"
organisms = [ "organism1", "organism2", ...]

def convert_organism(base, organism):
t = translator.BiogridOspreyTranslator()
# uses os module here
t.translate()

if __name__ == '__main__':
job_server = pp.Server(ppservers=())
jobs = [(organism, job_server.submit(convert_organism, (base, organism,), (), ("os","translator",))) for organism in organisms]
for organism, job in jobs:
job()




ParallelPython requires you to tell him the modules the functions requires. I didn't like that.
And here is the code for multiprocessing:

from translator import *
import os
from multiprocessing import Pool

base = "/some/path"
organisms = [ "organism1", "organism2", ...]

def convert_organism(organism):
t = BiogridOspreyTranslator()
# uses os module here
t.translate()

if __name__ == '__main__':
pool = Pool(processes = 2)
pool.map(convert_organism, organisms)

Tuesday, December 7, 2010

Uploading on sourceforge

Today, we're trying to publish our project Robinviz. It'll be a 1.0-beta version seperately for windows/linux source/binary. Binary files are around 400MB so it's a bit hard to upload it. Google Code -which we use for project management- limits the maximum file size for uploads. So we had to switch to sourceforge. But uploading on http was still a problem. So I found this solution: Rsync over SSH

At first, I found it hard to understand the URL format but then understood and wanted to share it with you. With the following command, I was able to send my 400MB file with resume support:

rsync -avP -e ssh robinviz-1.0-beta-linux-binary.tar.gz aladagemre,robinviz@frs.sourceforge.net:/home/frs/project/r/ro/robinviz/linux-1.0-beta

robinviz-1.0-beta-linux-binary.tar.gz: filename
aladagemre: username on sourceforge
robinviz: project name
/r/ro/robinviz: the first letter, the first two letters and all letters of the project joined by /
linux-1.0-beta: the folder I'd like to put my file in.

Hope it's useful.

Saturday, October 30, 2010

Dell Wireless 1515 Wireless-N Adapter and WPA timeout on Vista

I'm using a Dell Wireless 1515 Wireless-N Adapter and having connection problems in Vista. When I use WPA for authentication, it doesn't connect to my wireless network and says authentication failed due to timeout. Sometimes it doesn't connect and very rarely it connects. When I looked at the Event viewer, I saw the following details:

Detailed root cause:
Layer 2 security key exchange did not generate multicast keys before timeout


After a long research, I thought that I found a way to fix that. I went to Dell drivers site and wrote my laptop Service tag to get appropriate driver updates. I downloaded the one for my wireless adapter: R198377.exe. The reason why the research was long is that I had to do it on another OS and wanted to find a sound solution not to fail and return back. The dates for the driver were earlier than the date I purchased my laptop but it seems like the drivers coming with it are pretty old.

After installing that, my wireless card -surprisingly- immediately connected to the wireless network. I was gonna say "Well done!" but it turned out to be a coincidence that it worked! After a restart, it was the same problem again. Re-installing driver didn't work. Sigh.

I don't know what to do with this.

Sunday, September 5, 2010

Keyword Argument Injection with Python Decorators

In most of the object oriented codes we write, we need to set class variables to the given argument values and this is a very line-consuming thing. See what I mean:

class Test:
def __init__(self, x, y, z, t):
self.x = x
self.y = y
self.z = z
self.t = t
print x,y,z,t


To get over these redundant lines, I found a solution using decorators:

def injectArguments(inFunction):
def outFunction(*args,**kwargs):
_self = args[0]
_self.__dict__.update(kwargs)
inFunction(*args,**kwargs)
return outFunction

class Test:
@injectArguments
def __init__(self, x, y, z, t):
print self.x,self.y,self.z,self.t

@injectArguments
def fonksiyon(self, ad):
print "Ad:",self.ad

t = Test(x=4, y=5, z=6, t=7)
t.fonksiyon(ad="Emre")


args dictionary contains the arguments and kwargs dictionary contains the keyword arguments. arg[0] corresponds to self argument. So what we do is we update self.__dict__ with {'x':4, 'y':5,'z':6,'t':7} where self corresponds to the Test instance. This way, bulky self.x = x, etc. codes are eliminated.

I don't know if any built-it decorator like this exists in Python libraries but it seems like I'll be using this a lot.