Skip to content

Instantly share code, notes, and snippets.

View genghisjahn's full-sized avatar

Jon Wear genghisjahn

View GitHub Profile
private static void OldBadWay()
{
//Warning! This is bad code! Don't use this!
SoapExample.LocalLibrary locallib = new SoapExample.LocalLibrary();
remoteSoap.RemoteLibrarySoapClient remoteclient = new remoteSoap.RemoteLibrarySoapClient();
var ssCall = new RemoteSSClient();
Console.Clear();
DateTime start;
private static void RunTest(dynamic service,string name, int num1, int num2, ConsoleColor color)
{
Console.ForegroundColor = color;
DateTime start = DateTime.UtcNow;
Console.WriteLine("{0}: {1} + {2} = ",name, num1, num2);
var local = service.AddThis(num1, num2);
Console.WriteLine("{0} Answer: {1}",name, local);
DateTime end = DateTime.UtcNow;
Console.WriteLine("{0} Ticks: {1}",name, GetDiff(start, end));
Console.WriteLine("-----");
RunTest(locallib, "Local Assembly", 100, 100, ConsoleColor.Green);
RunTest(remoteclient, @"SOAP/XML", 100, 100, ConsoleColor.Red);
RunTest(ssCall, "Service Stack", 100, 100, ConsoleColor.Cyan);
@genghisjahn
genghisjahn / humanperson.cs
Last active December 22, 2015 01:59
Human & Person classes
public class Human
{
public string LastName { get; set; }
public string FirstName { get; set; }
public string BirthDay { get; set; }
public Int16 HeightInInches { get; set; }
public override string ToString()
{
return string.Format("{0}, {1} is {2} inches tall. Born on {3}", this.LastName, this.FirstName, this.HeightInInches, this.BirthDay);
}
@genghisjahn
genghisjahn / convertallexample.cs
Created August 31, 2013 20:16
Uses ConvertAll to map one typed list to another typed list.
List<Person> persons = PersonGenerator.Get();
var humans= new List<Human>();
humans = persons.ConvertAll(p => new Human
{
FirstName = p.Name.Split(' ').FirstOrDefault()
, LastName = p.Name.Split(' ').LastOrDefault()
, BirthDay = p.DOB.ToShortDateString()
, HeightInInches = (short)((Double)p.HeightInCM * 0.393701)
});
@genghisjahn
genghisjahn / PeopleConverter.cs
Last active December 22, 2015 01:59
Convert Persons to Humans and Humans To Persons
public static dynamic PeopleConverter(dynamic sourceobject)
{
if (sourceobject.GetType().Name=="Person")
{
return ConvertFromPersonToHuman(sourceobject);
}
if (sourceobject.GetType().Name =="Human")
{
return ConvertFromHumanToPerson(sourceobject);
}
@genghisjahn
genghisjahn / FizzBuzzDemo.go
Created September 20, 2013 19:58
This is a very simple example of the FizzBuzz problem using Go / Golang.
package main
import (
"fmt"
sfb "simplefizzbuzz"
)
func main() {
for i := 0; i < 100; i++ {
fmt.Printf("\n%v",sfb.GetFizzBuzzResult(i))
@genghisjahn
genghisjahn / FizzBuzzDemoGo-Blog.go
Last active December 23, 2015 18:49
Golang source code for my FizzBuzzGo blog post.
package main
import (
"fmt"
sfb "fizzbuzzgo/fizzbuzzlib"
)
func main() {
fbp := sfb.FizzBuzzProcessor{GetItems()}
@genghisjahn
genghisjahn / fizzbuzzproc-blog.go
Created September 24, 2013 01:20
Source code for blog post on FizzBuzz Go.
package fizzbuzz
import(
"strconv"
)
type FizzBuzzProcessor struct{
Items
}
@genghisjahn
genghisjahn / divisor.go
Created September 26, 2013 01:29
FizzBuzzDivisor for BlogPost
package fizzbuzz
import(
"strconv"
)
type FizzBuzzDivisor struct{
Value int //Value to be tested.
Message string //Message if a condition is met.
}
func (fbd FizzBuzzDivisor) GetResult(num int) string {