Skip to content

Instantly share code, notes, and snippets.

View andredublin's full-sized avatar
🐝
buzz

Andre Dublin andredublin

🐝
buzz
View GitHub Profile
@andredublin
andredublin / functor.js
Last active May 16, 2016 03:49
monads in javascript
var Identity = function(x) {
this.__value = x;
}
Identity.of = function(x) { return new Identity(x); };
Identity.of(3);
//=> Identity(3)
Identity.of('hotdogs');
@andredublin
andredublin / tennis.idr
Last active April 12, 2016 16:05
tennis kata in idris
module Tennis
%default total
data Player = PlayerOne | PlayerTwo
Eq Player where
(==) PlayerOne PlayerOne = True
(==) PlayerOne PlayerTwo = False
(==) PlayerTwo PlayerOne = False
@andredublin
andredublin / folding.fsx
Created March 30, 2016 15:32
Folding example
let sequence = ["A";"C";"A";"C";"G";"A";"G";"C";"A";"G";"T"]
let numbers = [1;2;3;4;5]
let dnaTotals = List.fold(fun (a, c, g, t) char ->
match char with
| "A" -> (a + 1, c, g, t)
| "C" -> (a, c + 1, g, t)
| "G" -> (a, c, g + 1, t)
| "T" -> (a, c, g, t + 1)
@andredublin
andredublin / installmono.sh
Created December 24, 2015 20:52
Install dnx for mono
dnvm upgrade -r mono
@andredublin
andredublin / dnxinstall.sh
Created December 24, 2015 20:17
Install dnx on a *nix system
curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh
@andredublin
andredublin / git-deploy
Created December 22, 2015 02:20 — forked from mgirouard/git-deploy
A minimal git deployment script
#!/bin/bash
git push $1 +HEAD:master
git fetch $1
git push origin --tags
@andredublin
andredublin / WebApiConfig.cs
Created December 11, 2015 15:46
Cors in webapi
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.EnableCors(); // allow cross origin resource sharing
config.MapHttpAttributeRoutes(); // enable attribute routing
}
}
@andredublin
andredublin / Program.fsx
Last active November 17, 2015 17:16
hello world fsx
#r "packages/FunScript/lib/net40/FunScript.dll"
#r "packages/FunScript.TypeScript.Binding.lib/lib/net40/FunScript.TypeScript.Binding.lib.dll"
[<ReflectedDefinition>]
module Program =
open FunScript.TypeScript
let main () =
Globals.window.alert("Hello, world!")
@andredublin
andredublin / Duplicates.fsx
Created November 10, 2015 16:56
"Write a method that determines whether all the characters in a string are the same, using only library string methods, but no loops or recursion"
open System
let allDuplicateChars (str : string) =
str.Replace(str.[0].ToString(), "") |> String.IsNullOrEmpty
// src/fsharp/FSharp.Core/array.fs#L702-L706
let mutable state = acc
let len = array.Length
for i = 0 to len - 1 do
state <- f.Invoke(state,array.[i])
state