Saturday, February 20, 2016

Django prefetch_related VS select_related in a single database query

Imagine the following model:
class Parent(Model):

class Child(Model)
    parent = ForeignKey(Parent)

I want to list all parents along with first related child.

Thursday, February 4, 2016

Cracking wifi password with pyrit and NVIDIA GPU on Amazon AWS

WPA algorithm is very secure, and to get the password usually we have only one way - to brute force it, which could take huge time if password is strong enough. But what if instead of using regular CPUs we would use a power of GPU? Amazon says, that we can use up to 1,536 CUDA cores on g2.2xlarge instance, which costs $0.65 per Hour. Sounds very promising, so let's see how it can help us to speed up password brute force.

Below I will give step-by-step tutorial on how to deploy Amazon GPU instance and run pyrit (python tool) to crack password using GPU.

Tuesday, February 2, 2016

Tricky questions: function parameters with default mutable values

Today I discovered one confusing feature of Python. And also decided to open new category on my blog, which will be called "tricky python questions".

def append(num, to=[]):
    return to

aa = append(1)
print aa

bb = append(2)
print bb