Last active
August 29, 2015 14:18
-
-
Save azechi/a2082f572b7f654799bc to your computer and use it in GitHub Desktop.
work
This file contains 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
private static readonly Char[] CHARS = new Char[] { | |
'a','b','c','d','e', | |
'f','g','h','i','j', | |
'k','l','m','n','o', | |
'p','q','r','s','t', | |
'u','v','w','x','y', | |
'z', | |
'2','3','4','5','6','7' | |
}; | |
// | |
private static IEnumerable<T> Chunk<T>(IEnumerable<T> source, int cutSize, int partitionSize, T padding) | |
{ | |
var i = 0; | |
foreach (var t in source) { | |
yield return t; | |
i = (i % cutSize) + 1; | |
if (i == cutSize) { | |
for (var j = 0; j < (partitionSize - cutSize); j++) { | |
yield return padding; | |
} | |
} | |
} | |
if (i != cutSize) { | |
for(var j =0; j < (partitionSize - i) ; j++){ | |
yield return padding; | |
} | |
} | |
} | |
public static string ToBase32(byte[] data) | |
{ | |
var bits = new BitArray(Chunk(new BitArray(data).Cast<bool>(), 5, 8, false).ToArray()); | |
var buff = new Byte[bits.Length / 8]; | |
bits.CopyTo(buff, 0); | |
return new String(buff.Select(x => CHARS[x]).ToArray()); | |
} |
This file contains 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
gist |
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
public class no_contents : IHttpHandler | |
{ | |
public bool IsReusable | |
{ | |
get { return true; } | |
} | |
public void ProcessRequest(HttpContext context) | |
{ | |
var response = context.Response; | |
//response.Headers.Clear(); | |
response.StatusCode = 204; | |
response.Cache.SetCacheability(HttpCacheability.Public); | |
response.Cache.SetMaxAge(TimeSpan.FromSeconds(31536000)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment