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
/// <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; |
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
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 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 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 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 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 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
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(); | |
} | |
var data = mem.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
var AWS = require('aws-sdk'); | |
AWS.config.region = 'us-east-1'; | |
var sns = new AWS.SNS(); | |
exports.handler = function(event, context) { | |
var count = event.Records.length; | |
var completed = function(err, data){ | |
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
var getFileName = function (url) { | |
return url.replace(/\?.*$/, "").replace(/.*\//, ""); | |
} |
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.Text; | |
using System.Security.Cryptography; | |
namespace PasswordHash | |
{ | |
/// <summary> | |
/// Salted password hashing with PBKDF2-SHA1. | |
/// Author: havoc AT defuse.ca | |
/// www: http://crackstation.net/hashing-security.htm |
OlderNewer