Home
  • Blog
  • Reading List
Follow @lelugom


Interesting readings
about technology, finance and other matters


The Craft of Research
 

In a very detailed book, Booth et al. give us thorough coverage of research. The book has five parts. In the first part, authors introduce research, defining it and describing its process. Then, the second part approaches the steps to go from a broad topic to a defined research question. The third part explains main claims, reasons to support them, and evidence backing those reasons. Planning and writing the research report comprise the fourth part of the book. A final part covers the crucial aspect of ethics in research and advice for teachers, cause authors consider research as the best way to teach students to read and think critically. A very important reading because research is involved in the professional life of most people.
 


Machine learning yearning
 

Andrew Ng is a world-class authority in the area of artificial intelligence. In this book, Andrew provided practical advice for machine learning practitioners. Topics include dataset setup, training considerations, human level performance, error analysis, and so on. Chapters are very short so that a practitioner can pick the issue he is having and read the advice for the specific situation. It's important to note that there is no introductory material, thus, readers should know about machine learning to take the most out of the book. As a side note, there is an AI introductory report from the same author: " AI Transformation Playbook How to lead your company into the AI era ". It has an overview of a procedure to adopt AI in business.
 


Man's Search for Meaning
 

After surviving four concentration camps during World War II, Austrian psychiatrist Viktor Frankl wrote a real masterpiece. Two parts comprise the book. In the first part, the author tells us about his experience in the concentration camps. The focus on the first part is on the psychological aspects of life in the camps. It describes the different phases inmates go through while they are imprisoned. It also tells us how the author survived and the importance of meaning in life to endure such levels of pain. Also, the author exposes how human beings can be saint or swine in spite of the situation they are facing. He highlights the freedom we as human have and the responsibility that should go hand in hand with such freedom. In the second part, building upon the role meaning plays in human life, the author presents logotherapy. A psychiatric treatment which name comes from logos, a Greek word for reason. Some examples are provided for its application in patients and its long-lasting effects on people's wellbeing. Definitely, a must read.
 


The Four Pillars of Investing: Lessons for Building a Winning Portfolio
 

An excellent book written by William Bernstein, easy to understand, with clear and accessible explanations covering different investment concepts. Also, there is numerous evidence backing the arguments, including tables, graphs, and calculations. Five parts comprise the book, plus an additional section with some updates after the 2008 market downturn. In the first four parts, the author approaches the theory of investment, the history of financial markets, the psychology of investors, and the financial business. The last section assembles concepts in the first four sections to lay out an investment plan that anyone can follow. Suggestions and examples guide the reader to set up an asset allocation and rebalance accordingly. Additional reads are presented in the book to continue the financial learning path, covering both investment and financial history books - history in finance is essential because boom and busts cycles are common throughout markets history.
 

-


How to win friends and influence people
 

Although Dale Carnegie wrote this book at the beginning of the twentieth century, it still contains valuable guidelines to make people like you and influence those around you. The first part deals with advice to handle people. The second part includes guidelines for making people like you. The third part provides principles for changing people thinking to your way of thinking. In the last part, the book explains leadership principles to change people without generating resentment. Guidelines in the book can be applied in both personal and business relationships. Principles are clearly explained by the inclusion of stories to better expose the concepts.
 


-


Supervised Sequence Labelling with Recurrent Neural Networks
 

Recurrent neural networks are ideal for processing sequential information. In this Ph.D. thesis, Graves provides an introduction to pattern classification, sequence labelling problems, and neural network concepts. Then, the book explores LSTMs and bidirectional recurrent neural networks. Subsequent chapters explain recurrent neural network approaches for sequence labelling applications, including framewise phoneme classification, speech and handwriting recognition, and image segmentation. New recurrent methods explained by the author include connectionist temporal classification, multidimensional networks, and hierarchical subsampling networks. It's important to note that the deep learning field moves fast and has advanced considerably after this book was published. However, it is an excellent resource for understanding the fundamentals of recurrent neural networks.
 


Writing the doctoral dissertation. A systematic approach
 

