Skip to content

Instantly share code, notes, and snippets.

View tugberkugurlu's full-sized avatar
:shipit:
💥 shakalaka

Tugberk Ugurlu tugberkugurlu

:shipit:
💥 shakalaka
View GitHub Profile
public class LRUCache
{
private readonly int _capacity;
private readonly IDictionary<int, LinkedListNode<Tuple<int, int>>> _store = new Dictionary<int, LinkedListNode<Tuple<int, int>>>();
private LinkedList<Tuple<int, int>> _accessLog = new LinkedList<Tuple<int, int>>();
public LRUCache(int capacity)
{
_capacity = capacity;
}
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
namespace Zleek.Server.Common
{
public class SlientExceptionHandlerMiddleware
{
private readonly RequestDelegate _next;
@tugberkugurlu
tugberkugurlu / program.fs
Created March 19, 2018 11:26
F# pattern matching sample
// Learn more about F# at http://fsharp.org
type Shape =
| Rectangle of width : float * length : float
| Circle of radius : float
| Prism of width : float * float * height : float
let rect = Rectangle(length = 1.3, width = 10.0)
let circ = Circle(1.0)
@tugberkugurlu
tugberkugurlu / error.md
Created November 25, 2017 20:49
error.md
Error RZ9999: Found a malformed 'body' tag helper. Tag helpers must have a start and end tag or be self closing.
   at Microsoft.AspNetCore.Mvc.Razor.Internal.RazorViewCompiler.CompileAndEmit(String relativePath)
   at Microsoft.AspNetCore.Mvc.Razor.Internal.RazorViewCompiler.CreateCacheEntry(String normalizedPath)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorPageFactoryProvider.CreateFactory(String relativePath)
   at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.CreateCacheResult(HashSet`1 expirationTokens, String relativePath, Boolean isMainPage)
source https://nuget.org/api/v2
// NuGet packages from https://nuget.org/api/v2 source
nuget NUnit ~> 2.6.3
source https://my-nuget-server.example.com/api/v2
// NuGet packages from https://my-nuget-server.example.com/api/v2 source
nuget FAKE ~> 3.4
nuget DotNetZip >= 1.9
const foo = new Map<string, number>();
foo.set('1key', 1);
foo.set('2key', 2);
foo.set('3key', 3);
Array.from(foo.entries()).forEach(item => {
const [y, x] = item;
console.log(`${y}zz: ${x}`)
});
Get-Project -All | ? { $_.ProjectName } | % { Get-Package -ProjectName $_.ProjectName } | sort -property Id -unique | % {
$pkg = $_ ;
Try {
$targetFile = "C:\sqlclone-licenses\$($pkg.Id)-$($pkg.Version).txt"
(New-Object System.Net.WebClient).DownloadFile($pkg.LicenseUrl, $targetFile)
$lineToAppend = "License downloaded from '$($pkg.LicenseUrl)' on '$([DateTime]::UtcNow.ToString('R'))'$([Environment]::NewLine)$([Environment]::NewLine)"
Set-Content $targetFile ($lineToAppend + (get-content $targetFile))
} Catch [system.exception] {
Write-Host "Could not download license for ($pkg.Id)"
}
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using RabbitMQ.Client;
using RabbitMQ.Client.Events;
using Foo.Messaging.Abstractions;
@tugberkugurlu
tugberkugurlu / Program.cs
Created December 14, 2016 15:58
Percentage Progress from multiple sources which runs in sequence.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading;
namespace ConsoleApp7
{
public class MainProgressReporter : IProgress<double>
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp6