ContactΒΆ

To contact me, you may use any of the following samples of code to derive my email address.

Basic C using only string manipulation:

#include <stdio.h>
#include <string.h>

int main(int argc, char **argv){
    char *url = "http://www.coglib.com/~icordasc/";
    char email[22];

    memset(email, 0, 22);

    if (!strncpy(email, url + 23, 8)) {
        puts("Cannot copy the username.\n");
        return 1;
    }

    email[8] = '@';

    if (!strncat(email, url + 11, 10)) {
        puts("Cannot copy the domain.\n");
        return 1;
    }

    email[21] = '\n';
    puts(email);
    return 0;
}

C using linux’s (gcc’s) regular expression library:

#include <sys/types.h>
#include <regex.h>
#include <string.h>
#include <stdio.h>

void die(char *prefix, char *msg){
    puts(prefix);
    puts(msg);
    puts("\n");
}

int main(int argc, char **argv){
    regex_t regex;
    regmatch_t matches[5];
    int error, len;
    char pattern[] = ".*\\.(\\w+\\.\\w+)/~(\\w+)";
    char coglib[] = "http://www.coglib.com/~icordasc/";
    char string[80];
    
    memset(string, 0, 80);

    if ((error = regcomp(&regex, pattern, REG_EXTENDED))) {
        regerror(error, &regex, string, 80);
        die("Compilation error: ", string);
        return 1;
    }

    if ((error = regexec(&regex, coglib, 5, matches, 0))) {
        regerror(error, &regex, string, 80);
        die("Execution error: ", string);
        return 1;
    }

    len = matches[2].rm_eo - matches[2].rm_so;
    if (!strncpy(string, coglib + matches[2].rm_so, len)) {
        die("Cannot copy username.", "");
        return 1;
    }

    if (!strcat(string, "@")) {
        die("Cannot append '@'.", "");
        return 1;
    }

    len = matches[1].rm_eo - matches[1].rm_so;
    if (!strncat(string, coglib + matches[1].rm_so, len)) {
        die("Cannot copy domain.", "");
        return 1;
    }

    puts(string);
    return 0;
}

Python using regular expressions:

#!/usr/bin/env python

from re import sub

print(sub('.*\.(\w+\.\w+)/~(\w+).*', '\g<2>@\g<1>',
          'http://www.coglib.com/~icordasc/'))

Simple bash script using sed:

#!/bin/bash

echo "http://www.coglib.com/~icordasc/" | \
    sed -r 's|.*\.(\w+\.\w+)/~(\w+).*|\2@\1|'

Simple bash script using the translate (tr) program:

#!/bin/bash

echo 'VPBEQNFP@PBTYVO.PBZ' | tr [A-Z] [n-za-m]

Ruby script using regular expressions:

#!/usr/bin/env ruby

puts "http://coglib.com/~icordasc".sub(%r|.*//(\w+\.\w+)/~(\w+)|,
                                       '\2@\1')

How to find my email using clojure:

(ns print-email
  (:require [clojure.string :refer [replace]]))

(def email
  (replace "http://coglib.com/~icordasc"
           #"\w+://([^/]+)/~(\w+)$"
           "$2@$1"))

(println email)