Rebase Branch on Git Tag

You fork a GitHub project and start working on a feature around v0.15. The upstream repository pushes updates and now master is ahead v0.17. But you need to rebase your feature on top of v0.16 as per client requirements. How would you handle this?

My Git remotes are respectively origin and upstream. origin been my fork and upstream been the original repository. The following requirement was an actual requirement I met today to prepare a feature for a client based on a specific version of the app.

  1. Sync the repositories if applicable
    #~ git fetch upstream
    #~ git merge upstream/master
  2. Checkout your branch
    #~ git checkout feature/2-ideas
  3. Rebase the branch
    #~ git rebase --onto v0.16 master

Yes, thats it! How ever I had to deal with a shit load of conflicts… hope you have better luck.

Grep Rails Log for Exceptions

I am working on a client project that uses USAePay as a a payment gateway. Unfortunately there is not much good I can say about the payment gateway and I am stuck with it. The app is old and uses an old version of ActiveMerchant, which in turn uses ActiveUtils. The timeout is set to 60s in ActiveUtils and the gateway may take about 45s to 10 minutes. The app generates 5 million lines of logs every day and I use grep to find things useful. A team member had interest in the regex I used and thus I thought it might be worth to share with you.

The idea is that a stack trace has its class name on top. Some thing like ActionController::RoutingError. We can use this Error and what it precedes to find a a line number we are interested in for further inspection.

cat -n production.log-20180902 | grep -E "([[:digit:]]+)(\s+)((\w|:)+)Error"

Let me describe…

  • cat -n will cat the file with line numbers
  • grep -E means for regular expression
  • [[:digit::]] is for any digit (shell script)
  • The rest is usual regular expression

If you are not on Rails your regex would be different, but you get the idea.

This outputs some thing like this…

