def fix_urls(tweet):
    """ Replace all the http://t.co URL with their real value """
    orig = tweet['text_as_html']
    to_do = dict()
    for url in tweet['entities']['urls']:
        expanded_url = url['expanded_url']
        replacement_str = '<a href="{0}">{0}</a>'.format(expanded_url)
        start, end = url['indices']
        to_do[start] = end, replacement_str
    new_str = ''
    i = 0
    while i < len(orig):
        if i in to_do:
            end, replacement_str = to_do[i]
            for c in replacement_str:
                new_str += c
                i = end
        else:
            new_str += orig[i]
            i += 1
    tweet['text_as_html'] = new_str
