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 / settings.json
Created January 12, 2018 14:25
Cmder in VS Code
{
"terminal.external.windowsExec": "O:\\Dropbox\\applications\\apps\\cmder\\Cmder.exe",
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
"terminal.integrated.shellArgs.windows": ["/K", "C:\\apps\\cmder\\vscode.bat"],
"terminal.integrated.fontFamily": "Consolas,Anonymous Pro for Powerline",
"terminal.integrated.fontSize": 16
}
@oguzhaneren
oguzhaneren / readme.md
Last active January 8, 2018 17:22
JavaScript Expression Evaluator
@oguzhaneren
oguzhaneren / proxy.cs
Created December 21, 2017 18:30
.Net Object Proxy
void Main()
{
var fooInstance = new FooImpl();
var proxy = DispatchProxy.Create<IFoo, FooProxy>();
dynamic p = proxy;
p.SetTarget(fooInstance);
var s = proxy.Bar(123);
Console.WriteLine(s);
@oguzhaneren
oguzhaneren / proje.csproj
Created May 8, 2017 14:20
AspNetCoreProjectWithBundleThenPublish
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<DebugType>portable</DebugType>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>myweb</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>myweb</PackageId>
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
@oguzhaneren
oguzhaneren / RateLimiterByAntiForgeryTokenMiddleware.cs
Created March 22, 2017 16:43
Rate limiter middleware for requests which contains RequestVerificationToken header
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Internal;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Caching.Memory;
public class ReliableSqlCommand : IDbCommand
{
private static readonly Policy RetryPolicy = Policy
.Handle<SqlException>(ex => ex.Number == 11001 || ex.Number == 1205)
.WaitAndRetry(new[]
{
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(2),
TimeSpan.FromSeconds(3)
});
@oguzhaneren
oguzhaneren / OwinRouter.cs
Created January 22, 2017 11:33
OwinRouter
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Owin;
using AppFunc = System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>;
using MidFunc = System.Func<
System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>,
System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>>;
public class OwinRouter
```css
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: white;
overflow: hidden;
```
@oguzhaneren
oguzhaneren / ActiveLinkTagHelper.cs
Created November 10, 2016 13:29
Asp.net Core TagHelper for adding 'active' class to current active link
[HtmlTargetElement(Attributes = ControllersAttributeName)]
[HtmlTargetElement(Attributes = ActionsAttributeName)]
[HtmlTargetElement(Attributes = RouteAttributeName)]
[HtmlTargetElement(Attributes = ClassAttributeName)]
public class ActiveLinkTagHelper : TagHelper
{
private const string ActionsAttributeName = "asp-active-actions";
private const string ControllersAttributeName = "asp-active-controllers";
private const string ClassAttributeName = "asp-active-class";
private const string RouteAttributeName = "asp-active-route";
using System;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
namespace Microsoft.AspNetCore.Proxy
{