This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var size = image.Size; | |
| var aspectRatio = size.Width / size.Height; | |
| var newSize = aspectRatio > 1 | |
| ? new SizeF(maxHeightOrWidth, maxHeightOrWidth / aspectRatio) | |
| : new SizeF(maxHeightOrWidth * aspectRatio, maxHeightOrWidth); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var all = @"// redacted"; | |
| var firstLetters = all | |
| .Split('\n') | |
| .Select(n => n.Trim().ToUpper()) | |
| .Select(n => n.Substring(n.IndexOf(" ") + 1)[0]); | |
| var counts = from l in firstLetters | |
| group l by l into g | |
| select new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace IBM | |
| { | |
| public class DeepThought | |
| { | |
| private static void Main(string[] args) | |
| { | |
| new DeepThought("What is the answer to life, the universe and everything?"); | |
| } | |
| private DeepThought(Setting<QuestionConfigurationSetting, string> question) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace IBM | |
| { | |
| public class DeepThought | |
| { | |
| private static void Main(string[] args) | |
| { | |
| new DeepThought("What is the answer to life, the universe and everything?"); | |
| } | |
| private DeepThought(Setting<QuestionConfigurationSetting, string> question) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Main() | |
| { | |
| var propertyInfo = typeof(A).GetProperty("Foo"); | |
| var lambda = Get<A>(propertyInfo); | |
| lambda.Compile()(new A()).Dump(); | |
| } | |
| public Expression<Func<T, int>> Get<T>(PropertyInfo propertyInfo) | |
| { | |
| ParameterExpression entity = Expression.Parameter(typeof (A), "e"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class CombiningSettingsReader : ISettingsReader | |
| { | |
| private readonly ISettingsReader[] _settingsReaders; | |
| public CombiningSettingsReader(params ISettingsReader[] settingsReaders) | |
| { | |
| _settingsReaders = settingsReaders; | |
| } | |
| public string ReadValue(string key) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using (Timeline.Capture("FormulaEvaluator.Evalauate")) | |
| { | |
| // Code to time | |
| } | |
| public static class Timeline | |
| { | |
| public static IDisposable Capture(string eventName) | |
| { | |
| #pragma warning disable 618 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let initField x y s = | |
| match (x,y) with | |
| | (1,1) | (1, 2) | (1,3) -> true | |
| | _ -> false | |
| let valueAt (f:bool[,]) c = | |
| match c with | |
| | (x,y) when x < 0 -> false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Psudo C# | |
| public class Program(IDb db) | |
| { | |
| _db = db; | |
| void Main() | |
| { | |
| var results = _db.Query(new FooQuery().From(DateTime.Today).ForUser("doe")); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ObjectSettingsReader : ISettingsReader | |
| { | |
| private readonly Dictionary<string, string> _values; | |
| public ObjectSettingsReader(object obj) | |
| { | |
| var q = from p in obj.GetType().GetProperties() | |
| where p.CanRead | |
| let v = "" + p.GetValue(obj) | |
| where v != "" |