Skip to content

Instantly share code, notes, and snippets.

@liammclennan
liammclennan / gist:891625
Created March 29, 2011 00:41
JavaScript Class Template
var myNamespace = myNamespace || {};
myNamespace.MyConstructor = function(opts) { this.options = opts; };
(function () {
function myPrivateMethod(t) {
console.log("myPrivateMethod" + t.options.a);
}
public class ViewModelRenderer : IEnableLogger
{
public string RenderViewModel(string interfaceCode)
{
var tree = SyntaxTree.ParseCompilationUnit(interfaceCode, "foo.cs");
var root = tree.GetRoot(new CancellationToken());
if (!root.ChildNodes().Any()) {
throw new ArgumentException("Compilation failed or code is badly formatted");
}
@adamchester
adamchester / blog_welcome.blog.md
Created June 3, 2012 02:37
Welcome to my blog, it may be updated rarely
@adamchester
adamchester / blog_purpose.blog.md
Created June 17, 2012 13:26
This blog is purely a learning experience
@dsplaisted
dsplaisted / AsyncPortableTask.cs
Created July 8, 2012 05:36
Portable task wrappers
// An implementation of IPortableTask which wraps an actual Task.
// This has to go in a project targeting a platform or platforms which support Task and async/await
using System;
using System.Threading.Tasks;
namespace PortableTasks
{
public class AsyncPortableTask : IPortableTask
{
@adamchester
adamchester / blog_debug_model_binding.aspnetmvc.debug.md
Last active March 28, 2023 15:03
Debugging ASP.NET MVC 4 model binding

The Scenario

Recently we had a tricky defect raised where, under certain circumstances, the user-entered values were not being persisted. The page was a somewhat complex data entry form, with many fields, lots of validation, and a complex hierarchy of view model objects and controls/helpers.

The process

After reproducing the issue (which itself was difficult), the first thing we did was to attach the debugger and set a break point on the first line of the controller action.

@TheRealCodeBeard
TheRealCodeBeard / FSharpAutocomplete.py
Created January 6, 2014 20:50
Hi. Having run out of time/momentum to work on this I wanted to 'get it out there' in the hope that someone can finish it. This python file is for Sublime Text 3. When installed as a plugin it parses an fsharp file when loaded and post save and then calls for auto complete options. I was a little inspired by this: http://www.eladyarkoni.com/2012…
import sublime, sublime_plugin
import sys,os,re
#script should go in Pacakges/FSharpAutocomplete/FSharpAutocomplete.py
#pexpect should go in Packages/FSharpAutocomplete/lib
#to make it load 'everything' from the lib folder.
def installpath(path):
if path not in sys.path:
sys.path.insert(0, path)
__file__ = os.path.normpath(os.path.abspath(__file__))
@clemensv
clemensv / gist:9953010
Last active January 3, 2017 14:11
However often you call me, I'm only going to flush every 200msec from the first flush call
Task flushingTask = null;
public override Task FlushAsync(CancellationToken cancellationToken)
{
Interlocked.CompareExchange(
ref flushingTask,
Task.Delay(200, cancellationToken).ContinueWith(
async (t) =>
{
await write.FlushAsync(cancellationToken);
@dsyme
dsyme / gist:9b18608b78dccf92ba33
Last active November 1, 2022 18:11
Working self-contained getting-started sample for Suave Web Scripting
//==========================================
// Working fully self-contained getting-started example for Suave Web Server scripting
//
// Note you don't need to have _anything_ installed before starting with this script. Nothing
// but F# Interactive and this script.
//
// This script fetches the Paket.exe component which is referenced later in the script.
// Initially the #r "paket.exe" reference is shown as unresolved. Once it has been
// downloaded by the user (by executing the first part of the script) the reference
// shows as resolved and can be used.