Milo CasagrandeCoding Adventures in Life2016-03-18T17:30:55Zhttps://www.milo.name/feed/atom/WordPressMilo Casagrandehttp://www.milo.namehttp://www.milo.name/?p=6382016-03-15T17:36:51Z2016-03-18T17:30:55ZLinks to articles not necessarily written today, but still interesting. The two y-axes problem: never use them, really… Why would one even think of using them? How D3.js works: getting started, in the right way, with D3.js. What it means to be an open-source leader: nailed it. Estonia e-residents: the digital nation, what a single … Continue reading Links of the Day – 2016-03-18

]]>0Milo Casagrandehttp://www.milo.namehttp://www.milo.name/?p=6282016-02-29T15:22:44Z2016-02-29T18:20:09ZLinks to articles not necessarily written today, but still interesting. Linux Performance Analysis in 60 Seconds: What to do in 60 seconds to understand what is going on with a Linux server. What we Talk About Distributed Systems: Minimum knowledge you need to have to sustain some sort of discussion on distributed systems. On the … Continue reading Links of the Day – 2016-02-29

]]>0Milo Casagrandehttp://www.milo.namehttp://www.milo.name/?p=6162015-12-13T12:53:04Z2015-12-13T15:00:36ZLinks to articles not necessarily written today, but still interesting. The Cost of Frameworks: Vanilla JavaScript is still faster. Let’s Earn the Right to be Called Engineers: A follow-up/response to the “do not call yourself engineer” discussion. Although I didn’t agree with all the points raised in the original post, there are valid points on … Continue reading Links of the Day – 2015-12-13

Let’s Earn the Right to be Called Engineers: A follow-up/response to the “do not call yourself engineer” discussion. Although I didn’t agree with all the points raised in the original post, there are valid points on both sides.

]]>0Milo Casagrandehttp://www.milo.namehttp://www.milo.name/?p=6052015-11-22T13:16:17Z2015-11-22T15:10:24ZLinks to articles not necessarily written today, but still interesting. Reconsider: “Part of the problem seems to be that nobody these days is content to merely put their dent in the universe. No, they have to fucking own the universe.“. Nice read on startups, VC, investors and the overall “startup philosophy”. Startup Playbook: Again startup, … Continue reading Links of the Day – 2015-11-22

]]>Links to articles not necessarily written today, but still interesting.

Reconsider: “Part of the problem seems to be that nobody these days is content to merely put their dent in the universe. No, they have to fucking own the universe.“. Nice read on startups, VC, investors and the overall “startup philosophy”.

]]>0Milo Casagrandehttp://www.milo.namehttp://www.milo.name/?p=5692015-03-02T08:01:59Z2015-03-08T08:01:15ZThis is more of a “write here so I do not forget” kind of post. I set out trying to make a simple “maintenance” mode for a REST API (that speaks only JSON) without having to handle it in the code base. nginx has a really cool support for maintenance mode that is dead easy … Continue reading Make nginx Return a JSON Response

I set out trying to make a simple “maintenance” mode for a REST API (that speaks only JSON) without having to handle it in the code base.

nginx has a really cool support for maintenance mode that is dead easy to set up:

if (-f $document_root/maintenance.html) {
return 503;
}

Obviously, life is not that easy.
In my case, the same URL is used to show static content (the API docs) and only sub-dirs in the URL are used for the API resources:

api.example.net
api.example.net/resource1
api.example.net/resource2

I already handle the API resource definitions in nginx, and I only need to override the root maintenance definition. In addition, the JSON response should also have the correct Content-Type header set.

In this case, is probably “easier done than said”, and is all done in here:

]]>1Milo Casagrandehttp://www.milo.namehttp://www.milo.name/?p=5792015-03-01T17:32:30Z2015-03-01T14:47:13ZDisclaimer: I received a free a copy of “How Linux Works 2nd Edition” to review from NoStarch Press. I enjoy doing these occasional reviews: it’s a good excuse to read a new book, learn something new (there’s always something to learn, every day) and to move my eyes aways from a light emitting digital device … Continue reading Book Review: How Linux Works

I enjoy doing these occasional reviews: it’s a good excuse to read a new book, learn something new (there’s always something to learn, every day) and to move my eyes aways from a light emitting digital device (yeah, apart from when I actually write the review…). And since I fully read the books, that’s why usually it takes some time to review them all.

I have to admit I love NoStarch books: lovely cover arts, a nice book form factor, well written and edited content, multiple formats to choose from (paper, digital DRM-free versions). And “How Linux Works” is no less.

The Review: How Linux Works by Brian Ward

