Sunday, July 31, 2016

Summer and Life Cycle

The Bahamian conch salad from the Da Fish Fry
Sri Lanka really does not have these periods. The first time "summer" made some sense or difference to me was 2009. I applied and got selected for my first Google Summer of Code as a student with AbiWord. It was so exciting, and unlike now, I was somewhat new to the open source. Not entirely new, since I had already done some localization work (I had localized Squirrelmail to Sri Lankan Tamil, along with a few of my friends). Also I was an intern at WSO2, a Sri Lankan open source company (which also mentors GSoC students these days at a large scale, as a mentoring organization). Following 2009, I was always involved in GSoC, either as a mentor or a student.

But it was 2012 when I really got to know how does a summer feel like, and was able to differentiate it with other seasons. That was when I came to Portugal for my Erasmus Mundus masters program EMDC. Coming from a hot and humid country, Lisboa's summer was mild to me and it felt comforting.

Europe always had its beauties with seasons. I did not like winter in Portugal particularly as it was too wet. Similarly, I was not a fan of Swedish' dark winters either. However, I miss the snow.

Though I did not experienced seasons beyond sunny days and rainy days, I did have the days - weekdays and weekends. During the school days, we still had tuition classes during the weekends. That effectively made us busy almost 7 days a week. So there was no real weekend till I joined the university. However, at the latter years of my bachelors, I had classes even on Saturdays, leaving us with only Sunday as a free day.  When I joined the industry, I really had the weekends off.

Crystal clear water of Nassau
Same was true with my masters too. However, with the increased autonomy I have with my PhD in Portugal, I am actually free to choose my own timing. I tend to work in weekends when I want to. On the other hand, if I decide to go for a movie, I can always go ahead any time instead of waiting for the weekend. When I had paper submission deadlines approaching, I tend to work 7 days a week, and love it!

Atlanta's summer is hot and humid. Just like Sri Lanka. When you come out of office, you will feel like entering a sauna. Also the rainy days! Coming from Portugal, it felt weird to have thunderstorms in summer. Summers are supposed to be dry. ;)

US has holidays arranged in a strategic way to have them on Mondays or Fridays to allow long weekends. During my short stay here, I have experienced 3 long weekends, if I counted it right. Weekends I often use for buying food or doing some minor fun activities - except for the long weekends - when I can go somewhere farther such as the Bahamas.

I am a proud gypsy student since 2012. It has its positives and negatives. Positives - I got to experience new places and new people, and always make me feel young. Negatives - time wasted in bureaucracies and installation costs (such as buying the basics for the new accommodation).

As I walk on the lanes from my lab in the late evening, I always think of random things. I recall many things - to be worth of blogging down - both technical and non-technical. I end up not writing majority of them. Writer's block, if I may say so. That's why I keep a list of future blog posts!

It is interesting to note that in the recent past my "thinking language" has been shifted to English from Tamil. It is because of my limited reading, writing, and communicating in Tamil in foreign lands. However, I still enjoy my Tamil songs and movies from South India! I like musics and music videos. They always bring back memories from the past - the first time I heard the song! I am sure now I have many good memories from Atlanta as well, with more music and more diverse technical experience.

Proxy humans - The worst kind of social media users!

A useless image disguised as a "helpful resource"
Something I dislike about many social media users - specifically when they do that on LinkedIn - sharing content with no way to trace back to the origin. Some users are just plain novice and they do so without knowing the ways to propagate the information in the right way. For example, see the viral image on the left hand side. It was shared by millions of such novice users. But who creates these images? Are they social media novices too? No, they surely are not. These are social media crocodiles who create these "information" just for the sake of getting more visibility. If you were fortunate/unfortunate to witness this image, you would have noticed that there was no caption or pointers to where to find the MIT's online course material. Of course, a quick Google search would reveal that. But the intention here is not to help (as it seems); rather to make this particular image itself popular/viral.

The worse offenders are those who copy-paste others' content without giving the credit or link to the original post. Some would argue that they are sharing knowledge here. Some might really be unaware of the "Share" mechanisms present in all the social media. However, most are deliberately plagiarizing. They function as a proxy human between the knowledge source and the public, preventing access to the source of information, by functioning as a proxy in the middle. 

Next time, when you spot a proxy human in social media, please do not engage with them much under their post. The more their post get engaged, higher the possibilities that it will eclipse the origin.

Tuesday, July 26, 2016

Setting up Tyk Portal and Developer Registrations

There was this long running bug that is hitting us from setting up the Tyk portal. The issue was with Tyk not allowing custom domains from being set up as portal. While the settings as advised in Tyk mention the dashboard and portal port as 3000, ideally it should be set as 80 to get the portal configured seamlessly. I learned it hard-way after so many attempts on getting this done on port 3000.


Setting up Portal Domain
Add to /etc/hosts file:
127.0.0.1 dashboard.tyk-local.com
127.0.0.1 portal.tyk-local.com
Most probably Apache2 or some other web server would already be listening on the port 80. Make sure to stop it to release the port.

Stop Apache2 Web Server

/etc/init.d/apache2 stop

Configure Tyk Gateway

sudo /opt/tyk-gateway/install/setup.sh --dashboard=http://dashboard.tyk-local.com --listenport=8080 --redishost=localhost --redisport=6379 --domain=""


Configure Tyk Dashboard

sudo /opt/tyk-dashboard/install/setup.sh --listenport=80 --redishost=localhost --redisport=6379 --mongo=mongodb://127.0.0.1/tyk_analytics --tyk_api_hostname=127.0.0.1 --tyk_node_hostname=http://127.0.0.1 --tyk_node_port=8080 --portal_root=/portal --domain="dashboard.tyk-local.com"


Configure Tyk Pump

sudo /opt/tyk-pump/install/setup.sh --redishost=localhost --redisport=6379 --mongo=mongodb://127.0.0.1/tyk_analytics


Initial start to set up the Tyk license


sudo service tyk-pump start
sudo service tyk-dashboard start

Access http://dashboard.tyk-local.com/ and add the license in the prompt.

Restart the Tyk Dashboard and start the Tyk Gateway
sudo service tyk-dashboard restart
sudo service tyk-gateway start


Fix the Tyk bootstrap script to listen at port 80

gedit /opt/tyk-dashboard/install/bootstrap.sh and remove :3000 from all the references, since we are going to use the default port 80, instead of port 3000 as the dashboard port.


#!/bin/bash
# Usage ./bootstrap.sh DASHBOARD_HOSTNAME

LOCALIP=$1
RANDOM_USER=$(env LC_CTYPE=C tr -dc "a-z0-9" < /dev/urandom | head -c 10)
PASS="test123"

echo "Creating Organisation"
ORGDATA=$(curl --silent --header "admin-auth: 12345" --header "Content-Type:application/json" --data '{"owner_name": "Default Org.","owner_slug": "default", "cname_enabled": true, "cname": ""}' http://$LOCALIP/admin/organisations 2>&1)
#echo $ORGDATA
ORGID=$(echo $ORGDATA | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["Meta"]')
echo "ORGID: $ORGID"

echo "Adding new user"
USER_DATA=$(curl --silent --header "admin-auth: 12345" --header "Content-Type:application/json" --data '{"first_name": "John","last_name": "Smith","email_address": "'$RANDOM_USER'@default.com","password":"'$PASS'", "active": true,"org_id": "'$ORGID'"}' http://$LOCALIP/admin/users 2>&1)
#echo $USER_DATA
USER_CODE=$(echo $USER_DATA | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["Message"]')
echo "USER AUTH: $USER_CODE"

USER_LIST=$(curl --silent --header "authorization: $USER_CODE" http://$LOCALIP/api/users 2>&1)
#echo $USER_LIST

USER_ID=$(echo $USER_LIST | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["users"][0]["id"]')
echo "NEW ID: $USER_ID"

echo "Setting password"
OK=$(curl --silent --header "authorization: $USER_CODE" --header "Content-Type:application/json" http://$LOCALIP/api/users/$USER_ID/actions/reset --data '{"new_password":"'$PASS'"}')

echo ""

echo "DONE"
echo "===="
echo "Login at http://$LOCALIP/"
echo "User: $RANDOM_USER@default.com"
echo "Pass: $PASS"
echo ""


Save and exit the bootstrap script and execute it.

sudo /opt/tyk-dashboard/install/bootstrap.sh dashboard.tyk-local.com



root@llovizna:/home/pradeeban#  sudo /opt/tyk-dashboard/install/bootstrap.sh dashboard.tyk-local.com
Creating Organisation
ORGID: 579794145ee8571e46000001
Adding new user
USER AUTH: 6936a780a8e448fd73e3d7ef64eb8059
NEW ID: 5797941458149ac06a14e801
Setting password

DONE
====
Login at http://dashboard.tyk-local.com/
User: c9og13fnc8@default.com
Pass: test123

Tyk Developer Portal
Now you are good to log in to the Tyk Dashboard with the given credentials.

Set Portal domain
portal.tyk-local.com

This would give a message, "CNAME updated"
Now if you access http://portal.tyk-local.com/portal/ it would says "Home page not found". This is expected as you have not set up the portal and the welcome page yet. 

Follow the below document to get this set up.

Once you have set this up, your portal is ready for the developers to register, log in, and consumes the APIs defined in the API catalogue.

Monday, July 11, 2016

Tyk Dashboard crashed after setting the portal domain

So I set the portal domain to be as the same with the dashboard. Later, I was instructed that it is not permitted to have the portal domain same as the dashboard.

However, now I am left with the below error which does not simply disappear when I reconfigure Tyk.

panic: http: multiple registrations for dashboard.tyk-local.com:3000/

goroutine 1 [running]:
panic(0xa60f80, 0xc820370be0)
    /usr/local/go/src/runtime/panic.go:464 +0x3e6
net/http.(*ServeMux).Handle(0xc820356d50, 0xc82036f7e0, 0x1d, 0x7f5a221595d8, 0xc82027af20)
    /usr/local/go/src/net/http/server.go:1926 +0x297
main.GenerateRoutes()
    /home/tyk/go/src/github.com/lonelycode/tyk-analytics/Main.go:733 +0x41b7
main.main()
    /home/tyk/go/src/github.com/lonelycode/tyk-analytics/Main.go:750 +0x59


I basically had to drop the Mongo table, and then reconfigure Tyk to get everything back in place.

In Mongo shell:
> use tyk_analytics
switched to db tyk_analytics
> db.dropDatabase();
{ "dropped" : "tyk_analytics", "ok" : 1 }

Sunday, July 10, 2016

Long walks of a gypsy student

Flowers on my way, Atlanta
I was attending a conference in San Francisco, and one of my peers reminded me that I did not blog much recently. I realized, that is because of the limited time, and also I am getting used to rapid changes. When I came to Portugal in 2012, everything seemed fresh, and moving to a foreign country for the first time made me feel like I was reborn or starting my life afresh. However, after living in 2 other countries (Sweden and Croatia), I came to the US which is in fact my 4th country to live outside Sri Lanka. These international travels, and frequent migrations all has become part of our life.

Since we always have to be ready for our next migration, we also learn to live light-weight. I did not purchase unnecessary large items recently. More like a life of a monk. :) In addition to my past migrations, we are getting back to Portugal in October. Then I have to join my second host institution in Belgium. There have been a discussion on moving to Saudi Arabia for a short term internship, and all so many plans with travels across 4 countries in 3 continents.

Frequent migrations also is like getting fresh blood. Throwing all the old stuff in the country and moving on to a new country to start everything afresh. You have the potential to get new friends and almost make a new identity. However, it comes with a cost. Life gets more expensive. Not just for the flight tickets and other travel costs. Rather, short-term rentals of apartments and phone/internet contracts are more expensive. Moreover, the definition of friends changes. I have been on the move, or my newly made friends are on the move. So it is hard to find friends who stay longer than 6 months with me physically. However, I have made acquaintances spreading across the globe, thanks to my mobility. Should mention however, such a gypsy life comes with an additional cost of lack of stability, which itself is somewhat adventurous.

View from my hotel room in Areeiro, Lisboa - early summer, 2016
Probably I should write a book or something when time permits. "4 countries 3 continents. A year in the life of a modern day gypsy student." I am not even sure which city and country are we going to celebrate the new year this time. Since I moved to Portugal in 2012, it has always been Lisboa.

Some walks are always remarkable and hard to forget. To mention a few: my nightly walks from my office in Colombo to the bus stop through Flower Road (2010 - 2012), my walks to IST from my apartment in Lisboa (2012 - 2013), long forest walks in Stockholm/Farsta Strand (2013), long walks to our apartment in Benfica Lisboa (2015), zig-zag walks in Rijeka since the sidewalks are present only on one side and at intervals (2015), and now my daily walks to the lab from our apartment in Atlanta. I should note that I am good at walking - long distances. :) Since I walk or use public transport almost always, I can be confident that my carbon footprint always remained minimal - unlike those stars who fly in private jets and then plant some trees and go on preaching. :)

I should however note that Atlanta is not pedestrian friendly. There are streets with no pedestrian paths or side walks. You may be walking leisurely in a side walk, which would end abruptly in the street, where you will be forced to walk amid the traffic. Sudden installation of water pumps by the apartments along the side walks that will soak you as you walk along. If you are careful, you will still have to cross the street. Worse, there are not enough crosswalks, with fast moving traffic. Some pedestrian walks are damaged or never was implemented concretely. Apartment owners parking their long vehicles across the pedestrian walks blocking the way. Bus stops in the middle - with no sidewalk in one side with no crosswalk to reach the other side that has the sidewalk. Overall, no one paid attention to the pedestrians in a developed city. No walk - then drive to the gym for a treadmill. Despite all these rants, I still love my daily walk. Running squirrels and chipmunks. Hot and humid summer making you feel that you just reached a sauna. Dense vegetation still could not relieve the hot sunlight. No pollution. All good.

There are some events or time intervals in the past that always remain the best of the memories - such as the 2013 year end in Nordic countries and 2015 summer in Balcans. That reminds me that I miss the summer in Europe.

Wednesday, July 6, 2016

Tyk 2.0 in Centos

There are some minor changes in setting up Tyk 1.9 and Tyk 2.0, and also some differences between setting up on Ubuntu vs Centos.

Installing Tyk 2.0 on Centos is described here.

sudo /opt/tyk-gateway/install/setup.sh --dashboard=http://lion.bmi.emory.edu:3000 --listenport=8080 --redishost=localhost --redisport=6379 --domain=""


sudo /opt/tyk-dashboard/install/setup.sh --listenport=3000 --redishost=localhost --redisport=6379 --mongo=mongodb://127.0.0.1/tyk_analytics --tyk_api_hostname=localhost --tyk_node_hostname=http://localhost --tyk_node_port=8080 --portal_root=/portal --domain="lion.bmi.emory.edu"



sudo /opt/tyk-pump/install/setup.sh --redishost=localhost --redisport=6379 --mongo=mongodb://127.0.0.1/tyk_analytics


sudo service tyk-pump start
sudo service tyk-dashboard start

http://lion.bmi.emory.edu:3000/


sudo service tyk-dashboard restart
sudo service tyk-gateway start


sudo /opt/tyk-dashboard/install/bootstrap.sh  lion.bmi.emory.edu