Starting from the selection of an Advisor and a dissertation committee, this book provides guidelines to direct you throughout all the stages of an academic research project. Authors take well-known principles in project management and apply them to the different research stages. The book also includes suggestions regarding topic selection, research proposal preparation, communication, execution, time schedule, meetings, budget, and publishing of results. The fact that projects always differ from planned results is not an excuse for lack of management. Usually, the lack of management increases the probability of failure and wastes resources. Thus, guidelines in this book are quite useful for the successful completion of a research project. Both the research project and the report writing are considered throughout the book, as well as advice regarding the Advisor and committee.
 


Clean Code: A Handbook of Agile Software Craftsmanship
 

A must read for anyone involved or interested in software development. Robert Martin, a renowned computer programmer and writer, teach us how to create software that is easy to maintain and extend with new features. He explains how to appropriately name variables, functions, and classes, as well as how to approach the design of functions, classes, and systems. Two chapters are dedicated to the delicate subject of concurrent programming. The author also highlights the importance of good comments in code and the development of an excellent test suite using Test Driven Development techniques. As a reinforcement of good practices, the book includes a chapter explaining the thinking process and the decisions Robert made to refactor an existing Java module according to the principles explained in the book. Maintenance is considered one of the biggest cost in any software project, thus, it's instrumental to apply author's suggestions in order to generate quality code.
 


The Little MongoDB Book
 

One of the most popular implementations of NoSQL systems is MongoDB, which has been increasing in usage as an alternative to relational databases on production systems. Its availability and escalation make it a feasible option for web scale applications, as this database system is part of the MEAN stack - MongoDB, Express, Angular, and NodeJS. The introduction presented by Karl Seguin in this short ebook is a recommended reading for anyone interested in knowing about this kind of database systems. SQL background is recommended, as some of the examples and ideas compare both systems in terms of functionality and components. You can download the book in EPUB or PDF format for free.
 


The Little Go Book
 

The Go programming language was created at Google by Robert Griesemer, Rob Pike, and Ken Thompson. They started to work on the project in 2007 and then, they released it as an open source project in 2009. The language has been increasing in popularity according to the TIOBEX index, as it is designed with a focus on simplicity and concurrency. This short book is a thorough introduction aimed at programmers with previous knowledge of statically typed languages such as C or Java, who are familiar with pointers, data structures, locks, etc. There are lots of examples to help you understand the main characteristics of the language and experiment with the concepts explained. It's available for free in PDF, EPUB, or MOBI e-reader format.
 


Quiet: The Power of Introverts in a World That Can't Stop Talking
 

I highly recommend this beautifully crafted piece of advice especially aimed at introverts. This is one of those books you wish you have read way before in your life. Susan Cain encourages you to be yourself by taking the most out of your strengths and personality traits, while at the same time, compensating for your weaknesses and uncomfortable experiences. Lots of references to psychology research and real examples question the culture of personality - which happens to be quite popular in the western hemisphere - and help you understand your different reactions to uncomfortable situations. This book gives you great tips for your day to day challenges at school, work, and home.
 


-


Think And Grow Rich
 

This classic work of personal development literature was published after the stock market crash of 1929. Although it was written near a century ago, it has sound advice which is still valid to face today's challenges in different aspects of your life. A practical strategy, along with real life examples, is described in the book to give you the tools to achieve what you desire in your life. Should you find yourself drifting along your journey, the principles described in the book will explain the importance of setting goals and striving to achieve them.
 


The Millionaire Next Door
 

Dr. Thomas J. Stanley and Dr. William D. Danko highlight saving and living below your means as a fundamental part of your financial well-being. This book has very interesting advice to accumulate wealth based on their research and data of the affluent people in the US. Hopefully after reading this book, you will become a prodigious accumulator of wealth, as they refer to people who has accumulated considerable amounts of money throughout their life.
 


A Random Walk Down Wall Street
 

A must read for anyone interested in knowing the different financial assets and investment concepts. After some chapters of financial markets history, including booms and boosts in the capital markets, the book explains financial concepts in a very easy to read format. You don't need any financial background to understand the concepts explained by Burton Malkiel. In the last chapters, you will find advice to develop your own investment plan, set your asset allocation and improve your personal finances.
 


