Automate Reboot and Git push with Linux Crontab

1200px-Tux.svg

Introduction

I am going to explain how you can set up daily git pushes with crontab command.

Step 1 – Disable git username/password prompt during check-in

Follow the steps on this StackOverflow post.

Step 2 – Add git commands to a sh file

Add following sh file to the repository root directory.

#!/usr/bin/expect

#Pull remote repository
git pull

#Git commit and push
git add -A

#Commit
git commit -a -m "Daily Update"
git push

Step 3 – Open Crontab

sudo crontab -e

Step 4 – Setup Daily Executions

Add following line to the crontab file. This will run the script every 8am in the morning.

0 8 * * * PATH_TO_YOUR_SH_FILE

For example, the command I used was this.

0 8 * * * /home/myhome/project/gitpush.sh

Step 5 – Setup Daily Reboot

Refer to this askUbuntu post to set this up.

 

Advertisement

Set up Ubuntu Mate on Raspberry PI for Python Developers

Raspi-PGB001

Introduction

This blog explains how to set up a freshly installed Ubuntu mate on a Raspberry PI for Python and Django development. If you want to know how to install Ubuntu Mate on Raspberry PI please refer to this post.

Step 1 – Enable SSH

Not really needed for this task. But handy to have it. Run the following two commands to activate it.

sudo systemctl enable ssh
sudo systemctl start ssh

Step 2 – Update Ubuntu

Run following two commands. These two will take 1-2 hours to finish.

sudo apt-get update
sudo apt-get upgrade

Step 3 – Install Importent Packages

sudo apt-get install git
sudo apt install vim

Step 4 – Install Python/Django

sudo apt install python-pip -y
pip install --upgrade pip 
sudo python -m pip install django

Install Ubuntu Mate in Raspberry PI using Mac and no Keyboard

Raspi-PGB001

Introduction

In this blog, I am going to explain how you can install your Raspberry PI using a mac and without any keyboards. Also, you need minimal technical knowledge to do so. You will need a mouse and a display device. So here it goes.

Step 1 – Download Ubuntu Mate

Get it from the following link. Then extract it to get the .img file.

https://ubuntu-mate.org/raspberry-pi/

Step 2 – Plug Micro SD card to your Mac

Connect your Micro USB card to the mac. If your mac is a new (fancy) one with only Thunderbolt ports you can buy a micro SD card adapter from Amazon for a couple of bucks.

Step 3 – Find the Device Identifier

Mac will auto-mount your micro sd card. Go to the Disk Utility, select your SD card. Note the disk identifier of your card. For my case, it is disk4. Then unmount your disk (do not Eject).

Screen Shot 2019-03-09 at 4.26.54 PM

Step 4 – Write Ubuntu Mate image to the SD card

Here is the command you should execute.

sudo dd bs=1m if=path_of_your_image.img of=identifier_of_your_disk conv=sync

For my case, here is the exact command I had to run.

sudo dd bs=1m if=~/downloads/ubuntu-mate-16.04.2-desktop-armhf-raspberry-pi.img of=/dev/disk4 conv=sync

This command takes some time to complete, so stay put.

Step 5 – Boot your Raspberry

Plugin the micro sd. You need to connect a mouse and display to it as well. Turn on the raspberry and boot it up.

Step 6 – Set up username/password without a Keyboard

When it boots up it will ask you to give a login and a password. But you can’t do it because you don’t have a keyboard. The trick is to copy any text from the window and paste it on the login and password text boxes. For this example, I used “computer” username and “computercomputer” as the password. Set it up, you are good to go.

Step 7 – Enable On Screen Keyboard

Go to Applications–> Universal Access –> Onboard

Hope this helps. Refer this blog to see how you can set up Ubuntu Mate after installation for programming.

Best Machine Learning / Data Science Reads

Here are the most interesting research papers / articles that I came across.

  1. A Few Useful Things to Know about Machine Learning. This papers discusses twelve important topics that every machine learning practitioner should pay his attention to. https://homes.cs.washington.edu/~pedrod/papers/cacm12.pdf
  2. This article describes foundations of algorithmic bias. http://approximatelycorrect.com/2016/11/07/the-foundations-of-algorithmic-bias/
  3. How machine learning algorithms are evaluated in real world uses in web and other online applications. https://ai.stanford.edu/~ronnyk/2007GuideControlledExperiments.pdf

Investing Guide for Solo Investors

invest

Seven Key Rules

Keep following seven rules on your mind, on your desk and on the wall of your bedroom if possible. Read them at least once a week. When you are making an investment use this rules to evalute the quality of the investment.

  1. Always try to minimize loosing money. This involves making investments with minimal downside risks.
  2. Focus on acquiring and holding stocks with consistent dividend growth so the revenues can be compounded.
  3. Stocks are never undervalued. Stock is today worth what investors willing to pay for it, no more no less.
  4. No more than 20 symbols. Hard to keep track more than 20 companies. At least Half of them with high dividend pay companies.
  5. Evaluate each investment twice an year
  6. Have a predefined exit criteria for all the holdings.
  7. Always have a pool of cash ready

Numbers to Consider

  1. Company should have a high dividend yield. At least higher than the inflation.
  2. Consistent, moderate dividend growth – High dividend growth rates are not sustainable. Financial statements can be deceptive. Executives work goes to make them attractive for investors. But the dividend payment always tell the truth. Consistent growth of dividends is the hallmark of a good company. See at least 5 years of history.
  3. Debt / Capitalization should be less than 50%
  4. Coverage of at least 3 : 1. Cash flow of the company after taxes should be at least three times as the interest it pays
  5. Consistent, moderate annual earning growth 5 – 10%
  6. Payout ratio less than 60%
  7. Low Price / Sales ratio – Price of a share divided by the sales per share. Very fist prerequisite of business is revenue. If  revenues are high compare to the stock price, profitability can be easily increased though cons controls and increased productivity. Minimum price to sales ration of 1.5.
    1. Low P/E Ratio – must be at minimum. This value should be less than the reciprocal of the long-term bond rate. If bond rate is  5% –> 100 / 5 = 20 –> PE value should be less than 20. If the price of the company is above this level. Then the stock is expensive. Evaluate the PE value of a stock relative to the PE value of the market. If a stocks PE has been 125% of the market, but now it sells at 80% of the market, there is a good chance that it is under valued at the moment.
  8. Buy shares less than it’s book value. Book value does not represent intangible values of the company such as the brand name.
  9. Growth in cash reservers or investments made by the company
  10. Less volatile sharp rice. Can calculate the standard deviations of the share price to find this.

Measurements of the Quality

  1. Company has Performed well during the troublesome economic environments
  2. How well acquisitions are absorbed and integrated into the company –> smart acquisitions
  3. Do best to avoid new businesses. Look for companies with long-term consistent moderate growth, long-term dividend yields, long-term growth of yield.
  4. Look for a company that produce real goods or services which serves peoples needs, has a reliable user demand. Avoid reseller companies.
  5. What you should really buy is a competitive advantage. Try to identify the competitive advantages a company has over others.
  6. Look for growth kickers. That could be selling for a low performing division or a new sub division with great potential

General Guidelines

  1. Information available to everyone is not valuable anymore. PE ratio is not valuable as it was before
  2. TIme of max optimism is the best time to sell. the time of max pessimism is the best time to buy
  3. Don’t confuse genius with a bull market
  4. A list of stocks that you want to earn but which are not representing correct value at the moment. use this list during next correction/crash to buy

 

Selling Strategy

Sell when the dividend does not make sense to hold it for long team. make the decision based on the dividends. If we know that dividends are not going to keep rising, then it is time to sell. When dividends are affected, so is the share price.

Also when the share price increases it’s fair value, and the dividend yield relatively smaller to the other shares

One year goes with dividend increase. See the reason is one time occurring. If it fails two consecutive years, may be it is a good time to sell.

Document selling decisions and analyze them annually

If a company grows really fast with keep increasing sales, if those sales comes from the consumer credit, that may not be a sustainable business. When the debt cycle turns, customers will not be able to consume services as often.

 

 

 

Simple Four Steps to Get Fit

How to get fit? Why is it so hard to get fit? I was looking for answers to this question for a long time. After a long 5 years, after wasting thousands of dollars, reading countless books and wasting hundreds of hours in the Gym, I finally have my answer.

