Skip to content

Instantly share code, notes, and snippets.

@darylteo
darylteo / NinjectWebCommon.cs
Created July 5, 2014 08:04
Ninject injection into Signalr Hubs with ninject.mvc5.
[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(Ascend.Core.Application.App_Start.NinjectWebCommon), "Start")]
[assembly: WebActivatorEx.ApplicationShutdownMethodAttribute(typeof(Ascend.Core.Application.App_Start.NinjectWebCommon), "Stop")]
namespace Ascend.Core.Application.App_Start
{
using System;
using System.Linq;
using System.Web;
using Microsoft.Web.Infrastructure.DynamicModuleHelper;
@akabe
akabe / maze_solver.ml
Last active October 13, 2019 16:34
A maze solver by A* algorithm on OCaml
(* ========================================================================== *
* General implementation of A-star algorithm
* ========================================================================== *)
module Astar :
sig
type 'a t =
{
cost : 'a -> 'a -> int;
goal : 'a;
@justecorruptio
justecorruptio / 2048.py
Last active September 22, 2017 05:17
Tiny 2048
import os,tty;tty.setcbreak(0);M=['']*16
def G(v):
p=['']*4;u=list(filter(str,v));i=3
while u:z=u.pop();p[i]=u and z==u[-1]and 2*u.pop()or z;i-=1
return p
def Y(M,k):i=1;M=zip(*[iter(M)]*4);exec'M=map([list,G][i*k==k*k],zip(*M))[::-1];i+=1;'*4;return sum(M,[])
while 1:
r=id(M)%71+17
while M[r%16]*r:r-=1
if r:M[r%16]=r%7%2*2+2
@markrendle
markrendle / MITEA.license
Created March 30, 2015 10:53
The "MIT Except Apple" License
The MIT-except-Apple License (MIT-EA)
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person (except
anybody associated with Apple Inc.) obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the
Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@mavnn
mavnn / Game.fsx
Created November 21, 2014 12:06
Conway's Game of Life (1 hour, 74 lines...)
open System
let (|Alive|Dead|) i =
match i with
| 0 -> Dead
| 1 -> Alive
| _ -> failwith "What?"
let rand = Random()