Python jump start

In my current job (Research Assistant at SAnToS lab) I had to learn Python. I was very happy because of that. It gaves me an opportunity to get familiar with one of the most popular programming languages nowadays.

I was very lucky to find awesome Google’s Python Class by Nick Parlante. It is great! If you want to start programming with Python or just learn it for fun, start with this tutorial!

As a supplement to above course you can read some more detailed tutorial. I went through two: Learn Python The Hard Way and Tutorial from Python documentation. However if you already know some other programming language(s), your should learn during development. Python contains almost all common features of programming languages such as if/else, loops, exceptions, functions, classes etc. I said ‘almost’, because there is e.g. no switch instruction. However to check things like that there is very well written documentation. It contains a lot of examples. The main difference between other popular languages like (C, C# or Java) and Python is that there is no semicolons. We use colons and indentation instead.

if number > 0:
  print "This is natural number."
  print "This is not natural number."

Python is dynamic, strongly typed programming language. It means type checking occurs during the run time, instead of compilation time. Programming in Python is a real pleasure. Sometimes you can explicitly put your mind into the code. That is because of high level of abstraction. E.g. file operations are so simple and intuitive. You do not need to remember any StreamReaders or BufferedReaders and bunch of functions for simple I/O operations. Below example reads content of file.

f = open('file.txt')

Cool feature is the possibility to call functions explicitly on string. Like that:


There is a lot of implemented (widely used) functions in Python. As a comparison, let’s see how to reverse words in a sentence using C, Java and Python.

In C:

void reverse_words(char *sentence)
   char *start = sentence;
   char *end = sentence;

   while (*end != '\0') {

   reverse_chars(start, end);
   while (*start != '\0') {
      for (; *start != '\0' && *start == ' '; start++) ;
      for (end=start; *end != '\0' && *end != ' '; end++) ;
      reverse_chars(start, end);
      start = ++end;

void reverse_chars(char *left, char *right)
   char temp;

   while( left < right) {
      temp = *left;
      *left = *right;
      *right = temp;

In Java:

public string ReverseWords(string sentence)
  string[] words =  sentence.split(" ");
  string rev = "";
  for(int i = words.length - 1; i >= 0 ; i--)
    rev += words[i] + " ";
  return rev;

In Python:

def reverse_words(sentence):
  return " ".join(reversed(sentence.split(" ")))

That’s why Python is good for Rapid Development.

I am also using PyGTK (graphic library for Python) in my work. There is a great tutorial Python GTK on youtube! PyGTK requires very less code than e.g. C# to create some simple application. We do not to have tons of generated code when we start. We create application from scratch. Look at below Hello World example.

import pygtk
import gtk

class HelloWorld:
    def hello(self, widget, data=None):
        print "Hello World"

    def destroy(self, widget, data=None):

    def __init__(self):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect("destroy", self.destroy)
        self.button = gtk.Button("Hello World")
        self.button.connect("clicked", self.hello, None)

    def main(self):

if __name__ == "__main__":
    hello = HelloWorld()

The result is the window with button ‘Hello World’. When you click the button, then ‘Hello World’ will be printed on console. All of that with 22 lines of code (I do not count white lines).

Hello Python

If you don’t know python yet, I encourage you to try it. Programming in python requires a little bit different way of thinking. It also allows you to look at the programming from the different perspective.

Python installation is easy on all operating systems and you can find it in google. To install PyGTK in Windows you can use all in-one installer. There is also all-in-one installer for Mac. PyGTK is included in most Linux distributions, so you won’t need to install it if you are using Linux.

Tech Ed North America 2013

In June 3 – 6, there was Tech Ed North America conference in New Orleans. The videos are available on channel9. I have watched a few very good sessions, and I can recommend you especially 5 of them.

Live Demonstration: Hacker Tools You Should Know and Worry About (Hasain Alshakarti and Marcus Murray)

This is my favourite session. You can learn about various security tools. They show things we should be aware of.

APTs: Cybercrime, Cyber Attacks, Warfare and Threats Exposed (Hasain Alshakarti and Marcus Murray)

Another session. Now in enterprise point of view. They discussed techniques how companies are getting hacked.

Adventures in Underland: What Passwords Do When No One Is Watching (Paula Januszkiewicz)

This session shows that our passwords are not 100% secure when stored in Windows.

Hackers (Not) Halted (Paula Januszkiewicz)

Session about most common mistakes, which can be used to hack you.

Microsoft ASP.NET, Web, and Cloud Tools Preview (Damian Edwards)

General overview and new enchancements of Web Tools and Features in .NET.

There was NDC conference in Oslo, in last week (June 12-14), but Videos are not available yet. The next big thing is build 2013 in San Francisco, June 26 – 28.

Studying in the USA

Studying in United States is a way different than in Poland. In October 2008 I started Bachelor of Science at Wroclaw University of Technology (Poland). In Fall 2011 I was exchange student at the Kansas State University (USA). After that I camealt back and graduated at WUT (Wroclaw University of Technology) in January 2012. Then I started Master of Science (in English) and I also applied for Master program at the KSU (Kansas State University) and UA (University of Arizona) for Fall 2012. I was admitted to both Universities, but I didn’t get assistantship offer (to be Teaching Assistant or Research Assistant). Everybody knows that studying in USA is pretty expensive, but not when you have assistantship. Then department is paying for your tuition and you have salary/scholarship, which enables you to cover living expenses (such as rent apartment, food etc.). However I got an RA (Research Assistant) offer from KSU in July and finally started Master program in Spring 2013 (because it was too late to make VISA related issues done before Fall 2012).

In USA there are Fall and Spring semesters. Fall starts usually in the middle of August and ends in December before Christmas. Then there is winter break till middle January. After that Spring semester starts, and it ends in mid-May.

Kansas State Campus

One of my friends (who got PhD at KSU) said that the difference between KSU and WUT is that KSU gives you real opportunity to learn something: it is easier to get good grades but it is also easier to learn a lot. I agree in 100%. The standard amount of classes for Undergraduate student (Bachelor degree) is 15 credit hours (30 ECTS), which is about 5 courses (usually one course has 3 credits). At WUT sometimes I had 10 courses. The standard amount for Graduate Student (Master or PhD) is only 9 credits (3 courses). It is not because it is easier, but courses are more time consuming. That is because there is much more to learn than in typical 6 ECTS course in WUT. Usually Master Student is also TA (Teaching Assistant) or RA (Research Assistant), which means additionally 20 or more hours. Last semester I took one class, which consumed about 10 hours (excluding classes) per week for me (you can find estimated work amount here). It is like 2 hours every day, and I had two more classes and research. As a reward I learnt a lot.

Another difference is that there is no strict list of courses you need to take. In Poland, all students from the same major has the same classes (only in last two semesters you can choose specialty but you still have the same classes with ~40 people). In USA, student choose courses on his own. There are minimum requirements, but usually you have a choice to pick one of a few proposed courses to satisfy one area requirement. You can find a degree requirements for Master degree in my department here.

Kansas State Campus

Sometimes in WUT it is enough to study only one day before exam (if there is no laboratory or tutorials for that course). Here in USA it is impossible. You need to study every week, because of homeworks, quizes, required reading etc. In some courses there are quizzes in every week. Additionally ‘quiz’ not necessarily means ABCD. In my department it is always open-question test. The 90% of International students coming here for exchange from Europe, after two weeks says: “In last two weeks I was that busy like in finals week at my University”. In last semester, the day before semester start I received an email that I have a quiz in my first class and I need to be prepared for it (by reading given materials).

In USA everybody cares about studying. Students are not playing games during the lectures. Even when lecture is not obligatory, almost everybody is there and they interact with instructor a lot.

Disclaimer: All information given above are based on my personal experience. Everything can be different depends on the University, Department and even course you take.

Developer mouse

When you are looking for a good mouse, you always find lists of ‘top mouses for gamers’. However good mouse is also very important for developers. People who spend most of their time on computer. Usually we use various of applications and moving between them is like playing Call of Duty. When you want to click maximize button in VirtualBox or VMWare and you hit close instead, you are dead (VM start closing). You need to start your mission over (run the VM again). Some developers have problems with their hands (pain) caused by mouse use. It is good to invest some money in mouse instead of buying the cheapest or random one. However I have never spend on mouse more than $30. I tried various types of cheapest ones and medium-price.

A4Tech SnakeX-750BFRazer SamlosaLogitech M100

Five years ago I made one of my best purchase: A4-Tech XL-750BF. I paid about $20. It was very good mouse in the notion of precision and comfort. I like to have high DPI. This mouse has 6 modes: 600-800-1200-1600-2000-2500 DPI (adjustable by a little key on top). I use to work on 2500 DPI. Unfortunately, after 3 years the left key broke down. Not completely though, but when I was dragging items, sometimes they were dropped when key was still pushed (instead of MOUSE_DOWN I had MOUSE_DOWN-MOUSE_UP-MOUSE_DOWN sequence).

Then I decided to invest in better brand and I bought Razer Salmosa. I found good deal on eBay for ~$25. It was quite good, but too small for my hand, and not that comfortable as A4-Tech was. This mouse was good for less than 2 years. Then (again!) left button broke down. Maybe I am not using it appropriate?

A4Tech OscarX-748K

After that I thought my next mouse’s left button will probably be broken too after some time and I decided to buy the cheapest Logitech: M100 ($7 on eBay). It is good mouse, but only if you do not have any other. A few weeks after purchase I found new A4-Tech: X-748K. It had good reviews and I decided to buy it. And again A4-Tech becomes very good choice. I paid $20 and I love this mouse! It has also 6 DPI modes (like X-750BF): 600-800-1200-1600-2400-3200. It fits perfectly to my hand and is nice in touch. The slightly rough surface is very cool. I am using it almost three weeks and it’s working fine. It is the best mouse I have ever use. We’ll see how long it lasts 🙂

Desktop Watcher

Have you ever forgotten to lock your computer and went for a lunch? If so then you know what can happen. Your coworkers can send invitation for a party at your place to all co-workers (using your e-mail). They can also mess up with your desktop icons and much, much other fun stuff. The best solution is always lock the system. However sometimes we forget about it.

Once I was bored after work I created WinForms application, which starts playing scary sound when somebody move the mouse or push some key on the keyboard (while I am out of my desk). Usually when you want to mess up with somebody’s machine your heart rate is higher than normal (because of adrenaline that you can be caught). Then not expected scary sound can cause even heart attack.

I named my app: Desktop Watcher. It looks like that:

Desktop Watcher

When you hit Play, you get file dialog to choose some scary sound (like this) from your hard drive. Then you need to put cursor in the program area and leave your machine. You have 5 seconds for that. Every mouse move or keyboard’s key push after that will start sound playing and lock the machine. If you caught somebody the machine will be locked and sound will be playing. To quit the app you need to unlock the machine and hit ALT-F4  immediately (two keys together – because hit only ALT will cause lock screen again) or close app by mouse if you are quick hand person.

No worries that somebody close your app by ALT-F4 before he moves the mouse. If so then system will be locked anyway (but no sound will be played). You do not need to worry about it, because it means that somebody knew you prepared a trap 🙂

There is an issue that mouse needs to be in the program area to detect mouse moves. I may fix it in the future, but for now you can just hide the app somewhere (e.g. on right bottom corner):

Desktop Watcher hidden

Source (and sample scary sound) is available on github: