Ruby
  1. https://github.com/github/gollum
    • A simple, Git-powered wiki with a sweet API and local frontend.
  1. https://gist.github.com/4007635

短址產生程式

# -*- encoding : utf-8 -*-
require 'digest/md5'

module UrlShorter

  ALPHABET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split(//)

  def self.short!(url)

    hex = Digest::MD5.hexdigest(url)
    hexlen = hex.length
    subhexlen = hexlen / 8 

    output = []

    for i in 0..subhexlen-1
      subhex = hex[i*8,8]
      int = 0x3FFFFFFF & ("0x#{subhex}".to_i(16))
      out = ""

      for j in 0..5
        val = 0x0000001F & int
        int = int >> 5
        out += ALPHABET[val]
      end

      output << out
    end

    return output[0]
  end
end
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License