Self-Promotion for Introverts. The Quiet Guide to Getting Ahead
 

Great reading packed with real life stories and advice by many successful and famous professionals in different areas such as politics, finance and sports. The Author made an amazing job by encouraging the development of a plan at the end of each chapter, in order to apply the concepts learned while reading and increase the understanding of yourself. The book contains practical advice for different areas such as the job search process, salary negotiations and networking. Public speaking tips for excelling at your presentations are included as well. It also contains real-world examples and Author's own personal experiences while writing the book, in order to enforce the concepts laid down and encourage you to improve your professional life.
 


48 Days to the Work You Love
 

Should you find yourself in the midst of a job hunting process or you feel hapless in your current job, this comprehensive guide will lay down the foundations to develop a plan for discovering what you are really passionate about, and become aware of your personality traits, strengths and weaknesses. Real life successful cases are presented in order to give you a better insight of the different concepts and help you advance your professional career. You will also define a clear goal to focus your daily job on what you find rewarding. Through a 48 day plan, you will follow a job hunting strategy that is going to hopefully land you an exciting and fulfilling job.
 


I Will Teach You To Be Rich
 

A thorough guide about setting your financial life in order. It has easy to follow and practical steps for tackling debt, budgeting, saving, planning and investing. It's ideal if you have not started or you are just starting your financial journey. I strongly suggest you read this book first and apply the steps to your personal finances before even considering the idea of investing.
 


The Plague
 

A novel written by Nobel prize winner Albert Camus, it's a vivid story developed in the Algerian city of Oran. The book depicts the human nature in difficult situations of life and the different reactions that people have when they face a harsh environment. Throughout the prose, you will connect to the different emotions of the situation, grow your reflection capabilities and identify the strengths of the characters.
 

Distributed ledgers in the digital market

 

The blockchain technology is a distributed ledger for electronic transactions, which is used by various virtual currencies including bitcoin, the most popular virtual currency in the market. Melanie Swan, author of the book Blockchain: Blue Print for a New Economy, states that "Blockchains are an important new form of information technology, a descentralized infraestructure and organizational system that is universal, global, secure and granular"

 

 

The main characteristic of these ledgers is that they are handled by a distributed network of participants rather than a centralized entity. The participants are called nodes and a central validation system is not needed at all because of the nodes distributed topology. Another important consideration is the extensive use of cryptographic techniques to store the assets and validate the ledger transactions with a digitally secure approach.

Even though the most popular applications for the blockchain technology are the virtual currencies, it is increasingly finding new applications for the financial and banking industry. Those applications include the electronic payment infrastructure and the digital assets for the capital markets.

It is also possible to find distributed ledgers for the digital identities used by software applications, web sites and digital signatures. At the same time, distributed ledgers may be used to create verifiable registries for any data, file or business process, making these ledgers a mainstream technology in the digital market. As Blythe Masters, CEO of fintech firm Digital Asset, said recently: "We're at a tipping point where this technology is turning mainstream and this technology needs to be understood by a more mainstream audience."

 

 

The Linux Foundation launched the collaborative project Hyperledger, an effort to advance the blockchain technology by developing an open standard for the distributed ledgers. This initiative can potentially transform the way the business transactions are performed nowadays, and redefine the rules for different industries, such as healthcare, manufacturing and supply chain.

Access Twitter REST API from Perl

 

Twitter provides services to access information from the site through REST APIs. The HTTP process makes GET and POST requests in order to read or write data, and the Twitter endpoint sends responses to those requests using the JSON format. All requests should use Oauth authentication in order to identify particular users and applications accessing Twitter services.

This script will show you how to use the user authentication model to access the Twitter API, which is based on the open protocol Oauth 1.0. First, go to apps.twitter.com and login with your username and password. Then, click on the Create New App button. Name your app appropriately and fill in the requested data. Access your newly created application and click on the Keys and Access Tokens tab. You will need four keys from this tab

  • Consumer Key (API Key)
  • Consumer Secret (API Secret)
  • Access Token
  • Access Token Secret

