Fix the sticky top navigation bars on websites

I hate sticky top navigation bars (what are they actually called?)! I just hate them. If I wanted to reach your search bar or wanted to switch to homepage I can press the `Home` button and I’m at top. Or I can flick my smooth scrolling wheel and I’m there. Or I just click my mouse wheel, with a slight mouse movement; I’m up there.

If you really want to provide some sort of instant navigation, put it in the sidebar. That’s what it’s for! Leave my vertical space for the content! It gets even worse on the mobile! Not everyone owns a giant 5.5″ mobile beast. I like my 4″ tiny screen. It’s just enough. [UPDATE: now I own a 5.5″ mobile beast, it turns out, those bars still cover a good portion of screen estate, urghh] But those idiots, put not 1 but 2 layers of sticky top panels there and drive me crazy.

I’ve just noticed my angry English sucks. So I will keep it short.

Here is a greasemonkey script that I’ve forked from this one. It tries to disable sticky top panels. Be warned though, this is just an ugly hack. It may (will) potentially break the interface in some cases.

Script for creating KiCad symbols for STM32 MCUs

ST has recently released a tool for creating projects for STM32 mcu’s called STM32CubeMX . This tool also allows you to plan your pin layout for a selected MCU part. Using the interface you see below, you can select pin features and configuration. You can also label the pins as you desire.

After you plan your pin layout, you can create a list of pins in the form of a CSV file. For this from menu select: “Pinout > Generate CSV pinout text file”. This should create a CSV file similar to this:

"5","PH0 - OSC_IN","I/O","RCC_OSC_IN",""
"6","PH1 - OSC_OUT","I/O","RCC_OSC_OUT",""

Using this file and my script you can create a KiCad symbol that is specific to this pin layout in a whim. Get the script here.

When you run the script from the command line:

./ --name symbol_name input_file_name.csv output_file_name.lib

It should generate a KiCad symbol library which contains a symbol similar to what you see below.

As you can see output isn’t perfect. It certainly requires some edits. But it’s still very very useful.

PCB back annotation in KiCAD with Python

KiCAD already provides a tool to automatically annotate your schematics before moving on to PCB. But I prefer to to annotate my components according to their PCB position. That makes it easier to locate a certain component when you have PCB on your hand and schematic is open in the computer screen.

Some tools such as Altium, provides such function. It works like this;

  • First you annotate your components in schematic (presumably according to their position in schematic sheet)
  • You switch to PCB side, complete the placing of your components
  • Re-annotate the components on PCB
  • Back-annotate name changes to the schematic

KiCad doesn’t have this feature. So I decided to give it a try at implementing this feature with KiCad’s python scripting interface. And I’m successful (I think..).

I’ve created a script that when you run it; re-names all components on your PCB according to their PCB position. Then updates your schematic files with these changes. You don’t have to lift a finger.

First of all my script doesn’t use the KiCad’s python API directly. Instead it uses a wrapper written in python which provides a more pythonic API. It’s called kicad-python and it’s on github. Unfortunately original project had some problems, so I had to fork it and add some missing features. So you have to use my fork instead.

You can find the script in examples/ folder of my kicad-python repository. Before running it make sure you BACKUP YOUR FILES.

Note that you don’t have to install ‘kicad-python’ on your system. You can use it from the downloaded location. There is only 1 dependency at the moment (other than obvious kicad installation), which you can install via pip:

  • enum34

Update: now kicad-python comes with it’s copy of the ‘enum34’ module. I’ve added it because at the moment installing python modules on kicad’s windows version seems to be a pain.

To run the script, load your board with pcbnew. Start the python console from “Tools->Scripting Console”. Make sure ‘kicad-python’ is in your path (if you haven’t installed it):

import sys

Run the script with:


After you run a script, pcbnew doesn’t update the view immediately. You can force it to redraw by cycling canvases. For ex; switch to original canvas mode then switch to opengl canvas. Let me know if you know a better method for this.

