Skip to content

Instantly share code, notes, and snippets.

View thedom85's full-sized avatar
🏠
Working from home

thedom85

🏠
Working from home
View GitHub Profile
@thedom85
thedom85 / CSharp_Reflection_GetByName_DynamicCalledMethods.cs
Last active August 29, 2015 14:17
CSharp_Reflection_GetByName_DynamicCalledMethods
void Main()
{
Console.WriteLine ("Reflection \n");
//Create SampleClass objec
Console.WriteLine ("\n");
Console.Write("1)Create SampleClass object => new SampleClass(): \n");
var myObj = new SampleClass();
//Get the Type information
@thedom85
thedom85 / CSharp_ JaroWinklerDistance_distance_ MeasureOfSimilarityBetweenTwoStrings.cs
Last active August 29, 2015 14:17
CSharp_ JaroWinklerDistance_distance_ MeasureOfSimilarityBetweenTwoStrings
void Main()
{
//Inspired By: http://stackoverflow.com/questions/19123506/jaro-winkler-distance-algorithm-in-c-sharp
//Inspired By: http://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance
Console.Write(string.Format("distance(apple,mela): {0} \n",JaroWinklerDistance.distance("apple","apple")));
Console.Write(string.Format("distance(aa,ab): {0} \n",JaroWinklerDistance.distance("aa","ab")));
Console.Write(string.Format("distance(apple,aplpe): {0} \n",JaroWinklerDistance.distance("apple","aplpe")));
Console.Write(string.Format("distance(apple,pear): {0} \n",JaroWinklerDistance.distance("apple","pear")));
Console.Write(string.Format("distance(apple,Banana): {0} \n",JaroWinklerDistance.distance("apple","Banana")));
@thedom85
thedom85 / CSharp_Functional_programming_for_Example.cs
Created March 26, 2015 12:49
CSharp_Functional_programming_for_Example
void Main()
{
//for (Int32 i = 0; i < 10; i++) Console.WriteLine(i);
ExampleFunctiona.ForEach(Enumerable.Range(0, 10), View);
}
public void View (int i)
{
Console.WriteLine(i);
@thedom85
thedom85 / CSharp_ LevenshteinDistance_distance_ MeasureOfSimilarityBetweenTwoStrings.cs
Created March 26, 2015 13:17
CSharp_ LevenshteinDistance_distance_ MeasureOfSimilarityBetweenTwoStrings.cs
//Inspired By: http://www.dotnetperls.com/levenshtein
void Main()
{
Console.Write(string.Format("distance(aunt,aunt): {0} \n",LevenshteinDistance.Compute("aunt", "ant")));
Console.Write(string.Format("distance(Sam,Samantha): {0} \n",LevenshteinDistance.Compute("Sam", "Samantha")));
Console.Write(string.Format("distance(flomax,volmax): {0} \n",LevenshteinDistance.Compute("flomax", "volmax")));
//Out:
//distance(aunt,aunt): 1
//distance(Sam,Samantha): 5
@thedom85
thedom85 / CSharp_DesignPattern_Factory_ EasySimpleFactory.cs
Created March 27, 2015 08:30
CSharp_DesignPattern_Factory_ EasySimpleFactory.cs
void Main()
{
DbServer dbServer = DatabaseFactory.GetDb("Ms Sql Server");
string dbName = dbServer.GetDbServerName();
Console.WriteLine("Server Name : " + dbName);
dbServer = DatabaseFactory.GetDb("Oracle Database Server");
dbName = dbServer.GetDbServerName();
@thedom85
thedom85 / CSharp_Lambda_validation_Expression_Func.cs
Last active August 29, 2015 14:17
CSharp_Lambda_validation_Expression_Func
void Main()
{
Expression<Func<string, bool>> validationString = s => s.Length > 5;
Func<string, bool> validate = validationString.Compile();
//Test Validate:Hello
var result = validate("Hello");
Console.WriteLine("validate(Hello):"+result);
//Test Validate:Good Evening
result = validate("Good Evening");
Console.WriteLine( "validate(Good Evening):"+result);
@thedom85
thedom85 / CSharp_Lambda_ForEach_Expression_Func.cs
Created March 27, 2015 14:44
CSharp_Lambda_ForEach_Expression_Func.cs
void Main()
{
var mySourceStringArray = new string[] { "1", "2", "3", "4"};
var myDestinationStringList = new List<string>();
mySourceStringArray.ForEach(myDestinationStringList.Add);
myDestinationStringList.ForEach(x => Debug.Write(x + " "));
}
public static class EnumerableExtension
@thedom85
thedom85 / JQuery_ColorRandom_HtmlComponents.js
Last active August 29, 2015 14:18
JQuery_ColorRandom_HtmlComponents
var colors = [ "blue","blue", "red", "yellow", "green", "grey" ];
$("*").find("*").each(function() {
$(this).css("border-color", colors[(Math.floor(Math.random() * (5 - 1 + 1)) + 1)] ).css("border-style","solid").css("border-width","medium");
});
@thedom85
thedom85 / JQuery_ColorRandom_HtmlDiv.js
Last active August 29, 2015 14:18
JQuery_ColorRandom_HtmlDiv
var colors = [ "blue","blue", "red", "yellow", "green", "grey" ];
$("*").find("div").each(function() {
$(this).css("border-color", colors[(Math.floor(Math.random() * (5 - 1 + 1)) + 1)] ).css("border-style","solid").css("border-width","medium");
});
@thedom85
thedom85 / CSharp_Pattern_Dependency_Injection_Create.cs
Last active August 29, 2015 14:18
CSharp_Pattern_Dependency_Injection_Create
//LINQPad
//CSharp_Pattern_Dependency_Injection_Create.cs
void Main()
{
Client client = new Client(new Service());
client.Start();
}
public interface IService
{