Sleek CLI wrappers around Ruby libs

When using Ruby’s splat operator for method invocation, eg. my_method(*my_array), it takes the array and blows it out into the parameters required to fill the method’s signature. This makes it super easy to call methods from classes via the command line, by simply passing the arguments (ARGV) to a Ruby command line app and thenContinue reading “Sleek CLI wrappers around Ruby libs”

Creating a “Supernatural” Self-Adapting REST Proxy in C#

.NET 4.0’s DynamicObject provides a quick and easy way to hook into and control how a call for a method is dispatched at runtime.  This so called “late dispatch” capability is exactly what we need to easily create dynamic facades over out-of-process APIs, such as those of remote REST services. In this post, I’ll showContinue reading “Creating a “Supernatural” Self-Adapting REST Proxy in C#”

Giving Your Data Some Higher Order Muscle With C#

Today a colleague and I were going through some code.  I have recently been trying to impart to him the power and beauty in the functional programing paradigm in C#.  Today, the opportunity to demonstrate it presented itself as I was showing him how to use extension methods to extend Entities and ValueObjects with aContinue reading “Giving Your Data Some Higher Order Muscle With C#”

Ruby AOP in 12 lines of Code

First, we shim the Ruby Object class with a profiling aspect, in this case an additional method called profile that will wrap any existing method with timing code that we tell it to. Lets put this in a file called: aop_extension.rb. class Object   def Object.profile symbol     _symbol = (“rprof_” + symbol.to_s).to_sym     alias_methodContinue reading “Ruby AOP in 12 lines of Code”

Property getter/setter extraction from C# Types

The C# Expression API allows you to scrape property and method definitions from Types and work with them as external references.  See here: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Linq.Expressions; using System.Dynamic; using System.Runtime.CompilerServices; public static class Extensions  {        public static Func<X, T> GetPropertyFunction<X, T>(this Type source, string name) { ParameterExpression param = Expression.Parameter(typeof(X), “arg”);              MemberExpressionContinue reading “Property getter/setter extraction from C# Types”

My C# ObservableDictionary

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.ComponentModel;using System.Collections.Specialized; namespace DynamicSpikes{    public class ObservableDictionary<String, Object> : Dictionary<string, object>, INotifyPropertyChanged, INotifyCollectionChanged    {         public event PropertyChangedEventHandler PropertyChanged = delegate { };        public event NotifyCollectionChangedEventHandler CollectionChanged = delegate { };         private void OnCollectionChanged(object sender, NotifyCollectionChangedAction action, object value)        {            if (CollectionChanged != null)            {                CollectionChanged(sender, new NotifyCollectionChangedEventArgs(action, value));            }        }         private void OnPropertyChanged(object sender, string propertyName)       Continue reading “My C# ObservableDictionary”

Webshims – HTML5 For The Masses

I’ve been researching the available shimming libaries out there that provide old browsers with modern features.  The Webshims library does this in an efficient and unobtrusive way, always defering to the browser’s built in feature if it exists natively.  With 2 lines of code you tell it where to find its shim scripts and then toContinue reading “Webshims – HTML5 For The Masses”