Make gps working on your android phone if running LineageOS or cynagenmod


A known problem with LineageOS and cynogenmod on Android is that after an upgrade or first install the GPS isn’t working.
The solution is rather simple.
– Start your device in fastboot mode
Most of the times you start your phone with power and volume down pressed together and release power when the device starts.
– Your now in fastboot.
– Connect the phone by usb cable to you PC.
– Execute the following fastboot commands:
fastboot erase modemst1
fastboot erase modemst2

– Reboot phone.

Git list commit messages to create a changelog file


When you want to construct a changelog file from git commit messages you can use git log.
The way to construct such a list of commit messages is to use the git log command like this:
git log --since "DEC 1 2016" --until "FEB 3 2017" --pretty=format:"%s" > git.log.txt

This will only display the text of the commit message.
Other useful format options are :
git log --since "DEC 1 2016" --until "FEB 2 2017" --pretty=format:"%an %ad >> %s"
To get the author name and date.

More info can be found here:

How to get stock lollipop on your rooted Nexus 7 3G 2012


As I had my Nexus 7 3G 2012 tablet unlocked and rooted I didn’t get any official updates anymore.

But I still think the Nexus 7 tablet is the best tablet still I decided to get it a lollipop.

Be aware that everything will be removed from your device.
Your totally responsible for your actions, if you brick your device I can’t help you.
This description is not for beginners and I will not provide every detail of the processes.

Lets go.

  1. Download the google factory android image, look for “razorg” for Nexus 7 [2013] (Mobile),
  2. Follow the instructions at the top of that page to get the rom flashed, but don’t lock the bootloader again.
  3. Reboot your device to check that everything is working properly. (Be aware that first boot takes a while, be patience)
  4. If you get a image of a dead android with a red sign sticking out of its chest do a factory reset (instructions from google nexus support)
    While holding down the Power button, press and release the Volume Up button once.
    Press the Volume Down button twice to highlight “wipe data/factory reset,” then press the Power button to select it.
    Press the Volume Down button seven times to highlight “Yes – erase all user data,” then press the Power button to select it.
    After the reset is complete, select the option to reboot your device.
  5. Download the chainfire root tool and image:
  6. Unzip it and use fastboot to flash it
  7. sudo fastboot boot image/CF-Auto-Root-grouper-nakasi-nexus7.img
  8. It will reboot your device and performs it’s magic (placing su and pacthing the kernel)
  9. Be aware that it can take up to a minute before you see the red chanfire android and the patching starts.
  10. The device will reboot again (Mine did a second reboot just after booting the rom, not sure if that was intended)
  11. The device will boot into lollipop and starts to upgrade the apps (again let it do it’s thing first time boots take a while on android)
  12. Check your rooted by starting the supersu app.

Now you can let your bootloader unlocked or lock it, it’s up to you.
I lock it again just to be on the save side.Have fun with your lollipop.



Usefull teamviewer options for remote access


The information comes from this fine blog:

  1.  teamviewer --version print version information
      teamviewer --info print version, status, id
      teamviewer --passwd [PASSWD] set a password (useful when installing remote (ssh)
      teamviewer --ziplog create a zip containing all teamviewer logs (useful when contacting support)teamviewer --daemon status show current status of the TeamViewer daemon
      teamviewer --daemon start start TeamViewer daemon
      teamviewer --daemon stop stop TeamViewer daemon
      teamviewer --daemon restart stop/start TeamViewer daemon
      teamviewer --daemon disable disable TeamViewer daemon - don't start daemon on system startup
      teamviewer --daemon enable enable TeamViewer daemon - start daemon on system startup (default)
  2. Now we will check ID number for calling remotely our device and the current status of teamviewer daemon in our computer:
    user@home_machine:~$ /usr/bin/teamviewer –info

    TeamViewer 8.0.17147
     teamviewerd status
     teamviewerd stop/waiting
    TeamViewer ID: 9XXXXXXX7 <-- Your ID number
  3. If we don’t remember the password to connect to teamviewer in our home machine we can reset it using this command:
    user@home_machine:~$ /usr/bin/teamviewer –passwd MYnewpassword
  4. Now it’s time to enable the teamviewer daemon and launch (start) it. check that it’s up and running:
    user@home_machine:~$ sudo teamviewer --daemon enable
     mar jul 9 13:29:00 CEST 2013
      Action: Installing daemon (8.0.17147) for 'SystemV' ...
      installing /etc/init.d/teamviewerd (/opt/teamviewer8/tv_bin/script/teamviewerd.sysv)
      System start/stop links for /etc/init.d/teamviewerd already exist.
      /etc/init.d/teamviewerd start
      Starting teamviewerd...

    user@home_machine:~$ sudo teamviewer –daemon start

    /etc/init.d/teamviewerd start
      Starting teamviewerd...

ogg not playing on Kivy when packaged with pyinstaller


I’m working to package a Kivy based project for Windows7 by using pyinstaller and while following
the Kivy manual I noticed that all went well except for the ogg sound files I’m using.
The only thing one would notice when running the “exe” is that when playing the ogg you
would only hear a “click” iso the ogg sound file.
The solution  was to include by hand the the following DLL’s from site-packages/pygame:
libogg.dll, libvorbis.dll and libvorbisfile.dll to th eroot of the “exe” tree.

ssh tunnel for web2py admin when no https is available


For a simpel web2py based server running on a non-https port I wanted to be able to get to the admin interface but normally that isn’t possible as you will get a “Admin is disabled because insecure channel” message.

The solution is to use a ssh tunnel:

Assuming the web2py server runs at server:8000.

ssh -L 8001: user@server

Then go in your browser to





Stop Thunderbird from eating your CPU cycles


When using thunderbird it occurred to me that it was using a lot of CPU cycles, usage of 53% were almost constant while thunderbird seems to be idling. That’s not the way.

It seems there’s a bug in thunderbird <= 17.05 (and perhaps in newer version also) that was causing this

It can be fixed by setting mail.db.idle_limit  to 30000000 iso 300000 

Be sure to check the number of zeros 🙂

You can get to that setting by going to edit > preferences > Advanced > Config editor and use the search box to find the option.

Syntax highlighting for Kivy kv language in pycharm


The nice folks on the Kivy ML have provided a kv language highlighting for Pycharm 🙂

For easy retrieval I just post the original announcement together with the settings file:

For anyone using PyCharm, please find attached a file type extension that give you full syntax highlighting for KV files. Courtesy of Xuton…;-)
To install:
On Pycharm’s main menu, click File -> Manage IDE Setting ->  Import settings

    Select this file, then it will come with a dialog with filetypes ticked. Just click ok or whatever and then its there.

