Skip to content

Instantly share code, notes, and snippets.

View KevM's full-sized avatar

Kevin Miller KevM

View GitHub Profile
@KevM
KevM / attribute.cs
Created August 3, 2011 18:51
Mini How To Make a drop down via Html Convention
//annotate your view model property with this attribute
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
public class GbstListValueAttribute : Attribute
{
private readonly string _listName;
public GbstListValueAttribute(string listName)
{
_listName = listName;
@KevM
KevM / Breath.spark
Created August 9, 2011 22:03
FubuMVC Issue 97
<viewdata model="FubuMVC.HelloSpark.Controllers.Air.BreatheViewModel" />
<h2>${Model.Text}</h2>
<p>
This paragraphy should be before the go request partial
</p>
#this.Partial<FubuMVC.HelloSpark.Controllers.HtmlTager.GoRequest>();
@KevM
KevM / FakeWriter.cs
Created September 8, 2011 19:12
spark render html behavior invoke test
public class FakeWriter : TextWriter
{
public object Written { get; set; }
public override void Write(object value)
{
Written = value;
}
public override Encoding Encoding
@KevM
KevM / AutoMapperConventionTemplate.cs
Created September 13, 2011 19:29
Automapper Fubu ideas?
//My advice (YMMV) :
//
//skip the view filter
//Only expose your normal U type actions to the action scanner (source)
//add a covention that prepends your U type actions with the appropriate automapperaction<T,U>
// * your devices to know what T goes with what U
public class AutoMapperConvention : IConfigurationAction
@KevM
KevM / Context.cs
Created October 10, 2011 21:15
You can mock anything at Zombo com!
[TestFixture]
public abstract class Context<T> where T : class
{
public RhinoAutoMocker<T> _services { get; private set; }
public T _cut { get; private set; }
[SetUp]
public void Setup()
{
@KevM
KevM / regularexpressionevaluator.cs
Created November 7, 2011 22:57
Regular Expression with a timeout
public interface IRegularExpressionEvaluator
{
IMatch Match(Regex expression, string stringToMatch);
}
public class RegularExpressionSettings : DictionaryConvertible
{
public readonly int DefaultTimeoutInSeconds = 30;
@KevM
KevM / ClarifyGenericExtensions.cs
Created November 29, 2011 21:42
Clarify Extension Methods
public static class ClarifyGenericExtensions
{
public static ClarifyGeneric Filter(this ClarifyGeneric generic, Func<FilterExpression, Filter> filterFunction)
{
var filterExpression = new FilterExpression();
var filter = filterFunction(filterExpression);
generic.Filter.AddFilter(filter);
@KevM
KevM / cool git aliases
Created December 1, 2011 21:36
Keeping a local branch up to date
[alias]
st = status
c = commit -m
aa = add -A
fa = fetch --all
co = checkout
pu = clean -dfx
cu = !git fetch --all && git pull --rebase origin && git submodule update
new = checkout -b
done = !git fetch && git rebase origin/master && git checkout master && git merge @{-1} && rake && git push
@KevM
KevM / NameValueCollectionExtensions.cs
Created January 6, 2012 19:05
Pretty printing a silly collection? Seems like there should be a simpler way.
public static class NameValueCollectionExtensions
{
public static string PrettyPrint(this NameValueCollection collection)
{
var keys = collection.AllKeys.Select(k => "{0} : {1}".ToFormat(k, collection[k]));
return String.Join(Environment.NewLine, keys);
}
}
@KevM
KevM / Nuget.Config
Created January 19, 2012 23:19
Nuget configuraiton of package sources.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
<packageSources>
<add key="myrepo" value="\\server\\share\\path" />
</packageSources>
</configuration>