The source code history of Free Pascal and Lazarus visualized with Gource

Gource is a software version control visualization tool. I thought it would be fun to visualize Delphi’s source code with Gource, but that is not possible for obvious reasons. So, I decided to try-out Delphi’s cousins: Free Pascal and Lazarus.

I checked-out the respective code bases and ran them through Gource.

Below are the Gource commands I used:

gource -1280x720 -o C:\\gource\\fpc.ppm -s 0.01 --hide dirnames,filenames,progress,mouse C:\\gource\\fpc

gource -1280x720 -o  C:\\gource\\lazarus.ppm -s 0.01 --hide dirnames,filenames,progress,mouse C:\\gource\\lazarus

Gource shows the filenames and directories of the source code by default; still, I decided to hide them in these videos, because they were overlapping. You can play more with Gource, FPC and Lazarus on your own :-) For a comprehensive list of the command line options and arguments of Gource click HERE.

The above gource calls create two files: fpc.ppm and lazarus.ppm. I guess these are some kind of uncompressed video format. The files were huge: ~60GB and ~100GB respectively.

Then, I used FFmpeg to encode the above .ppm files into .avi files. The FFmpeg commands are below:

ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i C:\\gource\\fpc.ppm -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -crf 1 -threads 0 -bf 0 C:\\gource\\fpc.x264.avi

ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i C:\\gource\\lazarus.ppm -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -crf 1 -threads 0 -bf 0 C:\\gource\\lazarus.x264.avi

Finally, I uploaded fpc.x264.avi and lazarus.x264.avi to YouTube. You can see them below:

Free Pascal source code history visualized with Gource 



Lazarus source code history visualized with Gource 



If you liked this post; please, show your appreciation but clicking the Google Plus (G+) button at the beginning of the article. Thanks!

How much do you know about your Government? – Toronto, Ontario, Canada.

These are the answers to the questions found in Discover Canada (Citizenship Study Guide) from page 34-35.

The Federal Government part is applicable to all Canada. The Provincial Government part is applicable to Ontario and the Municipal Government part is applicable to Toronto.

Federal Government

Head of State: Her Majesty Queen Elizabeth II

The name of the representative of the Queen of Canada, the Governor General, is David Lloyd Johnston

The Head of Government, the Prime Minister, is Stephen Joseph Harper

The name of the political party in power is Conservative Party of Canada

The name of the Leader of the Opposition is Thomas Joseph Mulcair

The name of the party representing Her Majesty’s Loyal Opposition is New Democratic Party

The names of the opposition parties and leaders are:
  • Liberal Party of Canada: Justin Trudeau
  • Bloc Québécois: Mario Beaulieu
  • Green Party of Canada: Elizabeth May

My member of Parliament(MP) in Ottawa is [See below next to the *]

My federal electoral district is called [See below next to the *]

* Click this link and enter your postal code. This will allow you to find out who your MP is and to which federal electoral district you belong to.

Provincial Government

The representative of the Queen in my province, the Lieutenant Governor, is David C. Onley

The Head of Government (the Premier) is Kathleen Wynne

The name of the provincial party in power is Liberal Party

The names of the provincial opposition parties and leaders are
  • Progressive Conservative Party: Jim Wilson
  • New Democratic Party: Andrea Horwath

My provincial representative is
  • Easter and Northern Ontario Representative: John Baird.
  • Southwestern Ontario Representative: Diane Finley.

Municipal Government

The name of the Municipality where I live is Toronto

The name of the head of the Municipal government (mayor or reeve) is Robert Bruce “Rob” Ford

Canadian Credit Cards with No Foreign Transaction Fee

The Foreign Transaction Fee is the charge applied to your credit card when paying for a service or product in a foreign (non-local) currency. 

The currency in Canada is the Canadian Dollar. If you pay for something in a different currency; let’s say US Dollars, Euros, Pound Sterling, etc., then you might get charged with a Foreign Transaction Fee.

The Foreign Transaction Fee is apparently a big business for banks and other credit cards issuers in Canada. They charge a 2.5% of the amount spent that is NOT in Canadian Dollars. So, be advised that if you pay in US Dollars, Euros, or any other currency that’s not the Canadian currency, then you‘ll get busted with the 2.5% Foreign Transaction Fee.

As far as I know, to this date, the only issuer of credits cards in Canada that do NOT charge a Foreign Transaction Fee is Chase. Chase is an American bank authorized to conduct businesses in Canada.

Chase offers various credit cards with No Foreign Currency Transaction Fee. These are some examples:
  • Amazon.ca Rewards Visa Card
  • Sears Financial™ MasterCard®
  • Marriott Rewards® Premier Visa® Card
  • Sears Financial™ Voyage™ MasterCard®

For the more information about the cards provided by Chase visit: Chase for Canadian customers.

I got myself an Amazon.ca Rewards Visa Card. In the details of the card you can read:

Foreign Currency Conversion: We will bill you in Canadian Currency if you use your account to make a transaction in foreign currency. We will convert it into Canadian currency at the exchange rate set by Visa International in effect at the time we post the transaction to your account. This exchange rate may be different from the rate in effect on the transaction date. We will not charge you any additional foreign currency conversion charge.

This is the card I use whenever I pay for something in non-Canadian dollars; thus avoiding the sneaky Foreign Transaction Fee. You can do the same and save yourself a few bucks ;-)

If you think this post might be useful to others, please, share it by clicking the Google Plus (G+) button at the beginning of this entry. Thanks!

How to buy prescription drugs in Canada prescribed by an international licensed physician

My grandfather who lives in Cuba has Alzheimer. His treatment requires Donepezil, a prescription drug almost impossible to acquire in Cuba.

I live in Canada; and I put myself to the task of acquiring this medicine for him. The main issue is that Canadian pharmacies require a medical prescription in order to dispense Donepezil. So, I asked my family in Cuba to email me a scanned copy of my grandfather Donepezil’s prescription.

After this, I went online and found CanadaDrugs.com; which is an online Canadian pharmacy. This pharmacy is accredited by BBB, CIPA, PharmacyChecker.com, MIPA and HealthPricer.com. These accreditations give CanadaDrugs.com credibility; letting you know that this pharmacy is legal and not another Internet fraud.

I registered online with CanadaDrugs.com and placed an order of Donepezil. I paid with Credit Card, but there are other methods of payment from which you can choose.

After I placed my order, I had to email them my grandfather’s prescription. CanadaDrugs.com accepts prescriptions written by international licensed physicians, preferably in English or Spanish, but they can also translate prescriptions from most other languages.

To be considered valid all prescriptions must contain the following (I know this because I asked them by email prior to placing my order):
  • Prescribing doctor's contact information (i.e. doctor’s first and last name, clinic name and address, fax number, phone number and email address if possible)
  • Patient's name
  • Date prescription was written
  • Medication name
  • Strength
  • Directions for use
  • Dispensing amount
  • Refills
  • Doctor's signature  
CanadaDrugs.com will run some validation on the information provided and if all is ok, then the prescription drug will be mailed to you by postal mail. It took me around a week to get the Donepezil pills that I bought for my grandpa.

I am really glad with the service provided by CanadaDrugs.com. I have placed only one order with them so far, but the purchase process was straightforward and clean. I am planning on refilling my grandpa’s Donepezil pills with CanadaDrugs.com in the near future.

CanadaDrugs.com has also a Referral Reward Program in place. This program seeks to spread the word about the services provided by CanadaDrugs.com by giving money incentives to their customers.

What’s in it for me? If I refer you, I will get 5% of the value of every single order that you place.

What’s in it for you? You will get a 25% discount on your first purchase if you are referred by an active customer of CanadaDrugs.com.  

Let me say it in a different way, if you are not referred, you will have to pay 100% of the price of you first order; but if you are referred by an active customer, you will get a 25% discount; that is, you will be paying only 75% of the original price.

I am an active customer of CanadaDrugs.com; so, I can refer you. Yes, I am making a few bucks if I refer you, but please, note that I am a serious person and I wouldn’t recommend a crappy service just to earn a few dollars.

If you want to place an order through CanadaDrugs.com and you want to save 25% on your first order; then register yourself online by filling this online form

At the end of that form, you will notice that the Referrer's Name is pre-filled with Roberto Osvaldo Alvarez Arias (that’s the name of my grandpa) and the Referrer's Referral Number is pre-filled with 2830871. You must leave that information right there, if you want to be referred by me, hence getting a 25% discount on your first purchase.

Once you have completed your first purchase; you can also refer your friends, family and whoever might be interested in buying through CanadaDrugs.com. This will reward you with some referral money and also, it will help the people you refer to get a 25% discount on their first purchase.

Finally, I want to stress the fact that I recommend CanadaDrugs.com because of the quality and seriousness of their business. I am not doing this just to earn the referral money. The referral money is a nice perk, but the real value is in the simplicity and transparency of buying medicine through CanadaDrugs.com.

How to open a checking account at Tangerine?

Everything at Tangerine is done online… opening a checking account is no different: you can do it in 10 minutes (at the most) from the comfort of your home computer while you are in your pajamas. What I have found so far about Tangerine (formerly ING DIRECT) is that all procedures can be done with an extreme simplicity and from the comfort of your home.

Tangerine calls its checking account: Tangerine Checking Account. It was called THRiVE Chequing Account in the times when the bank was called  ING DIRECT.

Most checking accounts in Canadian banking institutions charge you a monthly fee. This is ridiculous if you ask me: banks are profiting from our own money, but that’s not enough for them: they still charge us a monthly fee for having our own money within their grasp, money from which they are profiting already.

This is what a Tangerine Checking Account has to offer:
  • NO MONTHLY FEES. Ask yourself if your current bank charges you a monthly fee and ask yourself if you should be paying for it?
  • Unlimited transitions: once again, you can perform unlimited transitions at Tangerine for free.
  • Earn interest on the money you put on your Tangerine Checking Account (yes, you heard well: this is a checking account that pays interest, just as saving accounts do).
I am not going to load you with more details…if you want to know more about the benefits of opening a Tangerine Checking Account come here: http://www.tangerine.ca/en/chequing/chequing-account/index.html.

Now, in order to open a Tangerine Checking Account you have to do only TWO things:
  1. Complete an online form that won’t take you more than 10 minutes. I am not exaggerating: this form won’t take you more than 10 minutes to fill. In order to fill the form click here: Open a new Tangerine Checking Account.
  2. Write your initial deposit cheque (payable to yourself) for at least $100, and mail it to Tangerine Bank, 3389 Steeles Avenue East, Toronto, Ontario, M2H 3S8. Note: all new clients of Tangerine opening accounts for at least $100 bucks get a $50 bonus. What does this means? It means that you open your account with $100, but you are credited with $150; so Tangerine welcomes you with $50 bucks.
That’s all: by completing the two steps above you will open a Tangerine Checking Account, that will treat you with unlimited transactions, no monthly fees, saving interests and a $50 bucks welcome gift.

If you have any questions, drop a line in the comments section below. I’ll do my best to answer.

If you think this post might be useful to someone else, don’t hesitate in recommending by clicking the Google Plus (G+) button at the beginning of the post. Thanks!

HMAC functions in Delphi (HMAC_SHA256, HMAC_SHA1)

I came across HMAC (Hash-based message authentication code) functions when developing a RESTful client application in Delphi. The RESTful Web Service API required me to send HMAC_SHA256 signatures (Base64 encoded) with each HTTP request.

HMAC functions take two parameters: a key and a message. The purpose of the HMAC function is to authenticate the message and guarantee the data integrity of the message.

The cryptographic strength of the HMAC function lies on the underlying hashing function that it uses: MD5, SHA1, SHA256, etc.

So, these functions are usually are termed HMAC_SHA256, HMAC_SHA1, HMAC_MD5 to connote the core hashing function being used.

The outcome of a HMAC function is basically an array of bytes, but it is usually represented as a hexadecimal string or encoded as a Base64 string. (The RESTful Web Service API needed the Base64 encoded output).

I Googled around for a bit, but I didn’t get a clean implementation of HMAC_SHA256 in Delphi (encoded as Base64). I glued together the pieces from some questions on StackOverflow and coded an Indy based implementation that uses generics to specify the core hashing function.

