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
| AmazonS3Client client = new AmazonS3Client(RegionEndpoint.USWest2); | |
| MemoryStream mem = new MemoryStream(); | |
| using (GZipStream gz = new GZipStream(mem, CompressionLevel.Optimal, true)) | |
| { | |
| var b = Encoding.UTF8.GetBytes(json); | |
| gz.Write(b, 0, b.Length); | |
| gz.Flush(); | |
| } |
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
| public static string GetHash(string str) | |
| { | |
| using (var md5 = MD5.Create()) | |
| { | |
| return BitConverter.ToString(md5.ComputeHash(Encoding.UTF8.GetBytes(str))).Replace("-", "").ToLower(); | |
| } | |
| } |
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
| //Input: "St. Patrick's Day: Awësöme tö-dö's" | |
| //Output: "#StPatricksDayAwesomeToDos" | |
| public static string MakeHashtag(string text) | |
| { | |
| text = RemoveDiacritics(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(text)); | |
| text = Regex.Replace(text, @"[^a-zA-Z0-9]", ""); | |
| return "#" + text; | |
| } |
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
| public class Email | |
| { | |
| public string Subject { get; set; } | |
| public string Body { get; set; } | |
| public string To { get; set; } | |
| public string From { get; set; } | |
| public Email() | |
| { | |
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
| public static Dictionary<string, string> ToDictionary(this object values) | |
| { | |
| var result = new Dictionary<string, string>(); | |
| var type = values.GetType(); | |
| var properties = type.GetProperties(); | |
| foreach (var property in properties) | |
| { | |
| var name = property.Name; | |
| var value = property.GetValue(values); |
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
| /// <summary> | |
| /// Class used for conversion between byte array and Base32 notation | |
| /// </summary> | |
| internal sealed class Base32 | |
| { | |
| /// <summary> | |
| /// Size of the regular byte in bits | |
| /// </summary> | |
| private const int InByteSize = 8; |
NewerOlder