Take apart. Make science.

welcome

  • Adversarial machine learning intro and examples

    Adversarial machine learning is one of my specific interests in the field. This short post is about advertising a notebook code with some examples but also speculating on the topic. I am specifically focusing on computer vision tasks taking handwritten digit classification as a textbook example. The subject notebook is available via this link.

    Continue reading →
  • Installing Windows 10 without installation media

    While on vacations, my wife’s Samsung phone suddenly refused to turn on. I thought I might be able to fix it by re-flashing the firmware (looking forward, I was wrong: the phone had a hardware failure). For this, I needed a Windows machine to run the flashing tool. I have no Windows on my laptop and I had no USB stick to install it either. So I had to figure out a “vegetarian” way of installing an operating system without using any installation media. Turns out, this is pretty straightforward if you are using modern Linux.

    Continue reading →
  • Sole underscore in python

    A sole underscore _ is often used in code snippets to drop one or more outputs.

    proc = subprocess.Popen(...)
    _, errs = proc.communicate()
    # do smth with errs
    

    Why do we use _ in place of a variable name in this case? Is it a convention or there is some magic behind? Let’s investigate with dis.

    Continue reading →
  • pyteleport - teleporting python runtime

    cut_image

    I often find myself in a situation where different parts of a script are most optimal to run in different environments. Like, for example fetching the configuration can be done locally, dataset manipulation is best done in a many-CPU environment, while machine learning requires a GPU-capable machine. Managing this is a nightmare: you split jobs into multiple steps, save intermediate results, deposit and transmit data, schedule job chains, and, most annoying, ensure the integrity of the whole run. There are many infrastructure solutions for this problem which come at a price of having to deploy and to maintain them as well.

    Instead, I was recently inspired by the idea of forking a process to another machine right in the middle of its execution. Indeed, it is rather tempting to not worry about intermediate variables which you have to save and to load, often from cumbersome locations, and to just swap the environment without interrupting the logic. I created a tiny proof of concept which does this in the context of python scripts. Also available on pip: pip install pyteleport. This post is about technical details of pyteleport and transmitting runtime states in general.

    Continue reading →
  • Random discoveries 1

    A collection of small hacks which I discovered recently. This time: ssh ControlMaster and the synergy of dataclass and @cached_property in python.

    cut_image

    Continue reading →
  • Micropython

    cut_image

    Python is the language that I write most of my code in and cPython is the interpreter that I use. That’s quite typical: python is cPython 99% of the time. But what is that small fraction of other python interpreters? Today I am featuring micropython: an independent project that fits python language into tiny (few kB or MB) bare metal platforms.

    Continue reading →
  • 'di' - the reverse of 'id' in python

    id(obj) returns an integer with object address in python (cPython). What about the reverse: return python object by address?

    Continue reading →
  • Hacking python bytecode in runtime: custom 'return(...)'

    Python flow is controlled by a number of statements, such as for, if, while, raise, try, return. These are a part of python language which you are not allowed to (re-)implement by yourself. Or are you?

    Continue reading →
  • Modifying immutable objects in python

    In python, strings and bytes are immutable objects which you cannot modify. But what to do if you absolutely want to? The nastiest way to do it is to overwrite the corresponding memory block. Here is how you do it in pure python.

    Continue reading →