Skip to content

Instantly share code, notes, and snippets.

@sudipto80
sudipto80 / dupSimple.cs
Created Mar 24, 2016
Finding duplicates the right way
View dupSimple.cs
var hasDup = plugIns.ToLookup(plugIn => plugIn.ID).Count != plugIns.Count;
View DemoPlugin.cs
class PlugIn
{
public string ID { get; set; }
public string Description { get; set; }
public Action DoThis { get; set;}
public PlugIn(string id, string des, Action act)
{
ID = id;
Description = des;
@sudipto80
sudipto80 / dup1.cs
Created Mar 24, 2016
Finding duplicates the wrong way
View dup1.cs
var duplicates = plugIns.GroupBy(i => i.ID)
.Where(g => g.Count() > 1)
.ToDictionary(g => g.Key, g => g.Select(a => a.Description).ToList());
@sudipto80
sudipto80 / UsingIndex.cs
Created Mar 19, 2016
Index consumption
View UsingIndex.cs
void Main()
{
List<Employee> testSet = new List<Employee> ();
for (int i = 0; i < 20000; i++)
{
testSet.Add(new Employee(Guid.NewGuid().ToString(),"345"));
}
Stopwatch w = new Stopwatch ();
View Index.cs
public static class SearchEx
{
public static IList<string> NGrams( string sentence, int q)
{
int total = sentence.Length - q;
List<string> tokens = new List<string>();
for (int i = 0; i <= total; i++)
tokens.Add(sentence.Substring(i, q));
return tokens;
}
View t9.txt
interesting contemporary communication photography bike birke blog blogs atony james apulia ataka australian big tvs acupuncture administration advertising brochure budget jewellery manufacturer manufacturers provider recruitment hypnotist laptops buffalo mozzarella organizer moulds consultant conservatory construction distributor consultancy organiser masspressies entertainment developments experiences experience
temps derailleurs koi domaineers looseners lot3 firenze pcs modded mud bugz partitioning jewellers
valuer sms sandwell limos ubique usbs teles ssfl flynn waggons entertainer
installers installer installation furnishing discoveries professional provider providers centre
measurement ny pd partioning dj djs accommodation accessories refurbishment petitioners coaters
maintenance conveyancers improvements sourcing conveniences dvds chillis voip fones wine bottlers
programming furnishing agricultural albury alicante andaluci antigua mediterranean framersmallaga conservatories consolidation adriatic a
@sudipto80
sudipto80 / SmartDiff.cs
Last active Apr 20, 2016
Smart Diff For Source Code using Roslyn
View SmartDiff.cs
//A very basic but smart code comparer for C#
//Written using Microsoft.CodeAnalysis.CSharp and LINQ
public class SmartComparer
{
public static string Code1 { get; set; }
public static string Code2 { get; set; }
public static IEnumerable<ClassDeclarationSyntax> Classes1 { get; set; }
public static IEnumerable<ClassDeclarationSyntax> Classes2 { get; set; }
View codes.cs
string code_1 = @"public class Employee
{
private int _Age;
private string _Name;
public int Age
{
get { return _Age; }
}
View strategy.cs
using System;
using System.Collections.Generic;
namespace DoFactory.GangOfFour.Strategy.RealWorld
{
View proxy.cs
using System;
namespace DoFactory.GangOfFour.Proxy.RealWorld
{
/// <summary>