Wednesday, 26 July 2017

Steampunk Name generator in AWK

Based on an image out there, can't find the original link ( it is on pinterest  )
example:

./spname simon 24-07-1975 M
 Well, I say there, Earl Neville Wakechild. You are 42.0088 years old.

or

./spname fiona 17-12-1981 F
Well, I say there, Madam Theodora Witherdale. You are 35.6079 years old.


#!/usr/bin/awk -f
BEGIN { 
TITLE["0M"]="Duke";
TITLE["1M"]="Captain"; 
TITLE["2M"]="Earl"; 
TITLE["3M"]="Viscount"; 
TITLE["4M"]="Baron"; 
TITLE["5M"]="Sir"; 
TITLE["6M"]="Chief Inspector"; 
TITLE["7M"]="Colonel"; 
TITLE["8M"]="Lord"; 
TITLE["9M"]="Professor"; 
TITLE["0F"]="Duchess"; 
TITLE["1F"]="Captain"; 
TITLE["2F"]="Dame"; 
TITLE["3F"]="Countess"; 
TITLE["4F"]="Baroness"; 
TITLE["5F"]="Madam"; 
TITLE["6F"]="Chief Inspector"; 
TITLE["7F"]="Colonel"; 
TITLE["8F"]="Lady"; 
TITLE["9F"]="Professor"; 

FIRSTNAME["AM"] = "Lionel";
FIRSTNAME["BM"] = "Basil";
FIRSTNAME["CM"] = "Theodore";
FIRSTNAME["DM"] = "Stanley";
FIRSTNAME["EM"] = "Cyril";
FIRSTNAME["FM"] = "Ebenezer";
FIRSTNAME["GM"] = "Fergus";
FIRSTNAME["HM"] = "Gilbert";
FIRSTNAME["IM"] = "Humphrey";
FIRSTNAME["JM"] = "Ambrose";
FIRSTNAME["KM"] = "Jasper";
FIRSTNAME["LM"] = "Wilfred";
FIRSTNAME["MM"] = "Leopold";
FIRSTNAME["NM"] = "Roderick";
FIRSTNAME["OM"] = "Cuthbert";
FIRSTNAME["PM"] = "Victor";
FIRSTNAME["QM"] = "Llewellyn";
FIRSTNAME["RM"] = "Montague";
FIRSTNAME["SM"] = "Neville";
FIRSTNAME["TM"] = "Archibald";
FIRSTNAME["UM"] = "Cornelius";
FIRSTNAME["VM"] = "Percival";
FIRSTNAME["WM"] = "Rupert";
FIRSTNAME["XM"] = "Septimus";
FIRSTNAME["YM"] = "Algernon";
FIRSTNAME["ZM"] = "Vernon";

FIRSTNAME["AF"]="Josephine"; 
FIRSTNAME["BF"]="Eugenie"; 
FIRSTNAME["CF"]="Violet"; 
FIRSTNAME["DF"]="Agatha"; 
FIRSTNAME["EF"]="Marguerite"; 
FIRSTNAME["FF"]="Theodora"; 
FIRSTNAME["GF"]="Gwendoline"; 
FIRSTNAME["HF"]="Emmeline"; 
FIRSTNAME["IF"]="Winifred"; 
FIRSTNAME["JF"]="Fanny"; 
FIRSTNAME["KF"]="Adelaide"; 
FIRSTNAME["LF"]="Ursula"; 
FIRSTNAME["MF"]="Henrietta"; 
FIRSTNAME["NF"]="Lenore"; 
FIRSTNAME["OF"]="Clementine"; 
FIRSTNAME["PF"]="Millicent"; 
FIRSTNAME["QF"]="Amelia"; 
FIRSTNAME["RF"]="Prudence"; 
FIRSTNAME["SF"]="Dorcas"; 
FIRSTNAME["TF"]="Lavina"; 
FIRSTNAME["UF"]="Wilhelmina"; 
FIRSTNAME["VF"]="Mildred"; 
FIRSTNAME["WF"]="Gertrude"; 
FIRSTNAME["XF"]="Beatrice"; 
FIRSTNAME["YF"]="Augusta"; 
FIRSTNAME["ZF"]="Constance"; 

LASTNAME1[0]="Rumble"
LASTNAME1[1]="Wither"
LASTNAME1[2]="Clanking"
LASTNAME1[3]="Worthing"
LASTNAME1[4]="Addle"
LASTNAME1[5]="Wake"
LASTNAME1[6]="Wraith"
LASTNAME1[7]="Roth"
LASTNAME1[8]="Knight"
LASTNAME1[9]="Supper"

LASTNAME2[1]="bottom"
LASTNAME2[2]="ton"
LASTNAME2[3]="stone"
LASTNAME2[4]="feather"
LASTNAME2[5]="topper"
LASTNAME2[6]="waddle"
LASTNAME2[7]="child"
LASTNAME2[8]="field"
LASTNAME2[9]="wood"
LASTNAME2[10]="hold"
LASTNAME2[11]="fellow"
LASTNAME2[12]="dale"

if (ARGC == 4) {
 if (NAME=="" ) NAME = toupper(ARGV[1])
 if (DOB=="" ) DOB=ARGV[2]
 if (G=="")  G = toupper(ARGV[3])


firstletter=substr(NAME,1,1)

YEAR=substr(DOB,7,4)
MONTH=substr(DOB,4,2)
DAY=substr(DOB,1,2)
#print YEAR" " MONTH" "DAY
lastdigit=substr(YEAR,4,1) 
NEWDAY = mktime( YEAR " " MONTH " " DAY " 0 0 0" );

AGES  = (systime()-NEWDAY)/(31557600.00)
AGEUNIT=substr(AGES,2,1)
DOW = strftime("%w",NEWDAY);

printf "Well, I say there, "
printf "%s %s",TITLE[AGEUNIT G],FIRSTNAME[firstletter G]
printf " %s%s. ",LASTNAME1[lastdigit],LASTNAME2[MONTH+0]
printf "You are %2.2f years old.\n",AGES 
} else { 
 print "Usage: spname Firstname dateofBirth(dd-mm-yyy) Gender(M/F)"
}
}


Reading

Stormdancer by Jay Kristoff

Friday, 21 July 2017

Man on the moon

On This Day:  Man on the moon,  Apollo 11

Tuesday, 11 July 2017

Windward Bound leaving

The Windeward Bound leaving the Tamar River, seen from Windmill Point ,George Town , Tasmania