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 / Customer.cs
Created August 18, 2016 11:47 — forked from ThomasArdal/Customer.cs
Elasticsearch migration c# example
namespace ConsoleApplication1
{
public class Customer
{
public int Zipcode { get; set; }
}
}
@oguzhaneren
oguzhaneren / socket.js
Created October 28, 2016 11:59
socket.io api methods
// sending to sender-client only
socket.emit('message', "this is a test");
// sending to all clients, include sender
io.emit('message', "this is a test");
// sending to all clients except sender
socket.broadcast.emit('message', "this is a test");
// sending to all clients in 'game' room(channel) except sender
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
{
@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";
```css
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: white;
overflow: hidden;
```
@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
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 / 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;
@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 / 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);