Skip to content

Instantly share code, notes, and snippets.

View gerektoolhy's full-sized avatar

gerektoolhy

  • 23:04 (UTC +03:00)
View GitHub Profile
[TestFixture]
public class TestAwsSplit
{
private const string keyValueSeparator = "=";
private string line = "aws_secret_access_key = =+123456789123456789123456791234567891234";
private static List<string> SplitData_2_3_55(string line)
{
var split = line
.Split(new string[] { keyValueSeparator }, 2, StringSplitOptions.None)
// Modelled similarly to IOwinContext
public interface IBusContext
{
IDictionary<string, object> Environment { get; }
T Get<T>(string key);
IBusContext Set<T>(string key, T value);
}
// Middleware for bus pipeline.
// Example middlewares:
@gerektoolhy
gerektoolhy / Base64UrlExtensions
Last active December 15, 2017 15:37
Base64UrlExtensions as specified by rfc4648 ((https://tools.ietf.org/html/rfc4648#section-5)
public static class Base64UrlExtensions
{
/// <summary>
/// Encodes string to base64url, as specified by rfc4648 (https://tools.ietf.org/html/rfc4648#section-5)
/// </summary>
/// <returns></returns>
public static string ToBase64Url(this string str)
{
// TODO - adds reference to System.Web
if (str == null)
public class DependencyModule : NancyModule
{
private readonly IApplicationDependency applicationDependency;
private readonly IRequestDependency requestDependency;
public DependencyModule(IApplicationDependency applicationDependency, IRequestDependency requestDependency)
{
this.applicationDependency = applicationDependency;
this.requestDependency = requestDependency;
@gerektoolhy
gerektoolhy / ConfigOverride
Created February 19, 2013 12:50
Second call to Mapper.CreaateMap redefiens the map from OrderDtoString to Order, but the actual property mappings stay untouched. The order is created with status "InProgress", but the old mapping which returns Status.Complete is still in place, thus the line dto.Status.ShouldEqual(Status.Complete) is true.
[Test]
public void ShouldNotAllowToOverrideConfig()
{
Mapper.CreateMap<OrderDtoString, Order>()
.ForMember(y => y.Status, x => x.MapFrom(t => Status.Complete));
Mapper.CreateMap<OrderDtoString, Order>();
var order = new OrderDtoString
{
@gerektoolhy
gerektoolhy / gist:4579407
Created January 20, 2013 15:43
elastic search query
dark@ubuntu:~$ curl -XGET 'http://localhost:9200/twitter/tweet/2?pretty=true'
{
"_index" : "twitter",
"_type" : "tweet",
"_id" : "2",
"_version" : 1,
"exists" : true, "_source" :
{
"user": "kimchy",
"postDate": "2009-11-15T14:12:12",