Skip to content

Instantly share code, notes, and snippets.

View oguzhaneren's full-sized avatar
🐍
it depends

Oğuzhan Eren oguzhaneren

🐍
it depends
View GitHub Profile
@oguzhaneren
oguzhaneren / and-filter.json
Last active April 11, 2019 08:08
Elastic queries
GET campaignproductcontent/_search
{
"query": {
"bool": {
"filter": [
{
"term": {
"campaignId": "301997"
}
},
@oguzhaneren
oguzhaneren / elasticsut.cs
Created February 22, 2019 10:47
InMemory elastic for testing
public interface IElasticSut
{
void MakeBulkRequest(string information);
}
public class ElasticFactory
{
public static IElasticClient CreateInMemory(IElasticSut sut)
{
var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
@oguzhaneren
oguzhaneren / pipe.cs
Created February 1, 2019 07:19
BuildPipeline with tpl dataflow
// https://stackoverflow.com/questions/12647185/linking-dynamically-created-actionblocks-to-a-bufferblock
private static ITargetBlock<int> BuildPipeline(int NumProductionLines)
{
var productionQueue = new BufferBlock<int>();
for (int i = 0; i < NumProductionLines; i++)
{
int iCopy = i;
@oguzhaneren
oguzhaneren / factory.cs
Last active January 25, 2019 11:25
.net core di object initializer with custom parameters and ioc dependencies
internal class DefaultTypedHttpClientFactory<TClient> : ITypedHttpClientFactory<TClient>
{
private readonly Cache _cache;
private readonly IServiceProvider _services;
public DefaultTypedHttpClientFactory(
Cache cache,
IServiceProvider services)
{
_cache = cache ?? throw new ArgumentNullException(nameof (cache));
@oguzhaneren
oguzhaneren / AssemblyExtensions.cs
Last active January 14, 2019 10:42
C# Extensions & Helpers
public static class AssemblyExtensions
{
public static IEnumerable<T> ExtractInstances<T>(this Assembly assembly)
{
return assembly.ExtractClasses<T>()
.Select(q => q.GetConstructors().First(x => !x.GetParameters().Any()))
.Select(i => i.Invoke(null))
.Cast<T>();
}
@oguzhaneren
oguzhaneren / GuidUtility.cs
Created October 1, 2018 11:59
deterministic guid
using System;
using System.Security.Cryptography;
using System.Text;
namespace Logos.Utility
{
/// <summary>
/// Helper methods for working with <see cref="Guid"/>.
/// </summary>
public static class GuidUtility
@oguzhaneren
oguzhaneren / datetime.cs
Created June 27, 2018 16:54
Change readonly static field with reflection
public static readonly DateTime MinDateTime = DateTime.MinValue;
/// <summary>
/// Uses reflection to alter the static readonly MinDateTime value for tests
/// </summary>
public static void SetMinDateTimeForStorageEmulator()
{
BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static;
Type settingsType = typeof(DateTimeUtils);
@oguzhaneren
oguzhaneren / NhibernateExtensions.cs
Last active December 15, 2020 05:34
NHibernate Eager Fetch All Properties With Linq and Criteria API
public static class Ex
{
public static IQueryable<TEntity> EagerFetchAll<TEntity>(this IQueryable<TEntity> query)
{
// hack the session reference out of the provider - or is
// there a better way to do this?
ISession session = (ISession)query.Provider.GetType()
.GetProperty("Session", System.Reflection.BindingFlags.Instance
| System.Reflection.BindingFlags.NonPublic)
.GetValue(query.Provider);
@oguzhaneren
oguzhaneren / CachingQueryHandlerDecorator.cs
Last active July 31, 2018 10:44
CachingQueryHandlerDecorator #code
public class CachePolicyAttribute
: Attribute
{
public int AbsoluteExpirationInSeconds { get; set; }
public string StaticKey { get; set; }
public CachePolicyAttribute()
{
}
@oguzhaneren
oguzhaneren / gist:e5ae0b87fb441548f71d6490da3cf883
Created March 15, 2018 16:52 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue: