def shorten(url)
      Base64.urlsafe_encode64([Digest::MD5.hexdigest(url).to_i(16)].pack("N")).sub(/==\n?$/, '')
    end
def shorten(url)
      Base64.urlsafe_encode64([Digest::MD5.hexdigest(url).to_i(16)].pack("N")).sub(/==\n?$/, '')
    end
Internal: Shortens a given URL to a short code.

 1) MD5 hash the URL to the hexdigest
 2) Convert it to a Bignum
 3) Pack it into a bitstring as a big-endian int
 4) base64-encode the bitstring, remove the trailing junk

 url - String URL to shorten.

 Returns a unique String code for the URL.