Skip to content

Instantly share code, notes, and snippets.

View tboby's full-sized avatar

Thomas Boby tboby

  • Oxford, UK
  • 01:47 (UTC +01:00)
View GitHub Profile
@tboby
tboby / Automapper.cs
Last active April 29, 2019 14:24
Automapper execution plan unchanged
static void Main(string[] args)
{
var caseView = new CaseView(){
User = new UserView{
UserID = 5
},
UserID = 5
};
Mapper.Initialize(cfg =>
@tboby
tboby / Automapper.cs
Last active April 29, 2019 13:45
Automapper ignore execution plan
static void Main(string[] args)
{
Mapper.Initialize(cfg =>
{
cfg.AddProfiles(new Profile[] { new CaseProfile()});
});
var configuration = new MapperConfiguration(cfg => cfg.CreateMap<CaseView, Case>());
var executionPlan = configuration.BuildExecutionPlan(typeof(CaseView), typeof(Case));
// Compare execution plans
version: "3"
services:
app:
build: .
volumes:
- app_data:/data_import
depends_on:
- data
data:
build: ./data
@tboby
tboby / Referee.java
Created May 14, 2017 20:30
Code4life cg-brutaltester referee
import java.awt.Point;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@tboby
tboby / gist:8b2587a94a6e494d955e
Last active January 8, 2016 12:37
Helper Example
@functions
{
public static HelperResult ValidatedElementFor<TModel, TProperty>(HtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expr, object editorHtmlAttributes = null)
{
var defaultHtmlAttributes = new { @class = "form-control" };
var combinedHtmlAttributes = html.MergeHtmlAttributes(defaultHtmlAttributes, editorHtmlAttributes);
return ValidatedElement(html.ValidationErrorFor(expr, " has-error", " has-success"), html.LabelFor(expr, htmlAttributes: new { @class = "control-label col-sm-3" }), html.EditorFor(expr, new { htmlAttributes= combinedHtmlAttributes}), html.ValidationMessageFor(expr, "", new { @class = "text-danger" }));
}
}
@helper ValidatedElement(MvcHtmlString error, MvcHtmlString label, MvcHtmlString editor, MvcHtmlString message)
@tboby
tboby / PartialFor.cs
Last active August 29, 2015 14:28 — forked from joeriks/ArticlePageViewModel.cs
PartialFor - resolve name of partial from type name or from UIHint (like DisplayFor)
using System;
using System.Linq.Expressions;
using System.Web.Mvc;
using System.Web.Mvc.Html;
public static class PartialForExtensions
{
public static MvcHtmlString PartialFor<T>(this HtmlHelper<T> htmlHelper, Expression<Func<T, object>> expression,
string partialViewName, ViewDataDictionary viewData)
{
var model = expression.Compile()(htmlHelper.ViewData.Model);
@tboby
tboby / 0_reuse_code.js
Last active August 29, 2015 14:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console