Skip to content

Instantly share code, notes, and snippets.

@csainty
csainty / app.config
Created June 1, 2014 20:08
Glimpse Config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="glimpse" type="Glimpse.Core.Configuration.Section, Glimpse.Core, Version=1.0.0, Culture=neutral"/>
</configSections>
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
<logging level="Trace"/>
<runtimePolicies>
<ignoredTypes>
<add type="Glimpse.Core.Policy.ControlCookiePolicy, Glimpse.Core"/>
class Foo {
func bar() -> String {
return "Hello"
}
}
func greet (f: Foo) -> String {
return f.bar()
}
public class MyBootstrapper : DefaultNancyBootstrapper
{
protected override void ApplicationStartup(TinyIoc.TinyIoCContainer container, Bootstrapper.IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
Nancy.Security.Csrf.Enable(pipelines);
}
}
@csainty
csainty / TracingMiddleware.cs
Created July 2, 2014 20:40
TracingMiddleware.cs for @jchannon
namespace TracingMiddleware
{
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using MidFunc = System.Func<
System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>,
System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>
@csainty
csainty / ko-date.js
Created November 27, 2014 09:08
Quick patch for KnockoutJS to handle date equality checks
function wrapEqualityComparerWithDateSupport(origFn) {
return function (a, b) {
return origFn(a, b) ||
(a instanceof Date && b instanceof Date && a.getTime() === b.getTime());
}
}
ko.observable.fn.equalityComparer = wrapEqualityComparerWithDateSupport(ko.observable.fn.equalityComparer);
ko.dependentObservable.fn.equalityComparer = wrapEqualityComparerWithDateSupport(ko.dependentObservable.fn.equalityComparer);
@csainty
csainty / gruntfile.js
Created February 24, 2015 10:47
Super simple grunt task to update a json config file in the package
grunt.registerTask('config', function (env) {
var config = grunt.file.readJSON('src/config.json');
var envs = {
production: {
apiUrl: 'http://foo.com'
},
staging: {
apiUrl: 'http://bar.com'
}
};
@csainty
csainty / HelloServer.java
Created July 25, 2015 15:10
Undertow Hello World
import io.undertow.Undertow;
import io.undertow.util.Headers;
public class HelloServer {
public static void main(final String[] args) {
Undertow server = Undertow.builder()
.addHttpListener(8081, "localhost")
.setHandler((exchange) -> {
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
exchange.getResponseSender().send("Hello World");
@csainty
csainty / gist:e15f5cb2fbf74c1e0901
Last active September 7, 2015 07:55 — forked from schacon/gist:942899
delete all remote branches that have already been merged into development
$ git branch -r --merged origin/development |
grep origin |
grep -v '>' |
grep -v 'master$' |
grep -v 'development$' |
xargs -L1 |
cut -d"/" -f2- |
xargs git push origin --delete
@csainty
csainty / Inmate.cs
Created July 5, 2011 03:56
Draft Inmate model for Macto
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Macto
{
public class Inmate
{
public int Id { get; set; }
@csainty
csainty / gist:1064886
Created July 5, 2011 14:01
Example RavenDb Profiling JSON
{
"Results": [
{
"Title": "Macto: The boundaries of a prison",
"LegacySlug": null,
"Body": "<p>Macto is a prison management system. To be rather more exact, it is an <em>incarceration </em>management system. Managing a prison is a very complex process (did you ever think about who takes the trash out? Or how to handle things like watch rotations?).</p> <p>I am getting ahead of myself, however. The first thing that we have to do when we start designing a system is check:</p> <ul> <li>What is the scope of the system?</li> <li>What is the intended usage?</li> <li>Who are the users?</li> <li>What other systems are we going to interface with?</li></ul> <p>Those are the basics, because in a lot of projects, they don’t get asked.</p> <p>Running a prison is a complex task, I already said. If we wanted a single piece of software to do it all, we would have to do a <em>lot</em> of stuff that we don’t really need. For example, are we going to write our own payroll system for the prison’s stuff? O