Skip to content

Instantly share code, notes, and snippets.

View gyuwon's full-sized avatar

Gyuwon Yi gyuwon

View GitHub Profile
@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 / 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 / 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 / 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
{
function Git-Ignore() {
param([Parameter(Mandatory=$true)][string[]]$list)
Invoke-RestMethod ("http://gitignore.io/api/" + [string]::Join(",",$list))
}
public class NinjectDependencyScope : IDependencyScope
{
private IKernel _kernel;
public NinjectDependencyScope(IKernel kernel)
{
Contract.Assert(kernel != null);
this._kernel = kernel;
}
@gyuwon
gyuwon / DynamicLinqOperations.cs
Created January 20, 2014 03:55
Dynamic Linq operations - Where, OrderBy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace DynamicLinq
{
public static class DynamicLinqOperations
{
private static MethodInfo orderByTemplate = typeof(Enumerable)
public static string PropertyName<T>(Expression<Func<T>> expression)
{
if (expression == null)
throw new ArgumentNullException("expression");
var body = expression.Body as MemberExpression;
if (body == null)
throw new ArgumentException("Invalid expression", "expression");
var cluster = require('cluster')
, express = require('express')
, config = require('./config/config');
if (cluster.isMaster) {
for (var i = 0; i < config.ports.length; i++) {
cluster.fork({ PORT: config.ports[i] });
}
} else {
var app = express();
forever stop app.js