Brexit and walls will not work in the future

I do not usually talk about these things, I hate talking about politics and football, basically because they do not foster creative thinking, they are disruptive, it creates conflict because there will always be different sides to the story, and there is no right or wrong. I would rather talk about science and what’s been proven to work, and practical matters that work because it has been tested and we use it.

However all these recent events have prompted me to have an argument. Not because I want to, but because social circles pressure us to say something. More and more people are talking about this topic and if you don’t have any ideas, you are basically out of the conversation.

I am not advocating for Hillary, neither whether European Union or Britain should remain, as people in different countries are brought up in different environments and the social circumstances highly affect how people think. What I do believe is in the idea of united Earth.

European Union has promoted widely, concepts that I believe are humanly universal, such as free people movement. One of the most important reasons Brexit happens is because there is too much population in UK and mostly due to immigration. I wouldn’t argue with that, but to tell the truth I believe free movement will be a standard sooner or later and in a global scale.

Main problem here are the economic differences. The concept of free movement is not for the immature, if you know what I mean, it will be achieved when there is certain economic development. It is all a timing thing. We’ve seen it. European countries were not unified in the past because different countries had different levels of development. With the adherence of new member states to EU, countries such as Poland and many other Eastern European countries saw a massive exodus to UK because of the different in economic development. But this is all part of the equation. Now Brits complain about this, but with time, free movement will have its prevalence because of an improved equality, people will not massively move.

Obviously some arguments will mention the fact that there will always be inequality, which I believe too, but the differences will not be so big. It will be like the differences within a country, in a national scale, that is, it will be like the difference between a big city and small village in terms of development, but not as different as the one between tribe and civilization. As humans develop over time, put apart their differences, economies develop, equality increases, therefore there will not be such a big immigration force, people will need to freely move basically due to business needs, travel needs etc. At that point, free movement will no longer cause problems, as it will converge in a more balanced migration of population from one place to another, and there wouldn’t be any notable differences moving to one country or another, as differences are not big in terms of income or social welfare.

Going back to our topic, doesn’t matter if UK people vote Brexit, or Trump builds his wall, or terrorists kill people. Everything will go back to these advances in humanity. We will have a united world sooner or later, it is a natural tendency such as water flowing through holes and cracks and it will be pushed when time is right, either when global economic development is stable, society is stable or aliens arrive.

Equal height with good old CSS positioning

The point of this trick, is to push title of the product upwards, instead of the normal flow, which is downwards. This way we can keep height of the outer element fixed.

Example HTML code:

Here is the CSS:

.container {

background-color:#000;
}
.product-wrap {
display:block;
}
.text {
position: absolute;
width: 100%;
height: auto;
bottom: 0;
opacity: 1;
z-index: 999;
padding: 15px 20px 0;
}

.image {
padding-bottom:80px;
}

.product-wrap {
position: relative;
padding: 25px;
border: 3px solid transparent;
background: #fff;
outline: 1px solid #e9e7e4;
-webkit-transition: all 0.25s ease-in-out;
-o-transition: all 0.25s ease-in-out;
transition: all 0.25s ease-in-out;
}
.product-wrap .wishlist {
display: none;
position: absolute;
top: 25px;
right: 25px;
}
.product-wrap .title h3 {
font-family: 'GWKnockout-thin', 'GWSentinel';
font-size: 29px;
line-height: 1em;
text-transform: uppercase;
letter-spacing: 0.06em;
/* height: 87px; */
overflow: hidden;
}
.product-wrap .price {
font-family: 'GWKnockout', 'GWSentinel';
font-size: 20px;
color: #d27528;
}

Run NodeJS app as a service and make it start after reboot

The issue

If you are running all Node dependencies locally, as opposed to globally, using a package such as foreverjs will not work, since all your node modules will be inside of your folder, and not installed on your server.
The reason why I have this, and as such, many of you, it is because we use a web server such as Apache and we want to add NodeJS additionally in the server. The Node app will only run if you hit “node start test.js”, therefore this is a solution to make it run forever plus also restart it after reboot of the server. In my case, because of my setup the crontab solution did not work.
Here is my setup:
Apache installed on my server, and Virtual host pointing to mydomain.com located in /var/www/html/mydomain.com folder
Main node file is main.js
Therefore, dependencies installed on node_modules

The solution

Install forever-service package. I used the option “–script” because my main Node app file was not named app.js (which is the default name assumed in forever-service).
$ sudo forever-service install test --script main.js
That will create a process called “test”. You will need to start it after that.
$ sudo start test

Why use Yahoo finance for your trading needs