Important notes:

  • Backup your files before running the script.
  • Make sure you have a recent version of KiCad (at least 4.0)
  • Script won’t rename components if their names doesn’t end with a number. For ex. something like ‘D12X’ won’t be renamed!
  • Schematics are updated with simple string replacement. So it may not work in some cases. Unfortunately at the moment KiCad has scripting only for PCB
  • After you run the script, update the netlist files. When you read netlist from pcbnew, it shouldn’t change any component footprints. Otherwise something went wrong! It may update some (automatically given) net names though. That’s expected.
  • You should really backup your files!

If you have any problems/questions with the script please let me know. I will try to help as much as I can.

SerialPlot – Realtime Plotting Software for UART/Serial Port

SerialPlot is my new open source adventure. It allows you to plot data coming through your computers serial port. To be honest, nowadays it’s most likely this will be a USB port, emulating serial port.

It supports binary and ASCII data formats. Binary formats include uint8, int8, uint16, int8, uint32, int32 and float. There is also multi channel support. SerialPlot doesn’t require a sophisticated package format. It just assumes each channels data is sent consecutively. That means all channels should be synchronized. In case of ASCII it’s different. ASCII input actually can be in CSV (comma separated values) format. Each channel is sent as a column.

Below is a screenshot of the SerialPlot:


Currently there is installation package for debian/ubuntu only. I hope to add windows support soon, and some other linux distributions as well. You can download debian package from here.

Source code is released under GPLv3 license. You can obtain code from my mercurial repository over at bitbucket. I also have created a project page at

If you have any trouble installing/building, please let me know.

Emacs mu4e: auto-complete mail addresses

I love auto-complete package. I wish it was more commonly used by other emacs packages. But luckily auto-complete is very easy to use(*). Below is a small snippet to use auto-complete mode for completing mail addresses when writing an e-mail with mu4e.

(defvar ac-source-contacts
  '((candidates . mu4e~contacts-for-completion)
    (prefix . "^\\(?:To\\|CC\\|BCC\\): \\(?:.*, *\\)?\\(.*\\)")))

(add-hook 'mu4e-compose-mode-hook
            (setq ac-sources '(ac-source-contacts))

(*) provided that you already have a nice list of candidates to choose from : )

Update 3/01/2015: `company-mode` which provides a completion mechanism very similar to `auto-complete` mode works with mu4e out of the box. You don’t have to configure anything. Install and enable. Although there is a graphical glitch, I find its completion better.

Python code to convert ligth wave length to RGB color

This is a small python function to convert a wave length of light to its corresponding RGB color. Note that this is a crude approximation. Calculating the actual RGB representation of a specific wave length is rather tricky. You could also say it’s impossible. That’s because your computer screen can only show a limited range of light colors. So, below code should be good enough for most presentational purposes.

def wave2rgb(wave):
    # This is a port of javascript code from
    gamma = 0.8
    intensity_max = 1

    if wave < 380:
        red, green, blue = 0, 0, 0
    elif wave < 440:
        red = -(wave - 440) / (440 - 380)
        green, blue = 0, 1
    elif wave < 490:
        red = 0
        green = (wave - 440) / (490 - 440)
        blue = 1
    elif wave < 510:
        red, green = 0, 1
        blue = -(wave - 510) / (510 - 490)
    elif wave < 580:
        red = (wave - 510) / (580 - 510)
        green, blue = 1, 0
    elif wave < 645:
        red = 1
        green = -(wave - 645) / (645 - 580)
        blue = 0
    elif wave <= 780:
        red, green, blue = 1, 0, 0
        red, green, blue = 0, 0, 0

    # let the intensity fall of near the vision limits
    if wave < 380:
        factor = 0
    elif wave < 420:
        factor = 0.3 + 0.7 * (wave - 380) / (420 - 380)
    elif wave < 700:
        factor = 1
    elif wave <= 780:
        factor = 0.3 + 0.7 * (780 - wave) / (780 - 700)
        factor = 0

    def f(c):
        if c == 0:
            return 0
            return intensity_max * pow (c * factor, gamma)

    return f(red), f(green), f(blue)

Below is an example code that uses this function:

import matplotlib.pyplot as p
import numpy as np

N = 100
image = np.zeros((5,N,3))

for i in range(0, 5):
    for j in range(0, N):
        start = 380
        end = 780
        wave = j * (end-start)/N + start
        image[i][j] = wave2rgb(wave)

ax = p.axes()

This should produce an output similar to below:


Emacs on-the-fly (as you type) syntax checking for VHDL [flycheck, nvc]

Flycheck is an on the fly syntax checker for Emacs. When configured properly it performs really great. Flycheck itself doesn’t do syntax checking. It uses external tools for that. There are many syntax checker tools out there for programming languages like C and python, but none for vhdl. Then I’ve noticed that error output of nvc vhdl simulator is quite helpful and decided to use it as syntax checker back end. Result was better then I expected.

Integrating nvc with flycheck wasn’t hard. It’s merely adding a few lines to your init file. See below. I think the code is self-explanatory.

(flycheck-define-checker vhdl-nvc
 "A VHDL syntax checker using nvc."
 :command ("nvc" "--message=compact" "-a" source)
 ((error line-start (file-name) ":" line ":" column
 ": error: " (message) line-end))
 :modes vhdl-mode)

Obviously you will need nvc vhdl simulator for this to work. Get it from here:

It’s not the best and you may encounter some problems using nvc like that, after all it’s not designed for this purpose. But it’s still pretty useful.

My Review of Lenovo T440s

This is my review of Lenovo T440s. It doesn’t cover much. It’s more like notes about things that have annoyed me with this device.


I knew that touchpad wasn’t good before buying this device. No review that I read has skipped that point. I thought, how bad it could be? Maybe it’s not as good as the -now- old design, but it should be a decent touchpad. After all there are no other products -that I know of- that has the famous touchpad of the Lenovo Thinkpad series. Well, I was wrong! This touchpad literally sucks! I can’t believe Lenovo decided to ship this beautiful product with this touchpad. It’s stupid but a few times I found myself thinking: have they deliberately tried to make this worse?

First of all, physical buttons are gone. You should have noticed that already.

When touching the touchpad (not clicking), it shakes and makes sound. It’s really annoying, and feels cheap. Like similar devices, whole touchpad is a button. But to for a click, you have to apply a decent amount of force. No problem, you can use touch-clicking. But this doesn’t work for right click. You have to actually press down the touchpad for a right click. When pressing the touchpad, cursor always moves around and I miss my target, which is really really annoying. It’s almost impossible to right click without cursor moving around (and sometimes messing things up).

There are two red markings on the top side of touchpad that I thought indicated left and right click. Nope. It’s left click everywhere, only right bottom side is right click. But when using the trackpoint right top side is right click. Middle click? There are markings on top middle, but no middle click. I think this works when using trackpoint, but I haven’t figured out that yet. I never knew that using a touchpad would be that confusing.

Palm rejection isn’t good. Touchpad area is quite big. When typing, my thumb touches the touchpad and this moves the cursor around, clicks etc. The fact that I have to focus on the position of cursor right now writing this blog post, is annoying.

By the way touchpad actually have a really nice surface. It feels nice to touch and move your finger around.


Keyboard is nice. I’m no lenovo expert, but this keyboard is as good as t530 (previous lenovo laptop that I had used).

Keyboard back light has two levels. You can switch between off state, half brightness and full brightness by pressing Fn+Space keys.

By default you have media keys in place of function keys. If you want to press a function key you can use Fn key. That’s not a big issue, you can press Fn+ESC and lock Fn key. Now, top row keys act as function keys and to use them as media keys you press Fn. When locked, green led of Fn key will be on, so that you are not confused.

Wi-Fi problems

I heard about brand new laptops having trouble with connecting to wifi, but I never heard one that crashes the wifi network! Yep. This device has crashed (and will continue to crash) my entire wifi network. I couldn’t connect to wifi from other devices, I had to restart the router and the wifi adapter of the other devices to be able to re-connect them. It’s a mess! I have found some reports that stated; this problem is caused by some Lenovo software, but I couldn’t find the exact problem yet (that problematic lenovo software doesn’t exist on my device). No wifi for now.

After installing linux I didn’t have much issue with the wifi. It’s just that sometimes signal goes away, and I have to restart the internal wifi adapter for it to work. But It’s rare, and it might be an issue with the wifi router I’m connecting to.


Generally LCD is good. It’s bright and viewing angles are spectacular. There is a little light bleeding on the edges – which is a common problem with all IPS displays. I only notice it when watching something fullscreen. It starts to be annoying when you watch things frequently.

But something else I keep noticing is a display artifact similar to a dead pixel. I’m not sure if it’s a dead pixel or not. It looks like a small, tiny 1-2 pixel wide shadow on the screen. It’s not really annoying. But still, I wish it didn’t exist.

Other Problems

This one isn’t exactly a product defect like others, but still, it’s an issue that I had to solve. Device disk came with 4 partitions already. Boot partition, system partition, recovery partition, some unknown partition.. And I learned that to be able to create another 5th partition I had to convert one of these to an extended partition which requires me to delete the system partition.. Isn’t that awesome!


Second day after I got the device, I have installed Linux Mint Debian (Cinnamon desktop) on it. Here is a list of problems I have encountered so far.

  • microphone mute key doesn’t work, led also doesn’t work (there is a fix that requires me to compile the kernel)
  • fingerprint doesn’t work (there is a patch to libfprint library, which is reported to work slow)
  • hibernate doesn’t work (I fixed that by creating a swap partition)
  • suspend drains too much power (I have measured it and it looks like, computer can survive on suspend only 6 days. This may sound like a small issue but consider that I sometimes leave my computer on suspend for two days, and when I open it up an important amount of battery is drained. I have switched to hibernate, because you never know when you need battery life.)
  • Occasional lock-ups after waking from hibernate! Whaaat? It literally locks down like windows. I think I should try another distribution. (Updated to Linux Mint 17 which is based on Ubuntu 14.04, problem persists)

Update 28 Dec: Case/Body

Laptop has an aluminum body which contributes it to look really sleek and still be lightweight. But actually design of the case has a serious defect. Maybe my unit has this problem, I don’t know. To see what I’m talking about please have look at the below photographs. You should have noticed the unfortunate scratches. These scratches are caused by the laptop lid. Even tough laptop lid has a rubber material on its edges that (I think) should have prevented this issue. But it seems that, this doesn’t work because inner part of the laptop lid, is too thick. Inner edges of the LCD (which doesn’t have any rubber) touches the bottom body of the laptop and causes these scratches. With all the small issues this is the most saddening one. It’s been only a few months and my laptop already looks old 🙁 .

Also when lid closed, keyboard touches the LCD and occasionally I have to clean the grease left from keys touching the screen (actually I wash my hands quite frequently). I hope this doesn’t cause a permanent problem in the future. I have been planning to use this laptop for a long time.

Script to Install Debian Packages as a Group

This is a python script to install debian packages as a group. This will allow you to remove the packages you don’t need easily when you want to clean your system.

When you install a package using `apt-get` it will mark all packages that are installed as it’s dependencies as “automatically installed”. When an “automatically installed” package is not needed by a “user installed” package it can be “automatically removed”. So when you install an application with `apt-get` it’s easy to remove its unnecessary dependencies. But if you frequently build and install applications from source, you will be installing bunch of packages which are build dependencies. And those packages will not be marked as “automatically installed”. Even if you mark them somehow, you need a parent package that depends on them to prevent them to be uninstalled with `apt-get autoremove`.

And this is where `` will help you. It will create a dummy package with dependencies that you specify and install that package with gdebi. That way you can clean your system from these packages easily, by removing that dummy package and running `apt-get autoremove` afterwards.

You can find `` at my public git repository: