Build a memory graph in linux terminal

Created on 20180711

I was searching for a terminal based graph of usage of memory but I couldn't find one, so I built it using simple bash and python.

First create a directory called mem and enter it with cd mem

Then run the daemon part of the monitor:

while true; do free -m | head -2 | tail -1 | awk '{print $3}' > `date +'%Y-%m-%dT%H:%M:%S%z'`; sleep 1; done

To actually build the graph, use this:

watch -n1 'for f in `ls -r | head -30`; do num=`cat $f`; python -c "print(\"{} {}\".format(\"$f: $num\", \".\" * ($num/10)))"; done'

And the result is something like this:

2018-07-11T11:26:36+0000: 330 .................................
2018-07-11T11:26:35+0000: 316 ...............................
2018-07-11T11:26:34+0000: 285 ............................
2018-07-11T11:26:33+0000: 236 .......................
2018-07-11T11:26:32+0000: 235 .......................
2018-07-11T11:26:31+0000: 236 .......................
2018-07-11T11:26:30+0000: 236 .......................
2018-07-11T11:26:29+0000: 238 .......................
2018-07-11T11:26:28+0000: 236 .......................
2018-07-11T11:26:27+0000: 236 .......................
2018-07-11T11:26:26+0000: 240 ........................
2018-07-11T11:26:25+0000: 236 .......................
2018-07-11T11:26:24+0000: 236 .......................
2018-07-11T11:26:23+0000: 236 .......................
2018-07-11T11:26:22+0000: 239 .......................
2018-07-11T11:26:21+0000: 236 .......................
2018-07-11T11:26:20+0000: 343 ..................................
2018-07-11T11:26:19+0000: 330 .................................
2018-07-11T11:26:18+0000: 327 ................................
2018-07-11T11:26:17+0000: 313 ...............................
2018-07-11T11:26:16+0000: 287 ............................
2018-07-11T11:26:15+0000: 238 .......................
2018-07-11T11:26:14+0000: 236 .......................
2018-07-11T11:26:13+0000: 236 .......................
2018-07-11T11:26:12+0000: 237 .......................
2018-07-11T11:26:11+0000: 236 .......................
2018-07-11T11:26:10+0000: 236 .......................
2018-07-11T11:26:09+0000: 236 .......................
2018-07-11T11:26:08+0000: 240 ........................
2018-07-11T11:26:07+0000: 237 .......................

On the difficulty of trying again

Created on 20180702

Chess

I don't even know how I ended up here. Something - was it an article, or a video - but something prompted me to watch some comentary on the chess matches between AlphaZero vs Stockfish. AlphaZero is Google's/Alphabet's AI machine - both the software of deep learning and through their proprietary TPUs hardware. Stockfish is (was) the best chess computer program in the world. Now, ever since 1997 match between the then world champion Garry Kasparov and Deep Blue, playing chess against computers has been useless in terms of actually beating them.

It's of course because computers are not like people - once you create great software, you can copy it, distribute it and improve it - even if it's illegal or whatever, you can do it if you want to. Humans not so much - once a human dies the best way he can (so far) transfer the knowledge of his lifetime experience is through the slow, inneficient and incomplete multi-level interface of brain-words-mouth-air-ear-words-brain. Or similar path in writing. And errors occur on each interface - your thoughts and emotions are transcribed imperfectly with words, the brains on the two sides understand words in a different way and then transcribing them back into similar feelings is difficult. We call this empathy. Something like json.dumps(yaml.loads('{}')) - it may work perfectly sometimes but most of the time it's impossible to get the same message.

Through thousands of generations of painful trial and error we were able to invent science, engineering and machines that are now beating us in some areas. And as argued above, once computers are able to beat us, they will always be able to beat us - because they can copy their collective knowledge. If I have a child, there is no way to transfer all the human knowledge that has been acquired. A tiny fraction takes a lifetime. A tiny, tiny, tiny fraction. How tiny? Play a game - go and click on wikipedia's random article page. Do this a hundred times. Give yourself a point if you have even heard anything about the title. Give yourself two points if you know what the title means. Three if you can say anything other than the description. Five if you consider yourself knowing quite a bit about it. You may score 10-15 points if you are lucky. Generally, you would score around 5. And the amount of articles on wikipedia are still imaginable - in the English wikipedia it's around 5.5 million.

