Skip to content

Instantly share code, notes, and snippets.

(defprotocol LNext
(foo [this] [this a] "this is a foo 1")
(bar [this a] "this is a bar"))
(extend-protocol LNext
String
(foo
([this] (str this " with extra goodness!"))
([this a] (str this " with double extra goodness!!" a)))
(require '[clojure.zip :as zip])
(def v [[[1 2 [3 4]] [:a [[ :b :c] :d]]] ["f" "g"] [[["h"] "i"] "j"]])
(def z (zip/vector-zip v))
z
( -> z zip/node)
( -> z
@NeilRobbins
NeilRobbins / tron.bot.clj
Last active December 17, 2015 13:39 — forked from cgrand/tron.bot.clj
;Circle
(ns tron.neil.bots
(:require [tron.core :as tron]))
(def directions {:right [1 0]
:down [0 1]
:left [-1 0]
:up [0 -1]})
(ns tron.neil.bots
(:require [tron.core :as tron]))
(def directions {:right [1 0]
:down [0 1]
:left [-1 0]
:up [0 -1]})
(def pos [3 4])
@NeilRobbins
NeilRobbins / Hunt in files for things.sh
Last active December 16, 2015 20:49
Change the regex to match requirements Example 1 (line 1) Search in packages.xml files for those that reference a given package. Example 2 (line 3) Search in csproj files for references
find . -name packages.config -exec grep -H -n '^.*System.Windows.*' {} \;
find . -name *.csproj -exec grep -H -n '^.*<Reference Include="System.Windows.Controls.Toolkit.Internals, Version=4.0.5.0, Culture=neutral, PublicKeyToken=2c5c654d367bf4a7, processorArchitecture=MSIL">' {} \;
@NeilRobbins
NeilRobbins / Alt.Fizzbuzz.hs
Last active December 15, 2015 02:49
Fizzbuzz in Haskell - just because
import System.Environment
main = do (countTo:_) <- getArgs
let numbers = fizzbuzz [0..(read countTo)]
mapM_ putStr $ map (\n -> n ++ ", ") $ init numbers
putStrLn $ last numbers
divides d n = rem n d == 0
fb x = if (divides 15 x) then "Fizzbuzz" else if (divides 3 x) then "Fizz" else if (divides 5 x) then "Buzz" else show x
@NeilRobbins
NeilRobbins / gist:5098828
Created March 6, 2013 11:56
Regular Expression for a 4 part version number
^([0-9]+[.]){3}[0-9]+$
@NeilRobbins
NeilRobbins / gist:4126083
Created November 21, 2012 17:06
Enable Remote PS-Sessions

Log on as the local system admin (must be the local system administrator account, no other admin account works)

Then run:

  • winrm quickconfig -quiet
  • winrm set winrm/config/client @{TrustedHosts="*"}

Optional (lets chunky stuff be passed around):

  • Powershell Set-PSSessionConfiguration -name ` microsoft.powershell -MaximumReceivedObjectSizeMB 1000 -Force
@NeilRobbins
NeilRobbins / PascalsTriangle.fs
Created October 31, 2012 23:56
Pascals Triangle
module Program
open System
let rec factor (n : int64) =
match n with
| 0L -> 1L
| _ -> n * (factor (n - 1L))
let rec combinations r n =
@NeilRobbins
NeilRobbins / containerfree.cs
Created October 15, 2012 16:11
Example of container free DI with ASP.NET MVC
public class MvcApplication : System.Web.HttpApplication
{
// Everthing else...
protected void Application_Start()
{
// Everthing else...
ControllerBuilder.Current.SetControllerFactory(new CustomControllerFactory(new BuildControllers()));
}