Skip to content

Instantly share code, notes, and snippets.

@shanefulmer
shanefulmer / cs.snippets
Last active April 24, 2018 18:55
C# Snipmate Snippets
# cs.snippets
# ===========
#
# Standard C-Sharp snippets for snipmate.
#
# Largely ported over from Visual Studio 2010 snippets plus
# a few snippets from Resharper plus a few widely known snippets.
#
# Most snippets on elements (i.e. classes, properties)
# follow suffix conventions. The order of suffixes to a snippet
@shanefulmer
shanefulmer / delivery.js
Created September 10, 2013 19:07
Next delivery date
require('sugar');
var _und = require('underscore');
function getDeliveryDate() {
// really only need holidays that are on Friday
var holidays = ['11/29/2013','12/25/2013', '11/28/2014'];
var startDate = '10/4/2013';
var deliveryDates = _und.range(100).map(function (i) {
var deliveryDate = Date.create(startDate).advance({weeks: 2 * i});
@shanefulmer
shanefulmer / gist:6198848
Created August 10, 2013 03:03
Secrets of the JavaScript Ninja pg 53-54
function Ninja() {
this.skulk = function () { return this; };
}
var whatever = Ninja();
console.log(whatever);
"But the effect would be for the skulk property to be created on window, and for window to be returned and stored in whatever"
function One() {
this.a = function () {
return this.b();
}
}
function b() {
return 1;
}
UUID uuid = UUID.randomUUID();
@shanefulmer
shanefulmer / CorsHandler.cs
Created November 30, 2012 04:49
CorsHandler
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace DotNetOpenAuth.WebAPI {
public class CorsHandler : DelegatingHandler {
const string Origin = "Origin";
const string AccessControlRequestMethod = "Access-Control-Request-Method";
@shanefulmer
shanefulmer / gist:3336201
Created August 13, 2012 01:23
Handler 5
public class CoreRegistry : Registry
{
public CoreRegistry()
{
Scan(cfg =>
{
cfg.TheCallingAssembly();
cfg.WithDefaultConventions();
cfg.IncludeNamespaceContainingType<Foo>();
cfg.ConnectImplementationsToTypesClosing(typeof(IRenderer<>));
@shanefulmer
shanefulmer / gist:3336101
Created August 13, 2012 01:06
Handler 4
public interface ISomeTextService { string DoSomething(); }
public class SomeTextService : ISomeTextService { public string DoSomething() { return string.Empty; } }
public interface ISomeHtmlService { string DoSomethingElse(); }
public class SomeHtmlService : ISomeHtmlService { public string DoSomethingElse() { return string.Empty; } }
public enum RenderType {Text, Html}
public interface IRenderer<T> { string Render(T obj); }
public class FooTextRenderer : IRenderer<Foo>
{
@shanefulmer
shanefulmer / gist:3335824
Created August 13, 2012 00:37
Handler 3
public interface ISomeTextService { string DoSomething(); }
public class SomeTextService : ISomeTextService { public string DoSomething() { return string.Empty; } }
public interface ISomeHtmlService { string DoSomethingElse(); }
public class SomeHtmlService : ISomeHtmlService { public string DoSomethingElse() { return string.Empty; } }
public enum RenderType {Text, Html}
public class Foo
{
private readonly ISomeTextService _someTextService;
private readonly ISomeHtmlService _someHtmlService;
@shanefulmer
shanefulmer / gist:3335789
Created August 13, 2012 00:33
Handler 2
public interface ISomeService { string DoSomething(); }
public class SomeService : ISomeService { public string DoSomething() { return string.Empty; } }
public class Foo
{
private readonly ISomeService _someService;
public Foo(ISomeService someService) { _someService = someService; }
public string Render()
{
return "this is a foo" + _someService.DoSomething();