Why is it hard to get fit? Because the following industries wouldn’t let you.

  1. Food Industry
  2. Fitness Industry
  3. Entertainment Industry

First, evidence that I really know my stuff. Here is my photo.

Getting fit not hard. Really, it’s the easiest thing you will ever do. Really!!! But it is not quick – it’s not something you can do it in 30 days.

In this article, I am going to explain how the above industries are holding you from getting fit – robbing your money, sucking the life right out of you.

Food Industry – Processed Food

Why

Farming is not a profitable business. Natural food stale fast, transportation and storage is expensive. On the other hand, processed food is a very lucrative business. Processed food have long expiration dates and can be mass produced easily under any climate. So Food Industry has been spending billions on marketing in the convincing general public to consume more and more processed food.

To keep the production cost low, one trick food industry uses is to add more sugar to processed food. Sugar is a relatively cheap substance. Today most of the processed food contains about 10% of Sugar. Here are some examples.

  • Marmite is healthy right? Check the nutrition chart. Marmite contains 11.6% of Sugar
  • One serving of Kellogg’s Cornflakes Cerias (28g) contains 3g of sugar. That is a little bit more than 10%
  • One serving of Heinz ketchup (17g) has a whopping 4g of sugar

So when they sell you 100g of Marmite, they sell you 11.6g of Sugar at the price of Marmite. Pretty neat eh.

Second best quality of sugar is that it is addictive. All of us are addicted to sugar. Do not believe me, try to cut your sugar treats for 1 week. You will be feeling like a drug addict on withdrawal.

How to minimize processed food?

  1. Cut down on bread, pasta, sausages, sauce… etc.
  2. Get your sugary treats from fruit. Replace your Chocolate Croissant from  Grapes or blueberries.
  3. Only consume processed food with the Sugar content of 5% or less. You will find that there are not a lot of options at this range.
  4. No more fuzzy drinks – drink water.
  5. Eat lots of meat, grains, vegies, and fruits.

Fitness Industry – Workout Right

“Sell a man a fish, he eats for a day. Teach a man how to fish, you ruin a wonderful business opportunity.” – Karl Marx

Why

Your personal trainer sure as hell not going to teach you how to fish. His business depends on you paying him 100$ an hour to workout.

Those expensive home workout machines do not work either. Models appear in the advertisement did not get to that shape using that machine.

Also don’t subscribe to the expensive gyms with fancy machines, which let you get into the shape ‘safely’. Those machines are there just to lure in new people. Just another marketing trick.

How to work out right?

  1. Lift free weights. Free weights are not as dangerous as they want you to believe. I am a self-thought – free weight trainer. There are tons of free youtube videos, books that can help you with this subject. If you still scared, hire a personal trainer for 3-4 days. Tell him to stick to free weights and learn all the good postures from him.
  2. Do Calisthenics/body – weight exercises. This can be practiced in your home or out in a park. This is an incredibly effective workout if you want a lean body with a reasonable amount of muscles. There are a bunch of apps with bodyweight exercises.
  3. Play spots run, jump, cycle, swim, and row. Playing a sport is an incredibly effective way of working out.
  4. Be consistent.
  5. Find a conveniently located gym/workout place. Don’t choose a gym that you need to drive for 20 mins because it was 50$ cheaper. Convenience is the key to consistency.

Entertainment Industry – Sleep Well

Why

As a generation, we sleep much less than our ancestors did. The main reason is content streaming services like youtube, Netflix, Amazon Videos. They are pushing so much content, and we are so addicted. But how Netflix is going to profit from this. Bigger the addiction easier to raise annual premiums on their service.

How

Personally, this is the most challenging thing for me. Now I have a strict sleep time, which is 11:30. I try to keep this time at least five times a week. I get about 8.5hours of sleep.

Bottom Line – Spend More Than You Earn

Think your body as your bank account. Your salary comes into your account and you spend some of it. If you spend less than you earn, the balance of your bank account goes high. If you can consistently keep this behavior for a couple of years, you can accumulate a substantial wealth in your account.

Salary is your calorie intake, cash withdrawals are your workouts. The amount of excess fat you have is your bank balance. Your target is to bring your balance to 0. How to do this? There are two ways.

  1. Find a job with a lower salary
  2. Consistently spend more money than you earn
  3. Or both

