Skip to content

Instantly share code, notes, and snippets.

View gyuwon's full-sized avatar

Gyuwon Yi gyuwon

View GitHub Profile
public class NinjectDependencyScope : IDependencyScope
{
private IKernel _kernel;
public NinjectDependencyScope(IKernel kernel)
{
Contract.Assert(kernel != null);
this._kernel = kernel;
}
function Git-Ignore() {
param([Parameter(Mandatory=$true)][string[]]$list)
Invoke-RestMethod ("http://gitignore.io/api/" + [string]::Join(",",$list))
}
@gyuwon
gyuwon / DataTableToListT.cs
Last active August 29, 2015 14:10
DataTable to List<T>
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
namespace DataTableMapper
{
public class Item
{
@gyuwon
gyuwon / DependencyParameterBinding.cs
Last active August 29, 2015 14:27
DependencyParameterBinding
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Metadata;
namespace Envicase.Bindings
{
@gyuwon
gyuwon / Get-DirAlias.ps1
Last active August 29, 2015 14:27
Get-DirAlias
function Get-DirAlias ([string]$loc) {
# check if we are in our home script dir
# in that case return grave sign
if ($loc.Equals([Environment]::GetFolderPath("UserProfile"))) {
return "~"
}
# if it ends with \ that means we are in root of drive
# in that case return drive
$lastindex = [int] $loc.lastindexof("\")
@gyuwon
gyuwon / ToObservable.cs
Last active September 18, 2016 16:39
IQueryable<T> to IObservable<T>
public static IObservable<T> ToObservable<T>(this IQueryable<T> source)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
IDbAsyncEnumerable<T> dbAsyncSource = source as IDbAsyncEnumerable<T>;
if (dbAsyncSource == null)
return source.AsEnumerable().ToObservable();
@gyuwon
gyuwon / ValidateParametersAttribute.cs
Last active September 25, 2017 00:08
ValidateParametersAttribute.cs
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;
using static AttributeTargets;
@gyuwon
gyuwon / Optimization.cs
Last active February 16, 2016 02:53
Compilier optimization
using System;
using System.Diagnostics;
namespace Optimization
{
public class Program
{
public static void Main(string[] args)
{
var instance = new Program();
@gyuwon
gyuwon / CallPerf.cs
Created February 16, 2016 02:54
Method call performance
using System;
using System.Diagnostics;
using System.Reflection;
namespace CallPerf
{
internal interface ICounter
{
long Count { get; }
@gyuwon
gyuwon / Set-CsiPath.ps1
Created March 13, 2016 11:29
Set C# REPL path
function Append-Path {
param([string]$path)
if (Test-Path $path) { $env:Path += (";" + $path) }
}
Append-Path("${env:ProgramFiles}\MSBuild\14.0\Bin")
Append-Path("${env:ProgramFiles(x86)}\MSBuild\14.0\Bin")