3560489	ActionController::RoutingError (No route ...
3560532	ActionController::RoutingError (No route ...
3560575	ActionController::RoutingError (No route ...
3560618	ActionController::RoutingError (No route ...

Physician Tharaka - Gampaha (නිළ වෙදකම)

Disclaimer: This article is about නිළ වෙදකම, a field of medicine similar to Ayurweda medicine. I believe නිළ වෙදකම is to Ayurweda as Chiropractic is to Medicine. I am by no means an expert in the field. This is merely my personal experience. I couldn’t find an english term for the field of medicine, so I will use “නිළ වෙදකම”, its original name in Sinhala.

Last Friday I got to know about a physician, Tharaka, who is in to නිළ වෙදකම. One of mums friends (aunt Biso) were interested in seeking out his service for her husband. He appeared to have results. Thus my mum was interested in going to see him and today we did.

Aunt Biso’s son-in-law was kind enough to get the number early in the morning. When we got there it was about 7:30 AM and only few were sitting in the chairs. Number available at the time was 27. By 8:30 AM the practitioner arrived. Some patients would take about 15min. Some took only a couple minutes. Mine pesonally took about 5 min and a smiler time for mum.

Treatments noticed

  • It has some resemblance to Chiropractic (all patients)
  • Noticed the use of chanted නූල / thread (1/ 10 patients)
  • Noticed the use of chanted water (1 / 10 patients)
  • There was oils in his bag


  • A neck pain I had seems to have improved
  • My mum’s back is curved slightly. She was relatively more straight. She has reduced need for her support belt.
  • The maid of my mums friend regained motion in few of her fingers


  • Location: Community Center - Vidyasekara Piriwena
  • Only 80 patients a day
  • Numbers are provided from 4:00 AM
  • The physician arrives at 8:30 AM
  • Observation time: varies from 5 min, to 15 min
  • Flow rate: 1.5 hours for 10 patients (that is the time we left)
  • Charges Rs. 500
  • Don’t keep cellphones in your pockets (close to the body) when seen the practitioner.
  • If you are sporting a suraya (සුරය), you are asked to leave it home as his doing may neutralize its power


I don’t have sufficient data points for a conclusion. I didn’t find any writing online about the practitioner. He seems to have some positive effect. If you are in to such medicine, it might be worth checking out.

How Advanced is Asgard - MCU

Realm Eternal, Asgard, the home world of Thor and Asgardians, is an interesting world. Some cultures believe Asgardians to be gods. In that metric, is that haven? In the Marvel Cinematic Universe, it is clear, they are just an intelligent civilization. This begs the question how advanced are they?

Quantify Advancement of Civilizations

Different civilizations will have different priorities and invent different technology at different times. How ever any civilization would generate/consume power. Based on the generation of power we could categorize civilizations. This was introduced by Russian astrophysicist Nikolai Kardashev (1964).

  • Type 1: A civilization that can harness all the energy that falls on its planet from its star. We Humans are not Type 1 yet.
  • Type 2: A civilization that can harness all the energy of its star using some thing like a Dyson sphere.
  • Type 3: A civilization that can harness energy of galaxies
  • Type 4: A civilization that can control the entire universe
  • Type 5: A civilization that can control collections of universe (multiverse)
  • Type 0: A civilization that doesn’t rank in this scale. Their actions will be indistinguishable from nature. Some thing god like.

What do we know…

Lets rule out what is impossible.

From what is visible in the comics, they are clearly not Type 4, 5 or 0. By definitions such civilizations are resilient to destruction with the amount of energy at their disposal. Regnarok is the distraction of the world by some mythical creature.

Clearly they are Type 2 or above. Why so? Well there are 2 points.

One, Nidavellir. That is the place where Thors Hammer was made and also the new Stone Breaker. While Odin said that they were forged in the hart of a tying star, if you look at the movie, its more like a Dyson Sphere channelling the collapsed stars energy to a forge.

Point two, the Bifrost, the bridget Asgardians use to travel between worlds. It kind of is like a wormhole. Wormholes cost a lot of energy to make and from what I remember it is in the scale of stars. Which means, at their disposal is more than 1 star of energy.


With this we can rule out Type 1. This is because they use consume energy in magnitudes what a star can produce. This leaves Asgard to be either a Type 2 or Type 3 civilization.

The physics around Asgard ois quite exotic. It is a flat surface. There is some sort of gravity that holds on the atmosphere and its water from falling over the edge. Its more like a floating spaceship with emulated climates. Does it mean that they origin from another planet or a galaxy? If so what happened? Did a war destroy it?

If their original habitat was destroyed, its likely a result of a war, with another Type 3 civilization or themselves. Otherwise they are a Type 2 civilization advancing towards been a Type 3 civilization.

What do you think?

Moment Lenses in Sri Lanka

I heard about Moment lenses from a few YouTube personalities. But I was never convinced to to get one. I believed it would be a waste of money and that the image quality would be bad. Today I stand corrected. The image quality of moment lenses is good, I don’t fully agree with the price though.

If you are interested in some moment lenses; the chances are that you have looked locally without success. Fortunately they ship internationally through DHL. That is what I did. It came to SL in a matter of days but got stuck in customs for longer. I paid almost Rs. 10,000/= in duty and charges on top of a purchase which was about Rs. 70,000/= (including shipping). I ordered the macro lens, super fish lens, and wide lens with a S9+ case from B & H Photo.

A few friends told me ship it to their address and that they will ship it them selves or bring it when they come to SL.

But, I think DHL is a safe and quick way to get the products. I got it within a week even with the customs interference. I used the Super Fish lens to shoot video of a get-together. I am personally happy to pay extra for a speedy and premium service. If you are interested in saving some Rupees and Cents, I suggest you rethink your supply chain, at least for this purchase.

Billing Details Breakdown


  • Customs duty: 1635.00
  • Port and airport development levy: 4222.00
  • Value added tax: 1210.00
  • Import cess: 30
  • Nation building tax: 1357.00

DHL charges…

  • Computer fees: 550
  • Documentation charges: 500
  • Nation building tax on documentation charges: 10.00
  • VAT on documentation charge: 77
  • Duty disbursement: 180