Brief description: I created a helper class called THMACUtils. Note that this class uses generics to indicate the hashing algorithm (TIdHMACSHA256, TIdHMACSHA1). Three functions are provided:  the main thing happens in the HMAC(...) function; HMAC_HexStr(...) and HMAC_Base64(...) are simply decorations of the output.

unit HMAC;

interface

uses
  System.SysUtils,
  EncdDecd,
  IdHMAC,
  IdSSLOpenSSL,
  IdHash;

type
  THMACUtils<T: TIdHMAC, constructor> = class
  public
    class function HMAC(aKey, aMessage: RawByteString): TBytes;
    class function HMAC_HexStr(aKey, aMessage: RawByteString): RawByteString;
    class function HMAC_Base64(aKey, aMessage: RawByteString): RawByteString;
  end;

implementation

class function THMACUtils<T>.HMAC(aKey, aMessage: RawByteString): TBytes;
var
  _HMAC: T;
begin
  if not IdSSLOpenSSL.LoadOpenSSLLibrary then Exit;
  _HMAC:= T.Create;
  try
    _HMAC.Key := BytesOf(aKey);
    Result:= _HMAC.HashValue(BytesOf(aMessage));
  finally
    _HMAC.Free;
  end;
end;

class function THMACUtils<T>.HMAC_HexStr(aKey, aMessage: RawByteString): RawByteString;
var
  I: Byte;
begin
  Result:= '0x';
  for I in HMAC(aKey, aMessage) do
    Result:= Result + IntToHex(I, 2);
end;

class function THMACUtils<T>.HMAC_Base64(aKey, aMessage: RawByteString): RawByteString;
var
  _HMAC: TBytes;
begin
  _HMAC:= HMAC(aKey, aMessage);
  Result:= EncodeBase64(_HMAC, Length(_HMAC));
end;

end.

Below there’s an example of how to use the THMACUtils class.

program HMACSample;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils,
  HMAC,
  IdHMACSHA1,
  IdHashMessageDigest;

begin
  try
    Write('HMAC_SHA1("key", "message")'#9#9'= ');
    Writeln(THMACUtils<TIdHMACSHA1>.HMAC_HexStr('key', 'message' ));
    Writeln;

    Write('HMAC_SHA256("key", "message")'#9#9'= ');
    Writeln(THMACUtils<TIdHMACSHA256>.HMAC_HexStr('key', 'message' ));
    Writeln;

    Write('HMAC_SHA1_Base64("key", "message")'#9'= ');
    Writeln(THMACUtils<TIdHMACSHA1>.HMAC_Base64('key', 'message' ));
    Writeln;

    Write('HMAC_SHA256_Base64("key", "message")'#9'= ');
    Writeln(THMACUtils<TIdHMACSHA256>.HMAC_Base64('key', 'message' ));

    Readln;

  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

The console application above looks like this:

HMAC Sample Application Delphi
HMAC Sample Application Delphi

How to obtain an “Option C Printout” for the most recent taxation year?

When you are sponsoring a family member to come to Canada, you are required to provide an Option C Printout of your last Notice of Assessment for the most recent taxation year.

An Option C Printout is not a Notice of Assessment. An Option C Printout is a document that summarizes your income and deductions for a particular taxation year.

How to obtain an Option C Printout?

Call Canada Revenue Agency (CRA) at this number: 1 (800) 959-8281. Sometimes the number is busy; in which case try again a few minutes later until you get connected.

You will be listening to an interactive recorded message; hence, a computer will be doing the talking...

Listen carefully and select the option that allows you to get the Option C Printout.

You will need to type these three pieces of information over the phone:
  1. Social Insurance Number. 
  2. Date of Birth.
  3. Amount of Income you reported on Line 150 of your most recent taxation year.
Make sure you have the information above otherwise the computer won’t be able to authenticate you.

Once you finally enter the info, the automatic system (computer) will tell you that you have succeeded, in which case the Option C Printout will be mailed by postal mail to the address you have on record with the CRA.

For instructions about how to update (change) your address with the CRA refer to the following link:

If you think this information might be useful to others, please, click the Google Plus (G+) button at the beginning of this post.