Tag: linkedin

  • Passing in “this” in StructureMap

    I’ve been working with StructureMap lately, and struggled when I need to pass this in. The following code is an example of resolving that issue… namespace StateMachine { public class StateRegistry : StructureMap.Configuration.DSL.Registry { public StateRegistry () { For<IState>.Use<StateA>.Named(“FirstState”); For<IState>.Use<StateB>.Named(“SecondState”); } } public interface IStateMachine { void ChangeState(IState state); } public interface IState { void […]

  • Namespace, Encapsulation in JavaScript

    I’ve had several discussion recently some of the more advanced features of JavaScript, such as functions as return values, namespaces, encapsulation, etc. In order to demonstrate some of these things, I contrived a simple example of a dependency injection tool. Never mind that dependency injection is not really a relevant pattern in JavaScript or other […]

  • Function Name Instead of Lambda in Linq Functions

    I did not realize that functions can fill in for predicates directly without lambda notation. To illustrate, consider the following: void Main() { var words = new List<string>() { “therapists”, “s words”, “slang”, “mustache”, “sean connery” }; var s_words = words.Where(w => w.StartsWith(“s” ,StringComparison.CurrentCultureIgnoreCase)); foreach(var word in s_words) { Console.WriteLine(word); } } It works, but […]

  • MSpec “Hello World” Sample

    I’ve been working with MSpec lately. It’s a BDD framework for .Net. Here’s a hello world type example that uses Trace Writing to show a little bit about what it does. using System; using Machine.Specifications; using System.Diagnostics; namespace UnitedIndustrial.DataImportConcerns { [Subject(“Sample”)] public class SampleConcerns { static string _myString; Establish _context = () => { _myString […]

  • Emacs on Windows Over SSH with Putty Tools

    With a little help from StackOverflow, I got emacs over ssh working on windows. This is trivial on mac/linux, but can be a challenge on windows. dired mode works too! To summarize: 1. Download putty installer with all the tools. 2. Put putty install in the path 3. Generate a key with PuttyGen 4. Copy […]