You can get the file here:


Firefox with a dark desktop theme displays some parts incorrect


When you have a dark desktop theme firefox tends to displays some parts of websites like entryboxes not correct. They have for example a black background with a dark grey fontcolor.
That’s not the way to go.
To fix this you could add your own chrome ccs which will be used to display stuff correctly.
Here’s the file:
(The w7u1.default would be different on your system)
stas@HackSung:~$ cat .mozilla/firefox/w7u1.default/chrome/userContent.css
* Use this css file to eliminate problems in Firefox
* when using dark themes that create dark on dark
* input boxes, selection menus and buttons. Put this
* in the ../firefox/default/chrome folder or your
* individual user firefox profile chrome folder.
input {
border: 2px inset white;
background-color: white;
color: black;
-moz-appearance: none !important;
textarea {
border: 2px inset white;
background-color: white;
color: black;
-moz-appearance: none !important;
select {
border: 2px inset white;
background-color: white;
color: black;
-moz-appearance: none !important;
input[type=”checkbox”] {
border: 2px inset white ! important;
background-color: white ! important;
color: ThreeDFace ! important;
-moz-appearance: none !important;
*|*::-moz-radio {
background-color: white;
-moz-appearance: none !important;
input[type=”submit”] {
border: 2px outset white;
background-color: #eeeeee;
color: black;
-moz-appearance: none !important;
body {
background-color: white;
color: black;
display: block;
margin: 8px;
-moz-appearance: none !important;

Python xmlrpcserver with HTTPS support and basic authentication


For a project I’m working on at I needed a Python based multithreaded xmlrpcserver with HTTPS support, HTTP basic authentication and capable of running on any port. After looking into solutions which required some sort of server for the HTTPS and basic autentication parts I decided to go for a better solution to try to add the HTTPS support and basic authentication to the Python xmlrpsserver itself. That way we would have a simple and fast solution which could run from any box on any port. Looking around on the net I found various solutions for every requirement but nothing which combined it all into one solution. So after combining various bits and pieces I came up with a Python xmlrpcserver with HTTPS and basic authentication support.

As the code used came from various free-software projects and locations I decided to share the server with the world so that it might benefit others.

For the HTTPS you need OpenSSL certificates, use your existing PEM formatted one or just create one yourself.

$ openssl genrsa -out privkey.pem 2048
$ openssl req -new -key privkey.pem -out cert.csr
$ openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095

And here’s the server

from SocketServer import ThreadingMixIn, BaseServer
from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler, SimpleXMLRPCDispatcher
import socket
from OpenSSL import SSL
from base64 import b64decode

from threading import Thread, Condition
from thread import start_new_thread

import traceback
import time

# static stuff
DEFAULTKEYFILE = 'privkey.pem'  # Replace with your PEM formatted key file
DEFAULTCERTFILE = 'cacert.pem'  # Replace with your PEM formatted certificate file

class Services:
    def give_me_time(self):
        return time.asctime()

class CustomThreadingMixIn:
    """Mix-in class to handle each request in a new thread."""
    # Decides how threads will act upon termination of the main process
    daemon_threads = True

    def process_request_thread(self, request, client_address):
        """Same as in BaseServer but as a thread.
        In addition, exception handling is done here.
            self.finish_request(request, client_address)
        except (socket.error, SSL.SysCallError), why:
            print 'socket.error finishing request from "%s"; Error: %s' % (client_address, str(why))
            self.handle_error(request, client_address)

    def process_request(self, request, client_address):
        """Start a new thread to process the request."""
        t = Thread(target=self.process_request_thread, args=(request, client_address))
        if self.daemon_threads:

class MyXMLRPCServer(CustomThreadingMixIn, SimpleXMLRPCServer):
    def __init__(self, ip, port, keyFile=DEFAULTKEYFILE, certFile=DEFAULTCERTFILE, logRequests=True):
        self.logRequests = logRequests
        class VerifyingRequestHandler(SimpleXMLRPCRequestHandler):

            def setup(myself):
                myself.connection = myself.request
                myself.rfile = socket._fileobject(myself.request, "rb", myself.rbufsize)
                myself.wfile = socket._fileobject(myself.request, "wb", myself.wbufsize)

            def address_string(myself):
                "getting 'FQDN' from host seems to stall on some ip addresses, so... just (quickly!) return raw host address"
                host, port = myself.client_address
                #return socket.getfqdn(host)
                return host

            def do_POST(myself):
                """Handles the HTTPS POST request.
                It was copied out from and modified to shutdown the socket cleanly.
                    # get arguments
                    data =["content-length"]))
                    # In previous versions of SimpleXMLRPCServer, _dispatch
                    # could be overridden in this class, instead of in
                    # SimpleXMLRPCDispatcher. To maintain backwards compatibility,
                    # check to see if a subclass implements _dispatch and dispatch
                    # using that method if present.
                    response = myself.server._marshaled_dispatch(data, getattr(myself, '_dispatch', None))
                except Exception, info: # This should only happen if the module is buggy
                    print "ERROR do_POST: ", info
                    print "Traceback follows:", traceback.print_exc()

                    # internal error, report as HTTP server error
                    # got a valid XML RPC response
                    myself.send_header("Content-type", "text/xml")
                    myself.send_header("Content-length", str(len(response)))

                    # shut down the connection
                    myself.connection.shutdown() # Modified here!

            def do_GET(myself):
                """Handles the HTTP GET request.

                Interpret all HTTP GET requests as requests for server
                # Check that the path is legal
                if not myself.is_rpc_path_valid():

                response = myself.server.generate_html_documentation()
                myself.send_header("Content-type", "text/html")
                myself.send_header("Content-length", str(len(response)))

                # shut down the connection
                myself.connection.shutdown() # Modified here!

            def report_404(myself):
                # Report a 404 error
                response = 'No such page'
                myself.send_header("Content-type", "text/plain")
                myself.send_header("Content-length", str(len(response)))
                # shut down the connection
                myself.connection.shutdown() # Modified here!

            def parse_request(myself):
                if SimpleXMLRPCRequestHandler.parse_request(myself):
                    basic, foo, encoded = myself.headers.get('Authorization').partition(' ')
                    username, foo, password = b64decode(encoded).partition(':')
                    #print username, foo, password
                    if username == 'admin':
                        return True
                        myself.send_error(401, 'Authentication failed')
                        return False
        SimpleXMLRPCDispatcher.__init__(self, False, None)
        BaseServer.__init__(self, (ip, port), VerifyingRequestHandler)

        # SSL socket stuff
        ctx = SSL.Context(SSL.SSLv23_METHOD)
        self.socket = SSL.Connection(ctx, socket.socket(self.address_family, self.socket_type))

        self.funcs = {}

        # requests count and condition, to allow for keyboard quit via CTL-C
        self.requests = 0
        self.rCondition = Condition()

    def startup(self):
        #run until quit signaled from keyboard
        print 'server starting; hit CTRL-C to quit...'
        while True:
                start_new_thread(self.handle_request, ()) # we do this async, because handle_request blocks!
                while not self.requests:
                if self.requests:
                    self.requests -= 1
            except KeyboardInterrupt:
                print "quit signaled, i'm done."

    def get_request(self):
        request, client_address = self.socket.accept()
        self.requests += 1
        return (request, client_address)

    def listMethods(self):
        """return list of method names (strings)"""
        methodNames = self.funcs.keys()
        return methodNames

    def methodHelp(self, methodName):
        """method help"""
        if methodName in self.funcs:
            return self.funcs[methodName].__doc__
            raise Exception('method "%s" is not supported' % methodName)

if __name__ == '__main__':
    import sys
    if len(sys.argv) == 3:
        host = sys.argv[1]
        port = int(sys.argv[2])
        host = 'localhost'
        port = 8111

    server = MyXMLRPCServer(host, port, logRequests=True)
    # Run the server's main loop
    sa = server.socket.getsockname()
    print "Serving HTTPS on", sa[0], "port", sa[1]


For a client use someting like this

from xmlrpclib import ServerProxy

user = 'stas'
pas = 'stas'
p = ServerProxy('https://%s:%s@localhost:8111' % (user, pas))
print p.give_me_time()
Go to Top