Okay, back on point - chess and AI. Even though it's now meaningless to play chess against computers, people still enjoy analyzing the games between people and machines and between machines themselves. It's an unsolved game - as in it's unknown whether there is a perfect strategy to always win as in much smaller games like Tic-Tac-Toe. And most probably we will never actually solve it in the mathematical way. The only thing which we can do is optimize solutions by trial and error. So far, the trial and error has been inspired by the human grandmasters and the experience that they have gathered through hundreds of years of playing chess, recording and analyzing the games. Through fine tuning parameters of the pieces values, converting chess positions into numbers of advantage for one side versus another, analyzing the possible moves on each move and iterating deeply through a almost brute force (but pruned brute force) search trees of min-max algorithm and doing that quickly on a fast hardware - we were able to beat humans. Computers don't feel emotions, don't get caught in the moment yada-yada.

AlphaZero is a new category.

Why? Well, for one, according to the paper AlphaZero had not had the advantages of these hundreds of years and collective - hundreds of thousands of years - of playing chess vs the grandmasters and fine tuned parameters and optimized search trees. But it had the advantage of playing versus different versions of itself for the equivalent of hundreds of thousands of human years.

Yup. It had only tabula rasa of the chess rules as you would teach a beginner. No "develop a strong center in the beginning", "castle early" not even "keep material advantage up". It was up to itself to figure that out. Basically the idea as I undrestand it now is this (I am still to enter the "Machine learning" thing, so I'm simplifying because I don't know more yet) - develop a basic understanding of the rules and a neural network that assigns weights - initially random - to decisions based on outcome of win/draw/lose in old fashioned code. Then copy yourself with a few slightly tweaked weights. And then play the two versions against each other a hundred times. The one that wins survives and saves these weights. A new copy is developed with slightly tweaked parameters and played against the winner. And so on for millions and millions of games until there is this one version which you actually want to present as a competition. Brute forced trial and error.

As I watched some of the interviews commenting on AlphaZero with the grandmasters of old - Gary Kasparov, Anatoly Karpov, Viswanathan Anand - they were quite amazed at the games the machine played, citing "alien" play. Of course it's alien, we haven't seen intelligence greater than human (so far). By definition, it's alien. And again remember - it played against not a mere mortal human, but the best computer program as of before. Sometimes it would completely sacrifice "common rules" like material advantage for positional, or play lines that the Stockfish would see as errors but later, Stockfish would reconciliate in it's analysis and see it as winning indeed. As a child, I remember being fascinated by chess and the chessmasters, I considered them with unhuman brains, able to think so much better than average Joe, that they see things which we can't see. Now I feel they are pretty much average Joe or me, looking at the machines in the same way.

The bigger picture

I feel curiosity and complete awe but more interestingly - resistance - when learning about these advancements. What I gather from this is that the best way for something to be the best in whatever it's doing is by continuous trial and error. Humans are not the best subjects at that. We feel pain when we lose. Sometimes the pain is too big to move on. Do computers feel that when you give them -1 point when they lose a game? "Don't be silly, computers don't feel!". And probably that's why they can learn so quickly and not "fall into depression". Or maybe, computer depressions are when a neural network goes so bad that instead of improving itself, it enters somehow a negative feedback cycle - is that even possible? I don't know, but I am curious to learn.

I went on a run after these videos and started thinking about the implications of this. Here it is - a machine trained for about 4 hours from scratch learned to beat the best of the best in a small domain like chess. It learned by continuous trial, tweak, play, lose, adapt, try again. It beat the "learn from history". It was able to "live" thousands of generations of human lives completely dedicated to chess. In four hours. Or ten - doesn't matter, in a very small amount of time compared to human lives. This is what exponential means. When you look at the great history of the Universe, life and human development (recently read Sapiens) - it's all an exponent. It took a very long time to develop single-celled life, then a very long-time to devleop multicellular life but then compared to that everything else is an explosion. Watch this video which is the development of the Universe squashed into 10 minutes. It takes until 1 minute until the end for multicellular life to appear, and then everything happens in the last minute - marine life, plants, trees, lizards, dinosaurs. Primates are in the last 2 seconds, humans - in a blip of the last second. Scale the whole human history into that 10 minute video, computers will be on the last bleep in the same way.

And then chess is the same way. Hundreds or thousands of years of play. Versus 4 hours of training of a machine.

The philosophy

It's difficult for humans to fail. It feels painful and if it happens too many times, you avoid failure.

But failure is the best way to learn. Think of it this way...

What if it wasn't millions of neural networks failures to discover chess. What if the neural networks could live your life a million times. Each time trying something a little different, not caring if it loses or dies sometimes. What would be your checkmate? What would be the best version of yourself if failing wasn't painful?

What if you anticipated pain but didn't care?

Humans avoid pain and seek pleasure. But what if you anticipated the pain, accept it as an iteration and knew that this is the best way to learn proven by millions of generations of a computer program.

Food for thought...

This blog is now written in Markdown and synced with OwnCloud

Created on 20180630

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 flatfile_syncer.py 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

Created on 20180510

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...

Created on 20180509

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.