Make sure you don't share neither your Consumer Secret nor your Access Token Secret with anyone. You can download the script from perl_oauth.pl and modify the keys accordingly. Let's import the modules for the script and define constants with the four keys from the apps.twitter.com page. Include the base url to access the REST API as well

  #!/usr/bin/perl
  use strict;
  use warnings;
  use URI::Escape;
  use JSON::PP;
  use Digest::MD5 qw(md5_hex);
  use Digest::SHA qw(hmac_sha1_base64);
  use Time::HiRes qw(time);

  use constant {
    CONSUMER_KEY => "Consumer key",
    SECRET_KEY   => "Consumer secret",
    OAUTH_TOKEN  => "Access token",
    SECRET_TOKEN => "Access token secret",
    TWITTER_API  => "https://api.twitter.com/1.1/statuses/",
  };
          

Declare a function with three parameters. A string for the type of request, a string for the url to be accessed and a hash for the parameters of the HTTP request. Declare local variables including a hash with OAuth parameters. The function md5_hex will be used for computing a unique random value for each request. This value will be stored in the variable oauth_nonce, its parameters are a random number concatenated to the result of the function time from Time::HiRes module. The HTTP data hash will be merged with the OAuth parameters for the subsequent computations

  sub twitterOauth {
    my ($req, $url, %getData) = @_;
    my $secret_token = SECRET_TOKEN;
    my $secret_key = SECRET_KEY;
    my ($oauth_signature, $base_signature, $signing_key, $authorization, $response,
      $parameter) =  ('', '', '', '', '', '');
    my %oauth_parameters = (
      "oauth_consumer_key"     => CONSUMER_KEY,
      "oauth_nonce"            => md5_hex(int time() . int rand(~0)),
      "oauth_signature_method" => "HMAC-SHA1",
      "oauth_timestamp"        => int time(),
      "oauth_token"            => OAUTH_TOKEN,
      "oauth_version"          => "1.0",
      );

    $url = TWITTER_API . $url;
    %oauth_parameters = (%oauth_parameters, %getData);
        

The signature method HMAC-SHA1 will be used for computing the Oauth signature, this method is provided by the function hmac_sha1_base64 in the module Digest::SHA. First, create a string separated by & characters containing all the data in the Oauth parameters hash, using the key=value format. Parameter keys should be sorted in alphabetical order. Then, create the base signature string by concatenating the HTTP method in uppercase with the percent encoded URL and the percent encoded string for oauth parameters, joining the strings with the & character.

Create the signing key by concatenating the Consumer Secret with the Access token secret, joining the strings with the & character. Remember to percent encode each string before concatenation. Now, compute the oauth signature with the base signature and the signing key. It's important to know that CPAN digest modules don't pad the computed base64 signature by convention. Therefore, manually pad the computed signature with the code from the CPAN documentation to avoid authentication errors when accessing the API

    foreach $parameter (sort keys %oauth_parameters){
      $base_signature .= "$parameter=$oauth_parameters{$parameter}&"
    }
    chop($base_signature); #remove trailing & character

    $base_signature = uc($req) . '&' . uri_escape($url) . '&' . uri_escape($base_signature);
    $signing_key = uri_escape($secret_key) . '&' . uri_escape($secret_token);
    $oauth_signature = hmac_sha1_base64($base_signature, $signing_key);
    # Pad base64 output, CPAN Digest modules don't pad by convention
    while (length($oauth_signature) % 4) {
      $oauth_signature .= '=';
    }
        

Now we are ready to build the authorization string for the HTTP request. Use the key=value format and remember to percent encode each value.

    $authorization = 'OAuth oauth_consumer_key="' . uri_escape($oauth_parameters{"oauth_consumer_key"}) .
      '", oauth_nonce="' . uri_escape($oauth_parameters{"oauth_nonce"}) .
      '", oauth_signature="' . uri_escape($oauth_signature) .
      '", oauth_signature_method="' . uri_escape($oauth_parameters{"oauth_signature_method"}) .
      '", oauth_timestamp="' . uri_escape($oauth_parameters{"oauth_timestamp"}) .
      '", oauth_token="' . uri_escape($oauth_parameters{"oauth_token"}) .
      '", oauth_version="' . uri_escape($oauth_parameters{"oauth_version"}) . '"';
        

Let's use curl to access the Twitter API, using the --header option to pass the authorization string. Then, return the JSON formatted string received from API server.

    $parameter = join('&', map{"$_=$getData{$_}"} keys %getData);
    $parameter = "--" . lc($req) . " \'$url\' --data \'$parameter\' --header \'Authorization: $authorization\'";
    $response = curl($parameter);

    return $response;
  }

  sub curl {
    my ($curl_args) = @_;
    my $response;

    # System call for curl
    $curl_args = 'curl -k --silent -A "' .
      'Mozilla/5.0 (Windows NT x.y; Win64; x64; rv:10.0) Gecko/20100101 Firefox/10.0" ' .
      "$curl_args 2>&1";
    $response = qx{$curl_args};
    die "Unable to download webpage $curl_args " if ( $? == -1 );

    return $response;
  }
        

As an example, here is the code to download the last 12 tweets from the @twitterdev account and print the JSON formatted string in the standard output. The GET statuses/user_timeline HTTP request will be send. Remember to use JSON::PP module to decode the returned string for you particular needs.

  print twitterOauth("GET", "user_timeline.json", (screen_name => "twitterdev", count => 12)); 

Convert HP LaserJet 1000 into a network printer with OpenWrt

 

The HP LaserJet 1000 is a black and white printer which comes with a USB cable to connect directly to a port in your computer. Nevertheless, if you have a router with OpenWrt installed and a spare USB port on it, you can connect your USB printer to the router and share it in your Local Area Network to allow access from any Windows or Linux computer.

To make this happen, you need both a firmware file for the printer and a printer server. The drivers for the printer send the firmware file every time the printer powers on, so the router should do the same. To get the printer firmware file, we will use foo2zjs, an open source printer driver which supports HP LJ 1000 printer. So, let's download the driver and unpack it

  $ wget -O foo2zjs.tar.gz http://foo2zjs.rkkda.com/foo2zjs.tar.gz
  $ tar zxf foo2zjs.tar.gz
  $ cd foo2zjs

Compile and install it

  $ make
  $ ./getweb 1000
  $ sudo make install

Now, under the foo2zjs folder. you will find the file sihp1000.dl, which is the firmware file that the router should send through the USB port every time the printer powers on. Store this file in your router file system under the folder /etc/config to preserve it whenever you update the router with the sysupgrade command. We will use the p910nd printer server, a small non-spooling printer daemon intended for disk-less linux hosts, which copies any data received on the port it is listening on to the corresponding printer port. Let's install the printer server and the USB printing module kmod-usb-printer

  $ opkg update
  $ opkg install kmod-usb-printer p910nd

Modify firewall configuration on /etc/config/firewall to accept packets on TCP port 9100

  # Allow attached network printer hplj1000
  config 'rule'
      option 'src' 'lan'
      option 'proto' 'tcp'
      option 'dest_port' '9100'
      option 'target' 'ACCEPT'

Check the file /etc/config/p910nd has the following information, assuming your router IP is 192.168.1.1

  config p910nd
    	option device        /dev/usb/lp0
    	option port          0
    	option bidirectional 1
    	option enabled       1
    	option bind          192.168.1.1

We need a script to send the firmware file to the printer any time it powers on. So, let's create the script /etc/hotplug.d/usb/hplj1000. Remember that we store the firmware file sihp1000.dl under the folder /etc/config

  #!/bin/sh

  FIRMWARE="/etc/config/sihp1000.dl"

  if [ "$PRODUCT" = "3f0/517/120" ]
  then
          if [ "$ACTION" = "add" -a "$DEVTYPE" = "usb_interface" ]
          then
                  logger "Sending firmware to HP LJ1000 printer..."
                  cat $FIRMWARE > /dev/usb/lp0
                  logger "done."
          fi
  fi

Start and enable the printer daemon

  $ /etc/init.d/p910nd start
  $ /etc/init.d/p910nd enable

At this point, the printer daemon is up and running. The next step is to install the printer on the computer. Depending on the OS on your computer, follow the instructions here, and use your router IP address and the port 9100. For instance, if you have Ubuntu installed in your computer, go to printers and click the + button to add a printer and type 192.168.1.1:9100 in the network address input field, assuming that's your router IP. A JetDirect printer will appear, select it and then choose the HP foo2zjs driver previously installed, see the two images bellow

 

 