17 chapters strong, the book opens with a general overview of a Linux system providing the reader with a really clean explanation of the differences between the kernel space and the user space, moving to a quick overview of the shell system.

From Chapter 3, the pace changes, and it’s here where the author starts diving into into the real Linux system. Devices, device types, sysfs and how they are implemented at the kernel level are an introduction to concepts that will be taken further in Chapter 4, where file systems, a generic overview on how they fit into the kernel, and the most used and common commands to work with partitions, are introduced.

I consider Chapter 5 and Chapter 6 to be the strength of the book: how the Linux boot process works, what GRUB is, does and how to configure it, all clearly explained with detailed steps of the overall boot process. And then, as a natural consequence after the boot phase, the init systems are introduced and the reader is taken further into the user space land.

Chapter 6 covers basically everything that is needed nowadays to understand the init process: systemd, upstart and sys-v are all explained in their glory details (although the latter is the less detailed): how they are configured, where their configurations are located and the different terminologies each adopts are easy to understand.

From here on, the book covers all that is necessary: logging, users, /etc and login methods with a focus on PAM (Chapter 7); processes, resources, CPU & I/O and all the commands to help you in performance diagnosis (Chapter 8); network, network configuration, a concise but exhaustive introduction to the network layers, the kernel routing table and internet/network user space applications (Chapter 9, 10).

Chapter 11 takes us back to the shell with an extensive coverage of its most useful and used commands, that will lead as to know all the file sharing programs available at our fingertips (Chapter 12).

Of all the book, I found these last chapters (counting also Chapter 12) to be the less interesting: probably because most of the concepts described were already known, or they were covering not (that) much interesting subjects to me.

In the End…

The book is really well organized, technically accurate and up-to-date with the recent modern Linux technologies. A really great Linux power-user book that doesn’t spend too much time in a graphical environment, but concentrates on command line tools and the depths of how a Linux system is glued together. Read it if you want to expand and deepen your Linux knowledge.

]]>2Milo Casagrandehttp://www.milo.namehttp://www.milo.name/?p=4472013-01-29T08:35:47Z2013-01-29T08:30:36ZFinally, after some delays, Linaro Image Tools now has support for Android hardware pack (or Android hwpack). What is an Android hwpack Let’s start with with clearing out the confusion the term “hwpack” has in this context. Generally speaking, for Linaro Image Tools an hwpack is a tar-ball that contains Debian packages, some configuration and metadata files, … Continue reading New Feature for Linaro Image Tools: Android Hwpack

What is an Android hwpack

Let’s start with with clearing out the confusion the term “hwpack” has in this context.

Generally speaking, for Linaro Image Tools an hwpack is a tar-ball that contains Debian packages, some configuration and metadata files, and some directory structures, needed to create and install bootable operating system images.

Linaro Image Tools has had support for this kind hwpack since the beginning of time, but they are not necessary to create Android bootable images. The process to create an Android image is slightly different.

This new hwpack, the Android hwpack, is just a configuration file, based on the same syntax of previous Linaro Image Tools hwpack, that stores information necessary to correctly create Android images. An Android hwpack does not contain any Debian packages nor binary blob or anything else, it is just a text file (a YAML file for instance).

It’s probably better to call is “Android configuration file“.

Why an Android hwpack

The necessity for this came out during last Linaro Connect Europe, from the Android team. The needs were an easy way to add support for new boards (without having to hack into Linaro Image Tools code), the possibility to change board parameters (almost) “on-the-fly” for testing (without having to touch code), and the possibility to maintain backward compatibility by providing some kind of “versioned” hwpack, guaranteed to work for specific Linaro releases.

How to use it

In order to use it, you need to have at least Linaro Image Tools version 2013.01. At the time of this writing, Android hwpack support is also being built into the Android boot tarball, so it should be totally transparent for the user: no need to add command line arguments and to pass file paths.

Still, it is possible to pass an Android hwpack to Linaro Android Media Create, the command line tools that creates Android bootable images. The command line argument is the same as Linaro Media Create one: –hwpack

So, if you want to use the new feature, arm yourself with an Android hwpack file (examples can be found on GitHub), and run:

]]>1Milo Casagrandehttp://www.milo.namehttp://www.milo.name/?p=5152013-01-22T11:00:19Z2013-01-22T10:57:33ZThis is that kind of post that are more necessary to me for remembering than anything else. Lots of digital ink has already been spent on this topic, but, as others I guess, I find that writing down things helps me remembering them (and mind-maps are precious on that front). VirtualBox Clone Operation I have … Continue reading Fixing Network Errors in VirtualBox

]]>This is that kind of post that are more necessary to me for remembering than anything else. Lots of digital ink has already been spent on this topic, but, as others I guess, I find that writing down things helps me remembering them (and mind-maps are precious on that front).