As a follow-up post (see stock selection guide), I write this one to filter all the information that Yahoo finance provides when looking up for a company quote.

  • Summary: is a good place to make sense of the technical details of the shares. Ranges, volume and beta are useful indicators.
  • Historical prices, if can be plotted into a graph will be very useful to study the historical trend of the shares and compare it with an index.
  • Interactive chart of Yahoo finance updates in real time and it offers logarithmic scale (smooths spikes). As a recommendation I would calculate high and low prices in yearly intervals to see if the possibility of profit is empirically real (technical analysis).
  • Headlines and news should be quickly read (no need to read the details) and mark them as positive or negative impact.
  • The information in Key Statistics tab should be used to compare with other companies, therefore used in conjunction with Competitors and industry tab. The Beta provided can be used to calculate CAPM and have a degree of understanding of how it moves with indexes. If Beta of a company is over 2 it means that it moves a lot more if the index moves 1% (mathematically a Beta of 2 does not mean that the stock will duplicate its value if the index goes up) and it moves in synch with the index the closer Beta gets to 1.
  • Income statement, balance sheet and cash flow statements should be used to calculate increases in earnings (compare one year with another) but should not be taken for granted. For example, some costs may extend several terms so that profits at the end are waned not because of reduced income but because of expenses from previous terms. Therefore, book values are not consequently related to market prices, a profitable company may not have a good book value and vice versa.

 

Stock selection for small investors

This is a guide for selecting assets in the global financial environment (I assume you have access to any stock in the world). The whole purpose is to make profit in a medium term, with an aggressive (risky) profile with little investment. Throughout my years of investing experience I have come to a clear conclusion.

Buy stocks within world biggest indexes

Here are a few reasons why (updated over time).

  • SMEs are not listed in a stock exchange. It is true that we should not close any doors to ourselves, that we should buy any stock anywhere in the world as long as the business is good and makes profit. However, this is not possible in reality because we also deal with other economic costs such as travelling, signing complex contracts, wasting time on bureaucracy, getting cheated… and the list goes on. This assumption also includes OTC stocks.
  • Trading volume has to be high. There should be a threshold that the shares traded need to satisfy for you to invest. If the volume is low, which is what happens with OTC shares, they are completely unpredictable. A company with a lot of capital such as an investment bank, or a hedge fund can easily take over and buy an outstanding amount of shares and as a result manipulate the market. Big companies are harder to manipulate because there are so many investments that it is no longer possible to manipulate the market with a sole transaction, which in a sense, makes it less volatile.
  • Good representation of the economy. In order to get market efficiency to hold and be able to predict to some degree the future direction of the stock price, it needs to be listed in an index. Indexes are usually good measures of a country’s economy. From my research I’ve noticed that relevant indexes such as FTSE 100, IBEX 35, Nasdaq, Dow Jones and Nikkei are relevant because when there is a shock in one of these indexes or some kind of turmoil, the economy feels it and vice versa. Therefore, we try to accomplish ceteris paribus (all other things equal) by analyzing stocks that are listed in an relevant index.
  • Reputation of the company. Even though this statement mustn’t be true in all circumstances, it gives a a certain degree of trust if the company is public (listed in a stock exchange, which means financial statements are available to anyone and auditing is done), which conversely will provide us with as much information as possible about the company. In private companies that have little exposed information, our asymmetric information risk is much higher and the probability of our investment not being profitable will be more evident.
  • Predict investors’ reactions, not data. Today, investment companies are heavily relying on market data that are analyzed by quantitative analyst experts. However, according to this documentary, market movements and overall investment has an emotional component, since economics is based on too many assumptions that do not apply in many circumstances, we should still focus on investor’s expectations which includes information provided by media and possible scenarios of how investors may react. Therefore, we should also include in our analysis the news that come from media and categorize them as positive or negative impact.

With all these arguments, I found Yahoo finance the best solution for these needs. See Use Yahoo finance for filtering relevant info on Yahoo finance.

Cost of living in cities around the world

I found this website Numbeo:
http://www.numbeo.com/cost-of-living/
Which uses aggregate data from users of the website who input the data to the website. It kind of follows the Wikipedia collaborative environment, so it is still an informal source.

Any user in any country can input data, which is data that may be biased. They seem to have labels for general products but still a specific model of the product is not cited, therefore prices may vary. As an example, labels like “Apples 1 Kg 2.06 dollars ” is not insightful because apples can be imported (Fiji apple) or it has different varieties (Golden apple) which may cause high variability in data input.

The good thing is that you can see the spread (variability) on the data on the right side “Range” column. Statistically, data with high spread means prices have big lows and highs. A price range of 0 – 30 has an average of 15, but still a price range of 10 – 20 is 15 too, but this last range has much lower spread. Therefore, looking at the range graph on the right, you should avoid big ranges, because data is not consistent nor representative of the product.

Obviously you cannot do a economic study with this website, however, this will give you a pretty good insight for an unknown destination, as long as you need how to avoid inaccurate data. Big cities will probably have more data, proportionally more people live in big cities, more people will go to big cities and this means more people will add more data, therefore data accuracy is based on amount of people contributed. Furthermore you can contrast data with other more legitimate websites such as:

http://www.socialprogressimperative.org/

This is a good source of information, which gathers economic data of different countries created by Michael Porter. You can contrast welfare using this website with Numbeo and see the differences, that will help you locate accurate data. If not enough, you can still search your destination using Wikipedia and contrast data against Social Progress Imperative and get a big picture with the information provided in all three websites.

Good luck on your travels!

Stop saying “Self-teaching”

I have learned web design, HTML, CSS, using Photoshop among other tools by watching videos, reading books, practicing tutorials available on the Internet. People call it these days “Self-teaching” or “I am self-taught”. I don’t know if it was a kid who created this expression, but I find it arrogantly childish, sounds like you are better than others just because you learned it without a teacher, and some Americans even call some of these kids “genius”. I think this is one of the worst words made popular by media. The main reason behind it is that you can’t possibly teach your self.

We all had a teacher when we were young, someone knowledgeable that has far more experience than you doing the things you want to learn and this is why that person is a teacher and teaches you, because he or she knows more than you, otherwise that person would not have the power to teach you, it would be useless. When you don’t know something, someone then teaches you, then how can you “self-teach” something you don’t know? If you don’t know how to play the piano, you can’t possibly teach yourself how to play it…

After all, I believe this expression is really wrong, but English-speaking people just accepted it, maybe as an answer to the questions that so many spoiler parents (always putting their kids on a pedestal) ask: “Where did you learn that?” or “Who taught you that?” Under this context, well… it makes sense that a kid jokingly with a cocky attitude says “I taught myself”, wow this ends usually with a “My son/daughter is a genius”.

For these and several other reasons I urge everyone who reads this post to avoid using this silly expression. You can’t possibly self-teach, better “self-learn“. Hereby I propose using this new expression, filtered, neat, no hard feelings, just a humble “self-learn”, because we learn everyday, babies do it when they walk, and pianists do it when they practice new melodies. Yet I still encourage those that have the means to learn through a teacher to do it in the traditional way, it will save you a lot of time and you’ll learn it much better and even reach skillful mastery —coming from a long-time “self-learned”.

Random number in javascript

The following snippet creates an integer (no decimals) between the range you choose starting from 1.

var range = whatever number you want;

var randomNumber = Math.floor(Math.random() * range ) + 1;

This means that if want a number between 1 and 6:

var range = 6
or
var randomNumber = Math.floor(Math.random() * 6) + 1;

Explanation

Because Math.random will output a decimal under between 0 and 1 (never will be 1) we round it down, this means that Math.floor(0.5) = 0. We simply multiply the inside by the top number and add to the outside 1 to make it an integer between the specified range.

Remove /blog from multisite URLs

Introduction

One of the issues of the multisite is that by default it appends /blog to the site’s URL, so no matter at which page you are, you’ll get something like
example.com/blog/post-name

To avoid this follow these instructions

  1. At blog site set Settings -> Permalinks -> Common Setting -> Default (Must select default only and don’t touch any thing, If you need to change category base, tag base set at Network Admin only)
  2. At Network Admin -> Sites -> (root site) Permalink Sturcture -> /%category%/%post_id%

Use wkhtmltopdf in WordPress

The story behind this method

After tried several HTML to PDF engines such as TCPDF, MPDF, mostly had a common problem – they were not supporting most features of CSS. After some searching I stumbled upon wkhtmltopdf, which is based on webkit. However there wasn’t a plugin to convert WordPress posts to PDF using wkhtmltopdf, there were only wrapper classes for PHP, since wkhtmltopdf is a command line application in its essence. Hence, I had only one choice: to create my own method.
Because I am not a programmer, I came up with a very rudimentary method for converting the posts output by WordPress into PDF using wkhtmltopdf engine.

Installation steps

Steps for successful installation of wkhtmltopdf to avoid annoying errors such as “X server not found”, “no error display”…

1. Install composer
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-composer-on-ubuntu-14-04

2. Install wkhtmltopdf.

3. URL: http://example.com/pdf.php?url=websitetoconvert.com&pdf=name-of-file.pdf

Original: http://tecadmin.net/convert-html-to-pdf-using-qtwebkit-with-php/

4. After publishing post, execute the URL.
https://codex.wordpress.org/Plugin_API/Action_Reference/publish_post

5. Automate using curl PHP function. Paste this in functions.php of your theme. Remember to substitute “example” to any other name you want.

For the $options see this link: http://wkhtmltopdf.org/usage/wkhtmltopdf.txt
You can also user other wrappers such as https://github.com/mikehaertl/phpwkhtmltopdf
Other resources using PHP (not WordPress)
Video (French): https://www.grafikart.fr/tutoriels/php/wkhtmltopdf-639