Finally, if you need to spool jobs, there is an easy workaround. After installing the network printer on your computer, go to Google cloud print and add the printer using the Add a Classic Printer option. Then, share this printer to the users you need. This way, any person with the shared printer can send print jobs, and they will be sent to the printer whenever chrome runs on your computer. Remember to synchronize chrome to your Google account for the spooling to work.

Upgrade an OpenWrt router using development snapshots

 

OpenWrt is a great distribution aimed to install a small Linux version in your embedded system, particularly your router. It supports lots of routers nowadays and new models are constantly added to the code base. There are two versions available for your router, the stable release, which was updated on March 2016 and received the name Chaos Calmer 15.05.1. The other available version is the development branch, known as Designated Driver.

Although you can build the development branch from the GitHub repository, there are pre-built snapshots available here. They does not have any web interface, therefore, all the installation process is performed from the command line interface. To showcase the process, let's update a TP-Link WDR3500 router using the build snapshot. Make sure you check the snapshots page to find a suitable image for your particular router! If you install the wrong image, you will brick your router . Before starting, let's make a configuration backup in case some unexpected result happens during the update process

  $ sysupgrade --create-backup /tmp/backup_conf.tar.gz 

Now, copy your backup from /tmp to your computer using scp command. Usually the storage on a router is quite limited. Therefore, we will check if the RAM available is enough to store the snapshot image in the /tmp filesystem

  $ free
               total       used       free     shared    buffers     cached
  Mem:        125196      26496      98700         88       1944       5748
  -/+ buffers/cache:      18804     106392
  Swap:            0          0          0 

The size of the snapshot image is usually around 3.2MB for this particular router, so we have more than enough space. Let's change working directory to /tmp, download the snapshot image and the checksum file to check image integrity

  $ cd /tmp
  $ wget http://downloads.openwrt.org/snapshots/trunk/ar71xx/generic/md5sums
  $ wget http://downloads.openwrt.org/snapshots/trunk/ar71xx/generic/openwrt-ar71xx-generic-tl-wdr3500-v1-squashfs-sysupgrade.bin

Now check image integrity with de md5sum command. If you don't get any output after running the command, the image file is corrupt. Download the image again and check it before any further step in order to avoid bricking your router

  $ md5sum -c md5sums 2> /dev/null | grep OK
  openwrt-ar71xx-generic-tl-wdr3500-v1-squashfs-sysupgrade.bin: OK

By now, We have the snapshot in our temporary storage. We are almost ready to upgrade the router, but we should first store important system files to avoid configuring the router from scratch after upgrading. In order to preserve the configuration files after performing the upgrade, you can edit the file /etc/sysupgrade.conf to specify wich files and directories you want to keep. This way you will preserve users, passwords, SSIDs and other configurations. Here is an example file

  ## This file contains files and directories that should
  ## be preserved during an upgrade.

  # /etc/example.conf
  # /etc/openvpn/
  /etc/sysupgrade.conf
  /etc/sysctl.conf
  /etc/rc.local
  /etc/profile
  /etc/passwd
  /etc/firewall.user
  /etc/config
  /etc/hotplug.d/usb

Now, upgrade your router by running the sysupgrade command tool. It will install the new image and reboot your router.

  $ sysupgrade -v /tmp/openwrt-ar71xx-generic-tl-wdr3500-v1-squashfs-sysupgrade.bin

Finally, install the packages you regularly use in your router, such as the packages needed for a printer server, or monitoring tools such as iftop, bmon and htop

  $ opkg update
  $ opkg install p910nd kmod-usb-printer iftop htop bmon 

All the steps are compiled into a shell script in order to automate the updating process. The script is available for download at tplwdr3500_upgrade.sh . Store the file in a router directory included in the file /etc/sysupgrade.conf, such as /etc/config, to preserve it after upgrade. Thus, any time you want to upgrade, you will want to run the following command

  $ sh /etc/config/tplwdr3500_upgrade.sh