Skip to content

Instantly share code, notes, and snippets.

View alimozdemir's full-sized avatar

Alim ÖZDEMİR alimozdemir

View GitHub Profile
server {
listen 80;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
BenchmarkDotNet=v0.10.11, OS=macOS 10.13.2 (17C88) [Darwin 17.3.0]
Processor=Intel Core i5-7360U CPU 2.30GHz (Kaby Lake), ProcessorCount=4
.NET Core SDK=2.0.3
  [Host]     : .NET Core 2.0.3 (Framework 4.6.0.0), 64bit RyuJIT
  DefaultJob : .NET Core 2.0.3 (Framework 4.6.0.0), 64bit RyuJIT

// params call
00007fff`0ca4d060 paramsBenchmark.ParameterBenchmark.ParamsWithObject()
00007fff`0ca4d076 83fe01 cmp esi,1
00007fff`0ca4d079 751f jne 00007fff`0ca4d09a
00007fff`0ca4d07b 48b9a229a168ff7f0000 mov rcx,offset System_Private_CoreLib+0xe29a2 (00007fff`68a129a2)
00007fff`0ca4d085 ba02000000 mov edx,2
00007fff`0ca4d08a e8b173ad5f call coreclr!MetaDataGetDispenser+0x72960 (00007fff`6c524440)
not managed method
00007fff`0ca4d08f ff05ef950400 inc dword ptr [00007fff`0ca96684]
@alimozdemir
alimozdemir / ActionHistory_V1.cs
Last active August 30, 2018 11:33
ActionHistory_V1 singleton pattern
public class ActionHistory_V1 : IActionHistory
{
private Stack<string> _history { get; set; }
public ActionHistory_V1()
{
if (File.Exists("actions.txt"))
{
var lines = File.ReadAllLines("actions.txt");
@alimozdemir
alimozdemir / ActionHistory_V2.cs
Created August 30, 2018 12:17
ActionHistory_V2 singleton pattern
public class ActionHistory_V2 : IActionHistory
{
private static readonly ActionHistory_V2 instance = new ActionHistory_V2();
public static ActionHistory_V2 Instance { get; } = instance;
private ActionHistory_V2()
{
....
}
@alimozdemir
alimozdemir / ActionHistory_V3.cs
Created August 30, 2018 13:07
ActionHistory_V3.cs singleton pattern
public class ActionHistory_V3 : IActionHistory
{
private static Lazy<ActionHistory_V3> instance =
new Lazy<ActionHistory_V3>(() => new ActionHistory_V3());
public static ActionHistory_V3 Instance { get; } = instance.Value;
private ActionHistory_V3()
{
....
}
@alimozdemir
alimozdemir / ClientPool.cs
Last active September 5, 2018 10:36
Object pool design pattern
public class ClientPool
{
private static Lazy<ClientPool> instance
= new Lazy<ClientPool>(() => new ClientPool());
public static ClientPool Instance { get; } = instance.Value;
public int Size { get { return _currentSize; } }
public int TotalObject { get { return _counter; } }
private const int defaultSize = 5;
private ConcurrentBag<Client> _bag = new ConcurrentBag<Client>();
@alimozdemir
alimozdemir / Clients.cs
Created September 4, 2018 13:02
Client and RequestClient implementation for object pool
public abstract class Client
{
public abstract void Connect();
}
internal class RequestClient : Client
{
public override void Connect()
{
Console.WriteLine("Connecting to something with RequestClient...");
}
@alimozdemir
alimozdemir / ClientPoolExample.cs
Last active September 4, 2018 15:50
Object Pool example usage
static void BasicExample()
{
Console.WriteLine("Havuzun boyutu {0}", ClientPool.Instance.Size);
Console.WriteLine("Client sınıfı ediniyoruz.");
var client1 = ClientPool.Instance.AcquireObject();
client1.Connect();
Console.WriteLine("Client'ı geri bırakıyoruz");
<template>
<div>
<blade v-for="(item, index) in items" :items="item" :key="index"></blade>
</div>
</template>
<script>
import blade from './blade'
export default {