Wednesday, 31 July 2013

Things Fall Together, and FNB

When I booked my Schengan Visa appointment with VFS yesterday, I didn't put much thought into the appointment time. Given the choice, I skipped over everything before 9 AM in the online booking form (I'm still a skeptic, and am not convinced that times earlier than this actually exist), and chose 9.30. Had I thought more about it, I'd have chosen 3 PM to keep things properly civilized. Had I thought more about it, I would probably be going back for attempt two tomorrow, instead of managing to finalise it today.

I hadn't been able to find a convenient check list for a Schengan Visa. I had a general idea of what I needed from when I did this in 2010. Unsurprisingly, with hindsight, I was missing some ever-oh-so-important documents. These missing documents included air tickets, travel insurance, and original bank statements (Seems kind of obvious now, doesn't it?). Somehow I thought that if the UK consulate was happy with my documents (and they'd already indicated that they were by stamping a delightful visa into my worthless Green Mamba passport), that the Austrians would be too. I mean, they're not even Austrians anymore -- both visas were done through VFS Global, and all the staff I interacted with were all South African -- so I thought I wouldn't have to worry about any stereotypical Austrian order.

But no. Copies of bank statements are not good enough. Copies could be, well, copied? Perhaps someone at the Pretoria Consul has a fetish for sniffing original bank stamps. Maybe it's just another obstacle to weed out a few more of us nauseating tourists. Only let the determined ones in. Jawohl.

Luckily my terrific Dad managed to organize travel insurance in a time comparable to a Usain Bolt hundred meters. He also phoned the premier FNB banking service, and had someone call me to arrange to collect the bank statements (with the scented stamp) at a Cape Town branch. Unluckily, the better half of me was still absent, as my Samsung S3 was in for repairs. This meant that I had to find things the old fashioned way (in my case, wandering round in circles until after several passes things begin to look familiar and then moving on to new territory). I eventually found and entered an internet cafe, booked some provisional flights out of Schengen territory, downloaded the insurance docs, printed everything off, and left.

Tried to leave, that is. My fingers were stuck to the revolting keyboard, and one of the many crapware toolbars had come alive and try to bite me, while Windows XP just sat back and cheered it on. Eventually I got out, making a mental note to change my Gmail password ASAP. That seemingly helpful guy from Premier hadn't phoned me back yet to confirm which branch I should go to, but I'd already got Google Maps to do that for me, so I started meandering FNBwards.

I got to FNB and still no phone call, so I went in to look for someone willing to make my problems their problems. The daemons that be picked on a certain Merlane and the poor woman came to ask me how she could help. Having heard my story, and being unable to trace my consultant friend from Premier, we decided to start over, and Merlane did not bat an eyelid as a complicated string of phone calls took place. Outdated numbers, forgotten security protocols, even an entanglement with the Dwyer Home Phone, and she finally managed to get hold of Dr Dwyer Himself, on a number which I had produced from thin air. Even though it obviously crossed her mind more than once that this could all be part of some elaborate plot for me to get my nose on some of that fragrant FNB ink, Merlane acted the perfect host, making idle small-talk while waiting for ringing phones to be answered. She mentioned with a laugh that normally they would not be able to hand bank statements to anyone but the account holder, but that obviously in this case she would make a plan. Within 20 minutes of walking into FNB, I left with stamped statements. I told Merlane that FNB had just won a loyal customer for life, and walked down the street handing out FNB flyers and telling all and sundry that they should change to FNB now (in spite of their new online banking site).

The new documents were accepted, and I left with a debit card noticeably lighter after they'd deducted various visa fees, processing fees, courier fees, and stamp sniffing fees.

I got back, and remembered to acknowledge FNB's service a complimentary tweet. I started reading the day's emails (Email once a day is still something very strange to me. Luckily my phone should come back in under 48 hours), and was surprised to find the following from FNB

Good day, Mr Gareth Dwyer 

The statements needed for your applciation for VISA, Cape Town branch are unable to grand statements as your father is needed at the branch with you.
You being in seperate towns, it is still not viable to get the statements without your father as he is the account holder and you the dependant.

Regards
Mpumi
Mpumelelo Bohali

This email had arrived at 3 PM, and didn't fully explain why I hadn't got the phone call from Premier.  By the time they'd sent this, my bank statements were probably en route to Pretoria. In presentation, punctuality and punctuation this provided such a stark contrast to the experience I'd just had with Merlane that I had to quickly unplug the router and take my Gran shopping, as my fingers were already halfway through typing out a reply full of nasty language and insults. In the evening, once I'd eaten supper and finished scraping paint violently off Gran's front step, I composed something less emotional.

Dear Mpumelelo,

I do not bank with FNB to receive emails such as this one. I do not bank with FNB to be told that my requests are not viable. I do not bank with FNB to be labeled "a dependent", especially when this is irrelevant to my request.

If I wanted service like this, I would bank with Standard Bank, or ABSA, where bad service is considered normal.

Luckily, my request was handled by the Adderley Branch pleasantly and efficiently, exactly as I would expect from a bank with the reputation of FNB, and I received the bank statements I needed before you sent the email saying this is "not viable".

Your email was the only blemish in my otherwise very positive experience with FNB today. 

I am disappointed by your attitude.

Yours faithfully,
Gareth Dwyer

We'll see if he deigns to reply. I almost hope that he tries to defend himself, like Imaginet did after they overcharged me for my domain and then emailed me with a similar attitude. I had a lot of fun then, but that was in January. A renewal is needed. And yes, there is indeed a direct correlation between number_of_snotty_letters_I_write and number_of_days_since_my_vacation_began. Well spotted.

Friday, 19 July 2013

Four weeks at Korbitec

Today was my last day of work for my internship at Korbitec. "Was" because today they asked me to stay on. So I sold my soul and agreed to carry on working at a desk job, partly because of the good pay,  and partly because I'm enjoying it.

While waiting for databases and ideas to load, I've discovered some great stuff around the interwebz. Top of this list is definitely joelonsoftware. I've read most of Joel's website now and I think I agree with nearly everything he says. Something which hasn't happened since I watched the three Ken Robinson TED talks on education and creativity.

You're back? Actually I assume you never left - if you'd visited the four URLs provided in the previous paragraph, you'd probably still be link-hopping. Well, not hinting or anything, but I found this Ubuntu Bug well worth a look: Open Office would not print on Tuesdays. And in case you're still around, take a look at this RFC for a hyper text coffee pot control protocol.

Apart from procrastinating, I have also been writing the if (statements) and while (loops) which Korbitec want. I even had a code review to prove it - an experience which gives a similar adrenaline kick to playing a practical music exam. Several developers nit-picked their way through the code I presented to them, arguing over best practice and style.

Outside work, I've been playing Ingress, which is a great game and good way to meet people in a new town. As long as you like meeting the sort of person who plays Ingress. I've also had my first (half) Gatsby (pic from Google Images, but it gives a good idea) and entered into the Marcel's vs Wakaberry debate. I could almost believe that I'm in a foreign place sometimes.
















Sunday, 14 July 2013

Getting a simple Flask app running on Amazon EC2

For my first internship, with cablekiosk.co.za, I wrote a simple Flask webapp to keep two databases synced. This app was hosted on an EC2 instance, and I found the tutorial below one of the most helpful ones in setting up Flask and Apache2 on an EC2 ubuntu instance. After creating another EC2 instance today, I looked for the article and found that the site it was hosted on, tangents.co, was no more. Luckily there was still a copy of the article in a GitHub repo (https://github.com/yolesaber/micromtn/blob/master/articles/HostingWithApache.md), but here it is again.

Get Your Flask Apps Up And Running Fast on EC2

Lately there have been a spate of articles detailing how to deploy Flask applications on Amazon Web Server's EC2 instances. However, when I followed these guides to deploy this very website, I often ran into errors, omissions, and edge cases that were not covered by the article. Hours of yak-shaving ensued. The application I wanted to host was not a massive project - it was a simple blog! It didn't really make much sense to me that hosting it should be such an endeavor, especially considering how swift Python development usually is for me.
Essentially this article exists as a quick antidote to such pains. I am going to show how you, dear reader and aspiring Python webdev, can get your Flask app running on the net.

Prerequisites

  • You have an AWS account with an EC2 instance running Ubuntu
  • Python and Flask are installed on this system
  • Your Flask source is stored in a git repo
  • You have not gone blind by the time you reach the end of this sentence.

Geronimo!

Log in to your EC2 instance (Usually done through an SSH connection) and type the following command:
sudo apt-get install apache2 libapache2-mod-wsgi
This installs our webserver, Apache2, as well as a Python WSGI module. Don't worry if you do not know what a "WSGI module" is right now; you can learn about it here. Essentially what it does is hand over Python's built-in webserver duties to Apache.
If you point yourself to your EC2 domain (either the DNS address you used to connect to your server via SSH or a URL you have pointed towards it), you will see a welcoming message from our good, if homely friend, the Apache webserver. Lets get your Python app on there.
Type the following:
sudo mkdir /var/www
cd /var/www
sudo git clone url://to.your.git.repo
cd yourgitrepo
sudo nano yourflaskapp.wsgi
The .wsgi file should match the name of the Python file containing the "yourflaskapp = Flask(__name__)" line. Make sure that in this file (the main python file, not your newly-created .wsgi file), you have any yourflaskapp.run() calls contained within the "if __name__ == '__main__':" clause. Otherwise, your app will be starting a local WSGI server instead of forwarding it through mod_wsgi and Apache.
The yourflaskapp.wsgi file is simple and should look like the following:
import sys
sys.path.insert(0, '/var/www/yourgitrepo')

from yourflaskapp import yourflaskapp as application
Note that 'application' is NOT a placeholder name. If you do not import it as that, mod_wsgi will spit up on you.
Now, type the following commands:
cd /etc/apache2/sites-available/
sudo nano sitename.com
where sitename.com is whatever you want your site to be called. The contents of this file should look like this:
<VirtualHost *:80>
         WSGIDaemonProcess yourflaskapp
     WSGIScriptAlias / /var/www/yourflaskapp/yourflaskapp.wsgi

     <Directory /var/www/yourflaskapp>
            WSGIProcessGroup yourflaskapp
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
     </Directory>
</VirtualHost>
Then all that is left do is disable the Apache default page and enable your Flask app:
sudo a2dissite default
sudo a2ensite sitename.com
sudo /etc/init.d/apache2 restart
Now if you navigate to your page, you should see your Flask app up and running. Congrats. That took about 10 minutes, I hope. Of course, this just barely scratches the surface of the power and flexibility of apache2 and mod_wsgi, but those are topics you and I will be exploring more as we go on to build bigger web apps.
The beauty of this approach is not only that it is fast and relatively painless (I could write a shell script that would make this a 10 second process...hmmm), but it is also quite modular. Simply rinse and repeat these steps for individual apps and you can switch between them using a2dissite and a2ensite. If you have more than one URL redirecting to the EC2 instance, you can configure Apache2 to serve each one by way of creating unique sitename.com configs as done above.
If you have any questions, be sure to email me at me.anzuoni at gmail dot com or hit me up on my Twitter, @SexyUlysses.