VirtualBox Clone Operation

I have a couple of local virtual machines installation for Ubuntu desktop and Ubuntu server, usually the latest LTS ones, and I clone them as I needed: I need to test some scripts, or the installation of a program, like it was being performed on a real installation.

VirtualBox has this nice little feature of creating clones of your virtual machines, and in no time you are up an running with a clean environment (as long as you remembered to take a snapshots at a good point in time).

The Error

When you clone a virtual machine, you are cloning everything of it, configurations included. And that’s where the problem is. The network will not work at all, and ifconfig will tell you that there is no interface configured.

The Solution

The solutions lies in one file:

/etc/udev/rules.d/70-persistent-net.rules

Open that file with your editor, remove the offending line and reboot.

In this case the offending line is an erroneous “eth*” interface, that will results in multiple network entries in that file when just one is needed. Pay attention to the MAC address of the network interface though.

]]>0Milo Casagrandehttp://www.milo.namehttp://www.milo.name/?p=4412013-01-17T17:16:17Z2013-01-17T17:15:48ZThis is my first attempt at writing a book review, so bare with me if it is not the best around. And here the “usual” disclaimer: I received a free copy of “Think Like a Programmer” from NoStarch Press. The book: Think Like a Programmer an Itroduction to Creative Problem Solving As the titles goes, … Continue reading Book Review: Think Like a Programmer

]]>This is my first attempt at writing a book review, so bare with me if it is not the best around. And here the “usual” disclaimer: I received a free copy of “Think Like a Programmer” from NoStarch Press.

The book: Think Like a Programmer an Itroduction to Creative Problem Solving

Think Like a Programmer book cover.

As the titles goes, this is not only a book about programming or development, it is an exercise on problem solving and thinking. The book has one of the best starts I could imagine: puzzles. Funny puzzles, those that nowadays scare candidates during the hiring processes at big companies.

The puzzle-pace is kept for the first two chapters, and the author guides you into well detailed examples of problem solving: how to break a problem into smaller parts, how to apply your knowledge to unknown problems, where and how to recognize patterns.

After these two introductory chapters, things start to get serious. Complex concepts are introduced: arrays, pointers, classes, dynamic memory… and the problems accompanying them resemble real-life ones. To fully grok these sections, a good knowledge of C++ is needed. The author introduces each new topic with the basic needed coding knowledges, but if you do not have any previous C or C++ skills at all, the examples and the exercises might be daunting.

The book is broken into 8 chapters and you can perceive the complexity increasing up to a peak in the middle ones. The last two chapters are less demanding and the concepts introduced are not tied to any particular programming language: they step into the realm of software engineering, code reuse and something I would refer to as task management.

In the End…

It is not meant to be a cookbook, nor something you can use as a reference manual. You have to embark yourself , and let the author sail you through a journey of discoveries, learning and problem solving, being patient and going through the proposed exercises. It is a training for your brain, for your code writing-fu, and mostly for how to approach problems and how to tackle them.

]]>3Milo Casagrandehttp://www.milo.namehttp://www.milo.name/?p=4882013-01-13T18:32:27Z2013-01-13T17:15:21ZBeing overwhelmed by passwords, for all the disparate websites you have to login to, plus trying to keep safe password for personal and work activities without sharing the same ones, was starting to get harder. Too many websites, to much passwords. The Last Password to Remember As a colleague of mine suggested, I tried out … Continue reading The Last Password

]]>Being overwhelmed by passwords, for all the disparate websites you have to login to, plus trying to keep safe password for personal and work activities without sharing the same ones, was starting to get harder. Too many websites, to much passwords.

The Last Password to Remember

As a colleague of mine suggested, I tried out LastPass. A nicely done online services that offers you the possibility to have a secure password vault where to store your passwords and identities. LastPass integrates also with your browser and helps you:

Filling out forms: you can store all your credentials and credit card info too

Logging into the stored web sites, also automatically if you tell it so

Creating one time and secure passwords

Updating the passwords when it detects you are changing them

And lots more…

You can even use it with a YubiKey and with Google Autheticator for a two-factors authentication, and it also has a “security challenge” where it tells you if any of your accounts were compromised or how strong are your passwords. The service is really well done and provides you with a smooth experience (even if the graphical web interface is not the best around).

But it is not open source. This is the kind of service I would like to have as a truly open source project. Are there any open source project like this out there?