Skip to content

Instantly share code, notes, and snippets.

View forcewake's full-sized avatar

Pavel Nasovich forcewake

View GitHub Profile
@jarrettmeyer
jarrettmeyer / ObjectToDictionaryHelper.cs
Created January 27, 2011 15:53
C# convert an object to a dictionary of its properties
public static class ObjectToDictionaryHelper
{
public static IDictionary<string, object> ToDictionary(this object source)
{
return source.ToDictionary<object>();
}
public static IDictionary<string, T> ToDictionary<T>(this object source)
{
if (source == null)
@kamranayub
kamranayub / gist:935461
Created April 21, 2011 21:00
This ProxyConverter can be used with AutoMapper to help when converting Entity Framework proxied objects (i.e. DynamicProxy_xxxxxxx). Room for improvement. See: http://stackoverflow.com/questions/3441916/automapper-mapping-issue-with-inheritance-and-abstr
// See: http://stackoverflow.com/questions/3441916/automapper-mapping-issue-with-inheritance-and-abstract-base-class-on-collection/5749579#5749579
//
// For use with AutoMapper
public class ProxyConverter<TSource, TDestination> : ITypeConverter<TSource, TDestination>
where TSource : class
where TDestination : class
{
public TDestination Convert(ResolutionContext context)
{
// Get dynamic proxy base type
using System.Web;
namespace NetflixDemo
{
public class AppHarborHttpContextWrapper : HttpContextWrapper
{
private readonly HttpContext httpContext;
public AppHarborHttpContextWrapper(HttpContext httpContext) : base(httpContext)
{
@theconektd
theconektd / github.css
Created April 30, 2012 02:11
Github Markdown CSS - for Markdown Editor Preview
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px; }
body > *:first-child {
@briancavalier
briancavalier / promise-monad-proof.js
Created August 8, 2012 15:57
A proof that Promises/A is a Monad
//-------------------------------------------------------------
//
// Hypothesis:
//
// Promises/A is a Monad
//
// To be a Monad, it must provide at least:
// - A unit (aka return or mreturn) operation that creates a corresponding
// monadic value from a non-monadic value.
// - A bind operation that applies a function to a monadic value
@larsks
larsks / blogger2scriptogram.py
Created November 6, 2012 04:23
Convert Blogger posts to Markdown for use with Scriptogr.am
#!/usr/bin/python
import os
import sys
import argparse
import iso8601
import re
import subprocess
import logging
import json
@ekantola
ekantola / RxJS-intro.js
Last active June 1, 2017 11:19
RxJS intro snippets
/*
* Observable
*/
var xs = Rx.Observable.range(0, 3)
xs.subscribe(log)
//=> 0
//=> 1
//=> 2
@wgross
wgross / Memoize.cs
Created June 6, 2014 08:23
Memoization of delegates calculation result using strong or weak references. Extension to multiple parameters with partial application. The memoization container can be changed by implementing a custom memoization container factory.
using System;
using System.Collections.Generic;
namespace Memoization
{
public static class Memoize
{
#region Create memoization containers
public interface IContainerFactory
@danfickle
danfickle / app.component.ts
Created January 17, 2016 08:09
Simple multi select dropdown component for Angular 2.
import {Component} from 'angular2/core';
import {MutliSelectDropdownComponent, DropdownItem, DropdownSelectionItem} from './multiselect.component';
/*
* Example usage of a simple multi select dropdown for angular 2.
* See component for more information.
*/
@Component({
selector: 'my-app',
directives: [MutliSelectDropdownComponent],
@ahmad-moussawi
ahmad-moussawi / HomeController.cs
Created May 18, 2016 10:17
A view Render for Razor (aspnetcore RC2)
public class HomeController : Controller {
private readonly ViewRender view;
public HomeController (ViewRender view) {
this.view = view
}
public string Test () {
// render ~/Views/Emails/ResetCode