Skip to content

Instantly share code, notes, and snippets.

View LukeWinikates's full-sized avatar

Luke Winikates LukeWinikates

View GitHub Profile
@LukeWinikates
LukeWinikates / ControllerHelper.cs
Created July 23, 2011 01:54
A possibly naive way to write less code when you want a Controller POST action to play nicely with both vanilla and Ajax form submits.
public static class ControllerHelper {
// working with forms on MVC 3, I found a handful of instances where I wanted to support ajax form submits using the jQuery form plugin
// but still wanted to keep the option of graceful degradation if javascript wasn't supported.
// there might be a better approach to this, like having seperate Ajax and vanilla Post methods,
// moving the logic that currently resides in the controller elsewhere. That would increase complexity a lot all at once.
// Perhaps this kind of thing is the right path in the short term.
public static ActionResult PartialIfAjax_ViewOtherwise(this Controller controller, string viewName, object model) {
if (controller.Request.IsAjaxRequest()) {
return controller.PartialView(viewName, model);
@LukeWinikates
LukeWinikates / FakeDbSet.cs
Created October 24, 2011 16:31
An implementation of IDbSet to help with mocking Entity Framework DbContexts.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace EntityExtensions {
public class FakeDbSet<T> : System.Data.Entity.IDbSet<T> where T : class {
private readonly List<T> list = new List<T>();
public FakeDbSet() {
@LukeWinikates
LukeWinikates / drill-dsl.md
Created December 28, 2022 05:30
Sketch of a markdown DSL for drills

Markdown DSL for drills

I partice a few skills on a weekly basis - certain workouts, guitar drills, and Japanese langauge drills. The concerns are broadly similar, and it got me wondering if there is a way to generalize "practice routine creation" in a format that is serializable, sharable, and "playable" in a variaty of formats.

Examples:

Define an 'atom'