Posts
- Since records began in 1850, seventeen of the eighteen hottest years have occurred since 2000.
- Two thirds of Arctic ice cover are gone since 1980.
- Less ice means less resilience to future warming and storms.
- Less ice to reflect Sun rays means more warming (estimated in 25% of the temperature increase due to CO2 during the past 30 years).
- 1-2% decrease in crop yields per decade over past century.
- Prediction: reduction of production of rice, wheat and corn by 36.25%, 18.26% and 45.10% respectively, by the end of the century, in China.
- Prediction: reduction of 6-23% and 15-25% of production of wheat in India during 2050s and 2080s, respectively.
- The loss of coral and the acidification of seas is predicted to reduce fisheries productivity by over half.
- The World Bank reported in 2018 that countries needed to prepare for over 100 million internally displaced people due to the effects of climate change.
- Why ICO are securities (and as such should be regulated)
- We are in a bubble but unlike the dot com bubble this time around most investors are retail investors and not institutions
- Why regulations are welcome
- ICO 2.0, the future - good ICOs with good products will give token holders equity-like rights and fulfill regulations
- breakfast - two eggs or skip it, having just a cup of black coffee
- lunch - vegetables and/or legumes (broccoli, lentils, white beans, cauliflower, chickpeas) and meat (generally red, but I’m trying to eat more chicken)
- snacks - peanuts, cashews, pecans and cheese. Sometimes a splash of milk.
- dinner - steaks or chicken with vegetables. Add one or two eggs if I’m too hungry
Deep Adaptation
I would like to share this ominous article I read the other day. In the article the author, Jem Bendell, analyzes recent studies on climate change and concludes that Earth is heading to a major catastrophe. According to the author there’s no way to avert global warming and we should instead work on ways to adapt to the new society that will rise after the near-term collapse of civilization due to global warming. This is what Bendell calls deep adaptation.
The author’s conclusions from the studies mentioned sound pretty reasonable to me. I will let you decide but I wanted to list a few facts and predictions from some of the papers mentioned in the article:
Yikes.
You can read more on Deep Adaptation: A Map for Navigating Climate Tragedy.
Crypto Digest #1
Some interesting Sunday readings about cryptocurrency.
Is it a bubble? Differences and similarities between cryptocurrencies and financial markets.
Read more: https://medium.com/@dennyk/why-and-how-the-cryptobubble-will-burst-de9bc7fc5332
From the same author, an explanation of market cap and why the real crypto market cap is much larger than people think.
Market cap(italization) is defined as the value of all outstanding shares in a company, or in another words, the current prize per share times the number of shares.
Ex. Apple is currently trading at $175 per share and has 5.13 shares outstanding. Hence, its market cap is around $900bn.
There’s an important distinction: “free float” market cap vs total market cap. Market cap is the value of total number of issued shares, while free float market cap is only shares are only those that are not held by a major shareholder. Consequently, multiplying the number of free float shares by price we obtain the free float market cap. Using Apple as an example again, around 91% of Apple shares are considered free float, while 9% are considered “stagnant shares”, shares that are held by funds like Berkshire Hathaway or Blackrock, or employees.
There’s no technical distinction between free float and stagnant shares and nothing prevents a large shareholder to sell their shares but as they haven’t done it in a while their shares are considered stagnant.
When people quote a crypto market cap they often refer to the “circulating supply” for that particular coin, and not the total market cap. Circulating supply is similar to the “free float” market cap and thus smaller than market cap. According to the author, by considering the total market cap we get a much better picture of how crypto markets compare to the financial market at the time of the dot com bubble.
Five Bullet Friday
High Intensity Training
In the past I read about high intensity training (HIT), mainly the version associated with Mike Mentzer, but I didn’t appreciate his theories as much as I admired his physique. I started to read about it once again, have been training HIT style for about two weeks and I must say I am already seeing good results.
HIT seeks to increase workout intensity at the expense of volume and frequency. In practice what that means is you have to maximize muscle time under tension by executing all movements in a slow and controlled fashion, having short or no rest intervals between sets and exercises. Also as you are keeping the muscle under tension longer by slowing down the execution, you don’t need to perform as many sets as conventional routines.
All the theory and scientific studies about it you can read on the book Body by Science that I am currently reading. Also recommended are the bulletins about exercise and fitness wrote by Arthur Jones, who popularized HIT in the 70’s. They can be read here.
Corporate Warrior Podcast
It might sound strange a podcast about High Intensity Training and entrepreneurship but that’s exactly what this excellent podcast is about. The podcast presented by Lawrence Neal brings several known experts in diverse areas related to health, business and lifestyle. As I’m reading about HIT right now I’m focusing on episodes related to that. A few interesting ones:
Bill DeSimone, episodes one and two.
Also by registering in the podcast website you can download a book with several episode transcripts for free. I’m reading it and it is worth it.
Friedrich Gernsheim
How come I didn’t hear about this German composer before? Having been listening to his symphonies and they sound to me halfway between Beethoven and Tchaikovsky: orchestrated a bit more colorfully than the former but more strict in form than the latter. I recommend symphonies 3 and 4.
Bitcoin
I was sucked into the hype and bought some Bitcoins. I’m not planning to get rich or anything, just to have some fun and not being alienated of conversations in my workplace. What interests me the most is the technology behind Bitcoin, and what things like blockchains can enable in the future. I’m trying to get my hands on more technical readings about the cryptocurrency and so are reading Bitcoin and Cryptocurrency Technologies by Narayanan et all. Read a free draft of the book here.
While we are on the topic but super late to Bitcoin party it might be worth to check the list of cryptocurrencies involving interesting technologies put together by John McAfee. I think it might point to coins that will rise in price in the future.
YOLO Neural Networks
I will be starting graduate school next year and my research will probably involve neural networks. I always thought neural networks were too slow for real-time image recognition but my supervisor brought the YOLO paper to my attention. I still have to read it throughly and understand it but from what I could gather traditional convolutional networks used in image recognition apply the model at multiple locations and scales on an image while YOLO networks (You Only Look Once), as the name says, apply a single neural network to the full image. I hope to be able to use them for performing real-time object tracking.
Great times are coming! Wish me luck!
Five Bullet Friday
Inspired by Tim Ferriss on Fridays I will be writing my list of five interesting things I saw/read/heard/discovered during week. Technically it is coming out on Saturday and that’s because I’m lazy and a chronic procrastinator.
“You and Your Research” by Hamming
This is a recording of a lecture by the great scientist Richard Hamming. I thought it was very inspiring to hear from the great scientist several personal anecdotes, including interactions with other great scientists and moments of self doubt. It is also awesome to know more about how a very productive person works.
Mahler, The Symphonies
I’ve known Mahler for a long time, but had never got much past the first symphony, the fifth and an occasional Das Lied Von Der Erde. Not anymore. Prompted by a BBC article I decided to give the 2nd, 3rd and 9th symphonies a shot. I have to say I have been listening them for a few days now and I’m enjoying. Granted, I’m still mystified by the way Mahler develops themes sometimes and his notion of form in general.
Sapiens - by Yuval Harari
History of the humankind and human society, from prehistoric days to now. I’m enjoying so far and I hope to review it after I finish.
The Little Elixir & OTP Book - Benjamin Hao
Nice book about Elixir and Erlang OTP. Still working my way through it, but I think this book is a nice complement to Introducing Elixir by Laurent and Eisenberg. The former illustrates the contents of each chapter with a small project which is nice for retaining information while the latter provides a more comprehensive treatment of Elixir the language.
Elixir is an extremely elegant language and it was love at first sight for me. I’m now trying to settle on a personal project to practice it.
The Tidyverse
Recently I took a short course on Literate Programming and Statistics. The purpose of the course was to introduce the packages of Tidyverse for handling data in R, Markdown documents and some statistics basics. I was aware if not familiar with all three subjects but it never occurred to me that Markdown documents could be considered a form of literate programming. More specifically, it was nice to finally get to learn and use dplyr
and other associated packages. They are great for tidying up data and a great improvement over equivalent base R functionality. Magrittr
package offers a pipe operator (%>%) similar to Elixir pipe operator.
To know more take a look at the incredibly useful book R for Data Science.
Feature Flags
Feature flags (also feature toggles) are useful when you want the ability to turn some application behavior on or off. Let’s say you are rolling out a new functionality. It might be the case that you don’t want to make it available from the get go, maybe part of the functionality is not complete. It might also be the case that you only want to show this functionality to a subset of users. That old-fashioned way of doing this is using conditional statements
if (bazFunctionalityEnabled) {
showBaz();
} else {
showFoo();
}
There are several libraries for aiding in the process of creating feature toggles. Also Spring ships with an annotation called @ConditionalOnProperty
that
is also helpful on those scenarios. This annotation tells Spring whether or not to create a Bean
based on a property. Let’s say you have a Bean
for listening
to a queue
@Component
public class FooSubscriber {
private final MessageConverter<Event> messageConverter;
private FooService fooService;
@Autowired
public FooSubscriber(FooService fooService) {
this.messageConverter = new MessageConverter<>(Event.class);
this.fooService = fooService;
}
@RabbitListener(queues = {"#{@fooQueue}"})
public void receiveMessage(byte[] message) {
Event event = messageConverter.convert(message);
fooService.save(e.getId());
}
}
You might want to disable processing of messages. Maybe the server is too busy processing messages. Just add conditional annotation
@Component
@ConditionalOnProperty(name = "feature.enable.foo.processing", matchIfMissing = true)
public class FooSubscriber {
(...)
}
This way, if feature.enable.foo.processing
is equal to true
in application.properties
the bean will be created and consequently messages will be
processed. Otherwise, Spring won’t create the bean. Notice the argument matchIfMissing
with a value of true
. It tells Spring to consider the property
as being true if it is not defined. This way you can define a default behavior in case that property is not defined.
This is even more convenient if you use distributed configuration tools like Spring Cloud Config. If you want to turn a certain feature off just change the configuration in Cloud Config repository, push those changes, restart the app and you will have the desired result.
In order to check more than one property, just supply an array of property names in the name
parameter
@ConditionalOnProperty(name = {"feature.enable.message.processing", "feature.enable.foo.processing"}, matchIfMissing = true)
See more in the official docs.
Advanced Checks with @ConditionalOnExpression and Spring Expression Language
If you need more elaborated checks you can use Spring Expression Language (SpEL) expressions inside @ConditionalOnExpression
annotations. Example:
@Component
@ConditionalOnExpression("${messaging.enable} && ${messaging.throttle} < 10")
public class FooSubscriber {
(...)
}
Bean Creation on Class Properties
You can also conditionally define multiple beans inside a class and use the presence or absence of this class as flag for another class. It is necessary to
extend AllNestedConditions
abstract class from Spring
public class FooMessagingFlag extends AllNestedConditions {
@Bean
@ConditionalOnProperty("feature.enable.messaging")
publiMessagingBean
}
@Conditional({FooMessagingFlag.class})
@Configuration
Solving RStudio Missing Latex Packages Issue
This post is more of a note to self for next time I encounter the same problem. When trying to generate a PDF from an RMarkdown file using Rstudio I got the following error
! LaTeX Error: File `framed.sty' not found.
Interestingly enough this error started to happen after I updated RStudio. Before the update I was able to generate PDF files without problems. However, I do remember having to install Latex packages in the past before generating any PDF files. How did installed packages disappear from my system after an update? Mystery. Anyway, if you use MacTeX distribution the solution is simple: you can use the package manager that comes bundled with MacTeX to install the missing package:
sudo tlmgr update --self
sudo tlmgr install framed
Problem solved? Not yet. After installing framed
it turns out I had one more package missing:
! LaTeX Error: File `titling.sty' not found.
The solution, once again, is to install the missing package:
sudo tlmgr install titling
That should solve this common problem. In case you have more errors like those, try to identify the name of the package that contains the missing file RStudio (more specifically pandoc) is complaining about and install that package.
The 4-hour Week Body
The Book
If you get past the baity title and occasional exaggerations this is actually a good book. It presents tips and some of the science for loosing fat and gaining muscle, gaining strength and physical fitness in general.
One of the highlights of the book is the so called Minimum Effective Dose, the minimum amount of something you need in order to obtain the effect. Tim argues that once you get past the MED you start to get diminishing returns. Why lifting 5 times a week for 2 hours if your MED is lifting 3 times a week for 20 minutes? According to Tim the most important then is finding the MED for everything, from consumption of nutrients to exercise.
Tim introduces what he calls the “Slow-Carb” diet. It turns out this is a pretty vanilla low carb high fat diet. Bottom line: eat as few carbs as possible. Try to get all your carbs from legumes and vegetables. Avoid simple carbohydrates like sugar, rice, pasta, bread and pastries in general. The Slow-Carb diet allows you one off day per week in which you can splurge and eat whatever you like. This helps you keep your sanity and sends confliting signals to your body so it doesn’t adjust so easily to your diet what would make it burn less calories. There’s a chapter on how minimize the amount of fat gained on these off days, with tricks like ingesting cinnamon and certain kinds of supplements. I didn’t try any supplement recommended in the book but I did incorporate cinnamon into my diet. Another tip is taking cold baths or showers as there will be more heat transfer from the body and consequently the body has to spend more calories for staying at its normal temperature.
There are some good tips on the chapter about exercise but I couldn’t make use of most of them since I’m not currently doing any kind of gym work. However, I’m trying at last doing a circuit with push-ups, crunches, planks and squats at home three times a week.
There’s also a chapter on sleep. Some of the tips are controlling room temperature when going to sleep (the colder the better), special lighting in the bedroom and cooling off your body before going to sleep. I’m adopting cold showers and they really seem to help besides the aforementioned benefits for weight loss. The book also talks about polyphasic sleep (sleeping several times over the course of 24 hours). I’ve read about polyphasic sleep in the past, but as I have work and school it is just not practical. I’m planning to at least start biphasic sleep, sleeping a core 6 hours in the evening and then 20 minutes after lunch. Truth is that I’m feeling more alert and less sleepy since I decreased the amount of carbs I ingest.
Additional topics on chapters that I have just skimmed over: reversing injuries, improving sex, swimming and improving life expectancy.
Takeaways
I have been following a non strict Low-Carb High-Fat (LCHF) diet for a few months now. I lost a few pounds and I’m feeling great. Most of what I read in the book is in accordance to what LCHF preaches. My meals are structured around
Sometimes I eat fruits in my day off. Generally I have a pastry or two in my day off, as well as ice cream and candy (but not too much). To be honest once that you start eating healthy it is hard to go back and eat junk, it just does not feel good.
I incorporated cold showers into my routine. I’m still not sure whether they are good for fat loss or not, but they do seem to improve sleep for me. Also they seem to improve my recovery after exercise, I feel less sore in the days following training sessions. There is some evidence they might improve health too.
Installing xgboost with OpenMP support on Mac OSX
After losing a few hours (and my temper in the process) I thought I would share the steps to compile and install xgboost on a Mac OSX with OpenMP (for multi-threading) support. Official docs weren’t terribly helpful.
This is not going to be graceful.
First, download the code
git clone https://github.com/dmlc/xgboost/
Now get a compiler with OpenMP support. Installing a clang version newer than the default version that ships with Mac OSX El Capitan turned out to be a bit of a hassle, so I went ahead with GCC instead. The easiest way I could find (it is in the official xgboost documentation) is using brew
brew install gcc --without-multilib
It might take a while, it took about an hour on a MacBook Pro 2.6 GHz Intel Core i5 with 8GB of RAM. Don’t use brew install --with-clang llvm
.
IT’S NOT GOING TO WORK. Or maybe it will, I don’t know, I tried that before discovering how to point R to the right compiler.
Assuming you now have a compiler with OpenMP support comes the trickiest part: point R to the right compiler.
I tried this solution, it didn’t work.
Also tried a couple more approaches, to no avail. I also didn’t feel like fiddling with symlinks and brew links.
That’s how a discovered this one weird trick to get six pack abs R compiling with OpenMP support.
It’s not pretty, but you can edit default R Makevars
file. This is a makefile that holds several flags, including compilers and OpenMP support.
You can find the location of this file on your machine using this command
file.path(R.home("etc"), "Makeconf")
Mine is at /Library/Frameworks/R.framework/Resources/etc/Makeconf
.
Open the file and change all references to clang
to point to gcc-6
instead. At the time of this writing GCC 6 is the most recent version, yours
might be different.
After this type inside R.
install.packages('devtools')
library(devtools)
install('xgboost/R-package')
And et voilà, you should be all set.
If you feel like trying a less hacky solution, this thread might help.
MOOCs of the month
I’m a great fan of MOOCs (Massive Open Online Courses) these days although when I first learned about the concept I didn’t like it much. I thought they would be mostly superficial and as many of them were/are self paced I thought it would be hard to finish them without deadlines. I probably have finished few of the many courses I have joined indeed.
However when Coursera started to become popular and having more courses I decided to give MOOCs a try again. And it was precisely when I fell in love with the concept. Given a little bit of effort now I was able to finish courses, gaining valuable knowledge that would be hard to get elsewhere. On Coursera (and other platforms like EdX) you can have access to high quality Courses on many topics, taught by top notch universities from all around the world.
Of course I also have some reservations about online courses. To me personally heavy math courses are hard to follow on the computer. I get distracted very easily when using computers, it’s just too easy to switch browser tabs and get lost on a long chain of links. At the other hand computer science or music courses are generally lighter and easier to follow, giving me good results.
MOOCs now are one of my main learning tools so I decided to stick to a routine of doing them every week. Sometimes I fall behind schedule due to college and heavy work load but I always try to watch all lectures and do as many tests as I can. School vacation has come, so I choose a few courses to do this July:
The World of the String Quartet
Write Like Mozart: An Introduction to Classical Music Composition