Created
September 17, 2012 07:54
-
-
Save azyobuzin/3736086 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string ExpandUstreamUri(string uri) | |
{ | |
const string alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
var id = uri.TrimStart("http://ustre.am/".ToArray()); | |
return "http://www.ustream.tv/channel/id/" + | |
id.Reverse() | |
.Select((c, i) => Math.Pow(alphabet.Length, i) * alphabet.IndexOf(c)) | |
.Sum(); | |
} | |
ExpandUstreamUri("http://ustre.am/xGQd") | |
// "http://www.ustream.tv/channel/id/8029509" が返ってきます | |
// http://www.ustream.tv/channel/id/******* は http://www.ustream.tv/channel/******* にリダイレクトされるので | |
// http://www.ustream.tv/channel/azyobuzich にアクセスすることと同じです |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment