This blog is now written in Markdown and synced with OwnCloud

Tags: English, technology, hacks
Created on Sat, 30 Jun 2018

This has been an idea that has been brewing in my mind for a while - create a simple blog that I can write from anywhere, using standard Markdown syntax. Here's the repo of the project.

The blog itself is a Flask webapp with sqlite database that has a BlogPost table. The trick is that the table is acutally synced with flat files in a folder. Each file is a blog post entry. The folder itself is synced by owncloud client which is running as a daemon (currently behind a tmux but will do it as a systemd service soon).

The key of the syncer is in the file. The sync is currently one-directional - when a file is created/updated/deleted, a blog post is created/updated/deleted. As an admin, you can CUD blog posts from the web interface but these are currently not synced to the file system.

So whenever I start writing a (non-hidden) file in that folder, the contents are created as a blog post. There is still work to be done to make this blog fully functional like perma-links for the blog entries, index, tags and uploading images (probably also synced) but for now it will do.

to be continued...

Google Duplex and the Struggle of the Moth

Tags: English, essays, life
Created on Thu, 10 May 2018

There is this one episode of the TV-Series LOST that I can’t seem to shake off my mind. It’s episode 7 of season 1 titled “The Moth”. I believe it’s one of the best hours of TV I have watched and the metaphor certainly comes to my mind quite often. One of the main characters (Locke) teaches another one (Charlie — who is struggling with withdrawal symptoms of heroin) that nature’s way of finding the best is through struggles. Locke demonstrates that by showing him a moth in its cocoon shortly before emerging from it. He says that he could help the moth — he has a knife and he can rip open the cocoon, helping the moth and letting him out. But the moth is not ready if it can’t break his own cocoon. The episode is worth watching as the two larger stories represented in the episode are also an expansion of the metaphor.

Google Duplex

I watched yesterday parts of the annual Google IO event where the tech giant presents what has it been doing for the past year and where it’s heading for the next one. This year they have revealed a lot of things around Machine Learning and lots of ways that it is going to interact with us. One of the most talked about ones is called Google Duplex.

The idea of Google Duplex is to tell your Google Assistant “OK Google, make a reservation for that restaurant” and Google will call the restaurant on the background and make the reservation for you. And it won’t be a person but a simulated voice. The technology shown in the demo is incredible — they went even so far as to incorporate “uhmms” and “aha-s” in the voice simulation at the right places as to sound more natural. If you haven’t heard it yet, have a listen on their recent blog post. I think for the first time I would give a pass on the Turing test — I heard the voice samples before reading the post, I assumed it’s some natural voice thing but I could not tell who is the robot and who is the person.

While I am absolutely amazed at the technological advances, the voice synthesis, the natural responses, the real-time answers, the handling of complex situations demonstrated — I have also been thinking a lot about technology from the ethical standpoint. There is no point probably of asking “Do we want that” as technology will move forward no matter our preferences — if it wasn’t Google this year, it would be Microsoft next or a green startup 3 years from now. In the large picture it wouldn’t really matter who came up with the technology, obviously it would happen. But can we really start talking about regulating it somehow? I am shaky on my opinions of whether AI will become smarter than us and not allow us to regulate it — good arguments on both sides, we will have to wait and see I guess. But for now, we can regulate it.

Why this one though? We have had natural sounding Siri-s, Alexa-s and Cortana-s for almost a decade now with vast improvements in the last 5 years. What is different about Google Duplex? Again, if you haven’t heard it, you must. It does not sound like the voices of your assistant. The feeling that at least I got is… well, let’s say there are some people I know that talk way more mechanically than the AI on the phone. The little nuances of “mhm”s go a long way.

Many questions popped into my mind and while reading news articles, comments on HN and reddit. Here are a few in a listicle way: * Wouldn’t agents mind receiving calls from bots? — As far as I understand many will actually prefer calls from bots — at least it will be a straightforward conversation and to the point without dealing with weird creepy people. * Will they know it’s bots? — They might learn some patterns. But now the other side learns too, it’s not a preset algorithm as good-old-programming. The bots are learning responses so a call this month might be different than a call last month. And the voice cover this up. But maybe people are still smarter and they figure it out, then… * Would I be bothered that the other side is a robot? — As in, if I understand the other side is something I can’t hurt the feelings of, because it doesn’t have feelings, I may be much more harsh and avoid social politenesses that we have built in our society. If at the same time I manage to guess bots from people but I have a failure false positives or false negatives, would that deteriorate our human conversations? * The bot now has a personality? — It’s not anymore straight out factual answers. Embedding uhms and politeness cues like Thank you and Goodbye gives that bot a personality. It could be overly polite or underly polite. Is the bot going to learn the English way of over excusing itself all the time or the harsher American way of straight to the point? What are the cultural implications — because Google is an American company, are all the cultures going to become slowly just one? * What if the agent is also a bot? — Google didn’t say or confirm if they provide the same service on the other side — a bot being the agent. It hinted it though and there is no reason it won’t provide the service next year. Then two bots will be talking in this highly inefficient human way? Will they send silent cues that they are bots and negotiate a more efficient protocol midway?

All these questions and pondering came to my mind just from this slight improvement in the voice output. But the one that I am mostly thinking about these days is the problem of the increasing social isolation due to technology. Bear with me.

Social isolation (?)

Google creates this Duplex service. How much time does it actually save? It won’t take more than 2–3 minutes to make a call or make an online reservation. Sure, it also lifts up some of the decision fatigue from the day and helps social anxiety types. But does it help them really?

Get back to the cocoon. We are getting more and more help from technology. At the same time the real-life interactions with people are becoming less and less. We IM and email more, we meet less. We swipe, like and look passively at photos, sending little yellow faces of emotions and we smile genuinely less. A phone call is in the middle of what I would call a real-life interaction and a fake interaction like chat. It does have real voice and it’s very instantaneous — unlike chat or email, you can’t spend much time re-thinking your response — it has to be almost immediate, thinking on the spot. You don’t see the person face to face so you also have to guess some of the social cues from the voice alone. This kind of interactions maybe helps us a little bit in keeping the humanity.

Why is this important — keeping the humanity? Well, because we see what happens when we avoid or deny our human nature thinking that technology solves it all. We isolate in our own bubbles, we go back to our cocoons and we stop fighting, stop having the struggle with real life. This makes us passive, goal-less, makes life meaningless, lonely and empty.

It’s not just Google Duplex that does this — far from it. But it’s one more step towards the fake interactions. Because the thing on the other side doesn’t feel offended, it is not hurt by my words, there is no risk of making a human being feel happy or sad and when I talk to bots and they don’t feel anything… I lose empathy. I lose the training of understanding social cues and feeling what the other person is feeling. I lose the struggle of figuring out what went wrong and trying to fix it. I stop evolving.

Of course this is an exaggeration. Yes, I am jumping to conclusions. Maybe I am wrong and this actually helps us get better with other people — use bots to train us out of human suffering. But the more I learn about technology and people, the more I experience the effects of how technology makes me lazy and complacent, the more cynical I become about the future. And I believe it’s healthy to have these sorts of conversations and queries because I think many people in technology are sometimes so driven to achieve the goal of progress that forget about the ethical implications. I am one of them.

If you like being a pirate...

Tags: English, technology, essays
Created on Wed, 09 May 2018

Keep on reading, I am not going to judge you - I (may) do this all the time. I just want to pose you an interesting question to think about…

Take a look (if you can and at your own risk) at the most seeded audiobooks on one of these sites where Johnny Depp might find himself if he was so inclined as to make an Internet movie 😉

At the time of writing (May 2018) titles include: * "12 Rules for life" [#1 with 396], * "Influence: The Psychology of Persuasion by Rober Cialdini" [#3 with 226] * "Be Obsessed or Be Average" [#4 with 175] * "Anthony Tony Robbins - Awaken The Giant Within" [#8 with 126] * "The Subtle Art of Not Giving a Fuck" [#9 with 125] * "The Millionaire Booklet" [#10 with 121] * "The Five Elements of Effective Thinking" [#14 with 103] * "No Excuses - The Power of Self-Discipline" [#15 with 93] * "You are a Badass" [#17 with 93] * "Maps of Meaning" (#1's author's previous book) [#19 with 91]

The unmentioned books include "Harry Potter book series 1-7", "The Art of War", "Sapiens - A brief History of Humankind" and other overall popular books and just popular novels at the time.

Take a look at Audible as well - the legal way to do these things - similar (4 of top 20 - the #1 12 Rules of life is 4th, the #9 - Subtle art… is 6th and there are two books by Mel Robbins - "5 second rule" and "kick ass" that are 11 and 17th) but not as much in the top 20s.

Now here is my question: Why so many self-help books? And why more in semi-legal sites?

This is far from scientific of course but here's my hypothesis. If you try to cheat life, now life cheats you. I am not saying this is karma or there is an all-judging being that makes you suffer because you pirated things. But let us explore it further.

Imagine you are the type of person that is likely to go on to the semi-legal sites to get their content. Audiobooks, movies, music, software. I can relate - I have gotten my free entertainment content over the years. On the software front I have switched to Linux as a free operating system about 10 years ago now but I used to have tons of CDs and DVDs with different versions of the glass operating system for years. I started feeling bad for it at some point that yes - it's not open source and privacy and all of that - but I couldn't and maybe can't exactly yet pinpoint the feeling why. Linux was harder to set up, many things didn't work out of the box and of course office software and games wouldn't work even close to what I was used to. But things got much better over the years and when I touch Windows now, I feel like a newbie. In the span of 10 years when I had to move permanently out of home I left my parents with Linux because I didn't want to deal with viruses every time I come home or not be able to call them some weekend. And they don't even know - they have a browser, it works.

I feel much better now using free software but again - I can't exactly pinpoint the main reason. Also, I became a programmer and understand more the value of the work but it's not just that. And it's not privacy (I think). It's a feeling of being free.

Now, I am not there yet with my entertainment although I try by getting a Netflix subscription and buying some of the songs I really enjoy.

Back to the original question: why so many self-help books in these provide-for-free sites? Well, if there is a person who is likely to cheat on society and tries to hack life by acquiring things for free when one should pay - well, I would bet this is a person who is likely to cheat in other ways as well. Did I jump to conclusions about cheating on society? You know you are - you can rationalize that it's a copy, you are not stealing because you are leaving the original - but c'mon, you know this is not the way the author wanted you to listen or watch their creation. Some do - there are artists who upload their creations for free to get exposure. But not everyone needs more exposure or are getting it by getting content from Captain Jack Sparrow's sites.

So how are you likely to cheat in life and why this is bad? Sure, it feels good in the short term - maybe you get delicious food like hamburgers and pizza that you know are nutritiously bad for you in the same way movies are - you are not even cheating, you are paying for your food! But you are paying for food that will not satiate you in the long run and you know from experience that these stuffed carbs and sat fat will turn to your belly. But it's quick and relatively cheap and boy - it's delicious! Who has the time to cook or eat boring greens…

Or maybe instead of going the hard way to find authentic human connections you go to porn sites. Or facebook. Or instagram. They are in the same category really in this case. Why? None of them are real for your primal brain. You scroll, or you fap, you like, or heart, you send yellow pictures of crying laughter but really - your face is static. Sometimes when I chat with people I find there is an enormous inflation of yellow faces - as if they are trying to compensate the real feelings that are just a blip in our souls but rarely really experienced. But it's hard to get real people especially in real life! In school or Uni maybe it's easier - at least you have your subject group of people and societies that people hang out at. But real life, boy - colleagues are in so different age groups that as a 20-something boy or girl you barely have anything in common. And going to meetups after work and maintaining relationships in real life takes way too much time. Meeting with one person can take hours! At the same time you could be chatting with 10 different people, "catching up" or sending cat photos (or these weird dog-photos embedded within a human face with enlarged eyes… what the fuck is that?!?!... I know, I'm getting old) and pretending that these are real conversations. Instead of building up a relationship for months or years, you open the black channel, jack off in 5 minutes and you are good to go with the rest of your day. No need to invest time in people, they take too much time and they can hurt.

And this way you cheat life. And you cheat yourself. In the short term it's good. But in the long run you feel lonely, empty, fat, tired and angry at yourself for procrastinating on everything. You know technology is not always the right answer, you've heard it, you've heard that it violates your privacy but c'mon - you are not a terrorist, you don't talk about bombs in your chats - who could be that stupid?! You are fine being tracked by tons of huge corporations - who cares, everybody is tracked. And guess what - advertisements are more relevant this way so it gives me better recommendations. (Note: I don't know if people actually say or rationalize that way, I am not convinced anybody finds ads useful, but let's say some might like them if they are more relevant for the sake of argument).

So okay, you don't care about being tracked if you are getting free services for that - free search, free chat, free email, free music, free videos, free operating systems, free file sharing… But guess what - somebody, somewhere pays for literal physical machines - and LOADS of them - in huge data centers that take the electricity of small or sometimes large town that serves millions and even billions of people like you. Also, artists need to pay their rent and food - but they are on YouTube and getting billions of views. And they do it for free? Because of the good of their hearts? Or wait - you pay for the Internet, right? These 20-30 something money pays for this, right? This pays mostly just for the cables from your local town Internet Service Provider to your house. You pay for the above mentioned services with your time and attention to advertisers who sell you things or try to lead you subconsciously to their sites, to get a few more clicks, a few more time spent.

You know that already? Am I boring you? Am I wasting your time? So why are you looking for self-help books? What is so wrong in your life that even though you know you need help, you turn to self-help? I am not talking to you anymore, dear reader, in fact I am talking more to myself now, but if you feel it's relevant to you, join me in my questionings.

You are conditioned to cheat life. Like the broken window theory, once you start cheating and grabbing things for free that you know shouldn't be and can't be really free - at least in our economy - you start cheating yourself. And you don't necessarily understand that in all the nuances and layers of complexity that your conscious and subconscious brain presents. What you feel as loneliness, angriness at society, meaninglessness of life - I argue here - is partly as a result of your hacks. You try so much to be self-sufficient and independent at life, maybe because you got hurt by real people, or maybe because the media presents you with the image of successful independent people - that you now crave help because you know you need it badly.

But you ain't gonna reach to a friend for a deep, real, emotional conversation which will open your mind and soul with all the power of all emotions you have - you haven't done that in years. Instead, you are going to get a self-help book which as yet another cheat, you are going to try to talk to yourself the meaning of life. To try to self-motivate, self-inspire. Not spend time in silence and inner exploration - that is just such a waste of time! And on top of that you are going to get it for FREE! Because who wants to pay for generic advice of "Just be happy! Just do it! Life is hard! Here is the ONE trick, the ONE method, the ONE cheat that will move you forward and make you happy again". And you will consume that and love it for a few days and then, like the cheeseburger, you will crave another one. And then another one, searching for this nirvana that with the right mood, the right incantations of self-talk that will rewire your brain while you sleep, listening to self-aspirations and saying them over and over that "you are beautiful", "you have everything and you can do anything", "you are confident, outgoing and a force to be reckoned with". But somehow, few nights later, you will be lonely again. Few days later, you will question the meaning of it all. Few scrolls later, you will envy all the friends that travel to all the beautiful destinations and you are stuck in your stupid apartment with shitty, meaningless job that probably contributes to the end of humanity in some way. Because you are conditioned to this, to the fakery, to cheating instead of investing real time in things that matter, you cheat life, and you cheat yourself.

So sure. Get this post for free - I can't possibly stop it. In fact, I have in fact for free on services that I don't pay for with real money - Blogger and Medium. It's the struggle that I still have and yes, I want to eventually pay for my server and host it by myself. I am not there yet. I am not preaching, and trying not to judge - I am as "corrupted" in the above manner as the next person. And even if I manage to one day sell this post for real money and embed it in a book or something - I will have no moral way of even judging you as I have done the same countless times and in times of weakness, I know that I will do it again. But please, think about the above and try to disagree with me. Try to rationalize it or find the holes in my arguments. I could be wrong, but I feel there must be some truth in it.

Ode to professionals

Tags: English, technology, essays
Created on Thu, 19 Apr 2018

A professional doesn't dress well to impress and fake his professionalism. He dresses well to feel professional.

A professional is not hack-y, quick or dirty. He is a thorough and precise.

A professional is not arrogant or know-it-all. He works together with his colleagues, learns from them and helps them.

A professional understands planned work, unplanned work and plans for the unplanned work.

A professional takes responsibility but never blames.

A professional always learns.

A professional uses the right tool for the job. Not the one that is most hyped at the moment, nor the one he is just most familiar with but too complex or too simple for this job.

A professional understands his human limitations. Thus he never overworks to show off or mistreats the rest of his life for his craft.

A professional always tells the truth, voices his opinions where they are relevant to the work and protects his craft and his colleagues.

A professional understands or tries to understand to the best of his abilities the risks and tradeoffs of choosing one solution over another in the broader context of the work being done.

Auto adapting signal to day-night scheme

Tags: English, hacks
Created on Mon, 02 Apr 2018

So I wanted to automatically change the day/night theme of my brand new Signal desktop app. The way that it is manually done is through the File -> Preferences... menu. Now that's not convinient for programatic person like me. Let's investigate!

.config folder

My first stab is looking into the mostly standard ~/.config folder in Linux for Signal if one actually exists. It turns out it does. Let's see. It even has a ~/.config/Signal/config.json file. Unfortunately, that file doesn't contain the settings for the theme, just window positions.

grep -ring in the folder for any of android or theme just returns the logfile that Signal is writing to.

./logs/log.log.1:{..."theme-setting changed to android-dark",...}

No luck.

Another stab is at /opt/Signal directory. Again - no luck. And the app is a binary ELF executable

$ file signal-desktop 
signal-desktop: ELF 64-bit LSB executable,...


My next attempt is to attach to attach to the Signal process via strace. Find the process by ps aux|grep signal, attach by strace -p <pid> and try to change the . Boy, this does a lot of stuff! Let's filter by writing:

strace -e write -p 12345

Still, too much but I saw something hapenning amid the writing to 40 and 71 file descriptors (fd).

write(40, "!", 1)                       = 1
write(71, "\0", 1)                      = 1
write(40, "!", 1)                       = 1
write(1, "{\"name\":\"log\",\"hostname\":\"pi2-ho"..., 147) = 147
write(12, "\1\0\0\0\0\0\0\0", 8)        = 8
write(71, "\0", 1)                      = 1
write(40, "!", 1)                       = 1

All right, the 1 fd is the log that is being written that I already saw. How about that 12 fd? Let's explore within the proc fs:

$ cd /proc/1234/fd
$ ls -la
# ...
lrwx------ 1 pi2 pi2 64 Mar 29 23:23 12 -> anon_inode:[eventfd]
# ...

Oh boy, some wierd anonymous inode. So we are definately not dealing with a good old filesystem file but rather some on the fly created fd. Let's explore a bit more...

Signal is an Electron app

Taking a look at the github repo of the project. Searching for dark and theme reveals css, sass files. Okay

Looking at the menus there is View -> Toggle Developer Tools and BAM - a good old Chrome developer tools console pops up! Inspecting the elements, it's pretty clear what is happening:

<body class="android">
<!-- changes to -->
<body class="android-dark">

Brilliant, the change of theme just changes the class on the body element. Let's see if we have jquery or I have to go to the dark ages of javascript's findElementByTagName:

> $
< function ( selector, context ) {
        // The jQuery object is actually just the init constructor 'enhanced' ...

Good, we have. Now I "just" have to find a way to connect to chrome console via a good old terminal in some way...

Chrome remote debugging

Searching the Internets, I find a post in Chromium blog from way back in 2011 that I can run Chrome with --remote-debugging-port flag which enables some sort of a remote console.

Would the electron app do the same?

signal-desktop --remote-debugging-port=9222

Indeed it does. This console however is not just a simple tcp connection to the javascript console. Running echo "alert('echo'); | netcat localhost 9222 does nothing. More reading to go...

Turns out, Chrome DevTools has its own protocol that among other things exposes websockets. Let's see what clients exist for that

Quite a lot.

Any pythonic ones? pychrome seems simple enough.

Let's be modern, do python3:

pip3 install pychrome

And I will use my favourite repl, ipython and follow the Getting started tutorial:

import pychrome

browser = pychrome.Browser(url="")

Awesome, I have a connection. The tutorial goes into opening a tab. I don't want that, I assume I should alread have a tab. Exploring browser object (via my favourite ipython repl):

In [3]: dir(browser)
Out[3]: [... _private_stuff

In [4]: browser.list_tab()
Out[4]: [<Tab [38473d8e-ad8d-4325-8cb6-81aaec36c124]>]

In [5]: tab = browser.list_tab()[0]

In [6]: dir(tab)
Out[6]: [... _private_stuff

The README goes into navigating pages and the examples folder is also not what I am looking for. But they do tell me call_method is probably what I want, just need to find the proper string and parameters in the protocl. I want to execute a javascript call.

Back to the Chrome DevTools Protocol Viewer. I look through a few of the Domains listed and finally arrive at Runtime.evaluate method.

In [7]: tab.start()
In [8]: tab.call_method('Runtime.evaluate', expression='alert("hi");')
Out[8]: {'result': {'type': 'undefined'}}

Finally! I have access to my javascript console in the browser! Let's write the jquery change of theme:

tab.call_method('Runtime.evaluate', expression='$("body").removeClass("android").addClass("android-dark");')

That worked!

Wrapping it up

Let's write a propper python script now:

#!/usr/bin/env python3

import sys
import pychrome

sys_argv = sys.argv

if len(sys_argv) < 2:
    print("first argument needs to be day|night")  

command = sys_argv[1]

if command == "night":
    expression = js_dark_to_light = """
elif command == "day":
    expression = js_light_to_dark = """
    print("first argument needs to be day|night")

browser = pychrome.Browser(url="")
tab = browser.list_tab()[0]

tab.call_method('Runtime.evaluate', expression=expression)


Running ./ day changes to white theme and ./ night goes to dark theme.

I also want to change the signal-desktop app to always start with the remote-debug flag enabled, so I do that:

rm /usr/local/bin/signal-desktop
cat > /usr/local/bin/signal-desktop << EOF
/opt/Signal/signal-desktop --remote-debugging-port=9222
chmod +x /usr/local/bin/signal-desktop

And that's it. Code can be found in my sun repo which also deals with other day-night related dark-light themes including a script to detect whether the sun has set or not:

$ ./ 
usage: calc --loc=location_name [--date-format] 
       calc --lat=latitude --lon=longitude [--tz|--date-format]
       current_time sunrise sunset day|night

$ ./ --lat=51.21 --lon=4.40 --tz=Europe/Brussels
23:57 07:23 20:10 night

So now I can chain that:

state=`./ | cut -f4 -d' '`
./ $state

Voala! That was fun 🙂😊