Skip to content

Instantly share code, notes, and snippets.

View forcewake's full-sized avatar

Pavel Nasovich forcewake

View GitHub Profile
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Collections.Concurrent;
using System.Text;
using System.Threading;
namespace MapReduceWords
{
public class WordReducer
@forcewake
forcewake / fromScript.json
Last active August 29, 2015 13:56
Dynamic form from c# to jquery dynamic form
{
"action": "index.html",
"method": "get",
"html": [
{
"type": "p",
"html": "You must login"
},
{
"type": "text",
class Program
{
static void Main(string[] args)
{
ReflectedType reflectedType = new ReflectedType();
PropertyInfo intProperty = typeof(ReflectedType).GetProperty("SampleInt32");
SetAndGet(intProperty, reflectedType, 0);
SetAndGet(intProperty, reflectedType, 10);
SetAndGet(intProperty, reflectedType, 30);
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RLUtils
{
/// <summary>
/// Creates an Comparer for a type
/// </summary>
@forcewake
forcewake / EnumerableExtensions.cs
Created March 20, 2014 13:28
Permutations extension
public static class EnumerableExtensions
{
public static IEnumerable<IEnumerable<T>> Permutations<T>(this IEnumerable<T> source)
{
if (source == null)
throw new ArgumentNullException("source");
// Ensure that the source IEnumerable is evaluated only once
return permutations(source.ToArray());
}
public interface IFactory<in TKey, TValue>
{
/// <summary>
/// Registers an item
/// </summary>
/// <param name="key">Item to register</param>
/// <param name="value">The object to be returned</param>
void Register(TKey key, TValue value);
/// <summary>
using System;
using System.Linq.Expressions;
using System.Reflection;
namespace Expression.Runner
{
/// <summary>
/// Extensions to <see cref="LambdaExpression"/>
/// </summary>
public static class ExpressionExtensions
public class TransactionProvider : ITransactionProvider<SqlTransaction>
{
private const string TransactionField = "StoreTransaction";
private const BindingFlags BindingFlags = System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod
| System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.NonPublic;
public SqlTransaction GetTransaction()
{
var sqlTransaction = (SqlTransaction)this.transaction.GetType()
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization.Json;
using System.Text;
namespace Test.Lib
{
/// <summary>
@forcewake
forcewake / NullSafeStringComparer.cs
Created May 5, 2014 18:13
Safe compare null-string
public class NullSafeStringComparer : StringComparer
{
private readonly StringComparer baseStringComparer;
public static NullSafeStringComparer NullSafeInvariantCulture
{
get
{
return new NullSafeStringComparer(InvariantCulture);
}