How I registered wr.gl

I always wanted to create my own URL shortening service, but the problem is that most of the short and attractive domain names are already taken. For that reason, I decided to write a bash script to help me find a simple 2-letter domain name that sounds catchy and easy to remember. This is how I registered wr.gl (Wriggle!).

#!/bin/bash
#
# by pawwa, Sat Dec 21 18:49:48 GMT 2013

CCTLDS=()

checkAcceptingDomains() {
    for CCTLD in `curl -s http://two.vg | grep png | grep -v 0.00 | sed -ne 's/.*\(\.[A-Z][A-Z]\).*/\1/p'`; do
        CCTLD=$(echo $CCTLD | sed -e 's/\.//g')
        CCTLDS+=($CCTLD)
    done
}

checkAvailableDomains() {
    for CCTLD in ${CCTLDS[@]}; do
        curl -s "http://two.vg/list.html?ext=$CCTLD&mode=list" | sed -ne 's/.*>\([a-z][a-z]\.[a-z][a-z]\)<.*/\1/p' > /tmp/$CCTLD
        echo -n "$CCTLD: "
        wc -l /tmp/$CCTLD | sed -e 's/\/tmp.*//g'
    done
}

checkDomainWords() {
    for CCTLD in ${CCTLDS[@]}; do
        for DOMAIN in $(cat /tmp/$CCTLD); do
            PATTERN=$(echo $DOMAIN | tr -d . | sed 's/\(.\)\(.\)\(.\)\(.\)/\1\2.\3.\4/g')
            if grep -E -qm 1 "^$PATTERN" /usr/share/dict/words
                then
                echo -n "$DOMAIN: "
                grep -E "^$PATTERN" /usr/share/dict/words | tr "\n" ", "
                echo
            fi
        done
    done
}

cleanUpTmpFiles() {
    for CCTLD in ${CCTLDS[@]}; do
        rm /tmp/$CCTLD
    done
}

echo "*** Checking available ccTLDs by querying two.vg..."
checkAcceptingDomains
echo "*** Checking available 2-letter domains by querying two.vg: "
checkAvailableDomains
echo
echo "*** Checking domains against local /usr/share/dict/words: "
echo
checkDomainWords
echo
echo "*** Cleaning up tmp files..."
cleanUpTmpFiles

As you can see, the script is non-interactive, it queries two.vg for a list of available domain names for registration, after which it constructs a simple regex pattern out of each of those domains to finally search for matches against /usr/share/dict/words.

Here’s an example of the output — http://pastebin.com/raw.php?i=0BTtdWBw

So, hurry up and register your py.hn (Python)!

Comments are closed.