One contradiction in above analogy is you can easily outspend you earning. But you can never ever work your way out of a bad diet. So it is very important to stick to a new diet so you can reduce your calori intake at the source.

Follow the above steps, I will guarantee that you will get into very good shape.

Step by Step Guide to Convert Foreign Drivers License to Canadian – BC Drivers License

Final_image-min 2How to convert my foreign driver’s license to a BC drivers license? This was a first question that I thought about before moving to Vancouver. Here we are explaining how you can get it done. Some quick facts before we dive into the details.

  • BC does not allow you to have two driving licenses. So when you are eligible for a BC driving license, you will have to surrender your foreign driving license.
  • You can use your foreign driver’s license during the first 3 months to drive in BC.

Step 0 – Check Your Eligibility

If you have a license from one of these countries and got two years of driving experience, you can convert your driving license to a BC driving license no questions asked.

If you a have a driving license from any other country/region you have to take a Knowledge test and a Road test. Depending on the driving experience, you will have to follow one of the following paths.

Has 2 years of driving experience

  1. Pass the knowledge test
  2. Pass a Class 5 road test you will get the full BC driving license

Has 1-2 years of driving experience

  1. Pass the Knowledge test
  2. Pass the class 7 driving test you will get a Novice driving license (what is a Novice driving license)
  3. Drive 2 years then pass a Class 5 road test to get a full BC drivers license

Has less than 1 years of driving experience

  1. Pass the Knowledge test
  2. Get the Lerners Drivers License (what is a Lerner’s drivers license)
  3. Wait till your original driving license  is 1 years old (if you got your drivers license on March 2018, you have to wait until March 2019)
  4. Pass the class 7 road test you will get a novice driving license (what is a Novice driving license)
  5. Drive 2 years then pass a Class 5 road test to get a full BC drivers license

Step 1 Before Arriving in BC

Get driving experience certification

If your driver’s license does not show an issue date, you need to get a certificate to show the period that you had your drivers license from a local authority

Get an IDP (International Drivers Permit)

An International Driving Permit is required only if your driver’s license is not in English or in French

Start Studying for the Knowledge Test

You can already start studying for your Knowledge test. Refer to study guide below.

Step 2 Pass your Knowledge test

You should have a permanent address in BC before taking the Knowledge Test.

Practice

You can walk into any ICBC office and get a free study guide. Personally, it took me about a total of 20 hours of reading and practice time. ICBC has an IOS app to help with both studies and practice. There are countless other resources online, But I recommend not to spend time/money time on them.

Take the Test

You can walk into any ICBC center and take the exam, no appointments needed. Find locations and opening hours of ICBC centers here. Note some ICBC centers are open till 9pm.

If you pass the test successfully, ICBC asks you to surrender your foreign driver’s license. But you don’t have to. Especially if you have some time of your 3 months quota you can keep it for some more time. But you have to surrender your license before taking the road test.

Step 3 Pass the Road Test

Practice

Although you have a good driving experience, I recommend you to take a few hours (1-3) of training with a certified instructor. Especially if you are moving from Asia like me you will discover lots of new rules. You can find driving instructors online. If you go with an independent trainer, they provide pick up/drop off. In Vancouver, they charge 70 – 90 CAD per 90 mins.

Be aware of the driving instructors, they will underplay your driving skills to sell more lessons to you.

Discuss with your instructor which ICBC center you should book for the exam. They also know ICBC road test areas. Practice around the area where you will have your road test.

Schedule a Test

Book the road test online. Usually, there is a waiting time of a couple of months. You can always change your appointment. Often people cancel their appointments. So regularly check for available slots.

Road Test

Road test takes around 40 mins. You have to bring a vehicle for the test. Also, bring a backup driver in case you fail.

Most of the personal driving instructors provide a “Road Test Package” which includes 40 mins warmup + Road test.

What happens if you Fail the Road Test

You can retake after 2 weeks. You have 3 attempts. So it’s really not a big deal failing the first attempt. I recommend taking a road test when you are reasonably confident about your driving.

Personally, I spent around 1200 CAD and it took me around 2 months to get it done. Finally, refer to the ICBC site for more information.