Skip to content

Instantly share code, notes, and snippets.

@loosechainsaw
loosechainsaw / iomonad.cs
Created October 16, 2014 11:12
IO Monad
using NUnit.Framework;
using System;
namespace Monads
{
public class Unit{
private Unit(){
@loosechainsaw
loosechainsaw / jsmixandmatch.js
Created October 8, 2014 08:05
javascript oop / mixin framework
j = {
context : {}
};
j.namepsace = (function(){
var createnamespace = function(parent, remainder){
if(remainder.length === 0){
return;
}
@loosechainsaw
loosechainsaw / rxjsautocomplete.js
Created October 7, 2014 12:29
rxjsautocomplete.js
window.application = {};
window.application.search = (function(){
function searchwikipedia(term) {
return $.ajaxAsObservable({
url: 'http://en.wikipedia.org/w/api.php',
data: { action: 'opensearch',
search: term,
format: 'json' },
@loosechainsaw
loosechainsaw / regex.fs
Last active August 29, 2015 14:05
Regex wip part 2
namespace RegularLanguages
open System
open NUnit.Framework
[<AutoOpen>]
module Internals =
let private (|Char|_|) x =
if Char.IsLetter(x) then
Some(x)
@loosechainsaw
loosechainsaw / perthcodedojo2.fs
Created August 26, 2014 10:59
Perth Code Dojo 2
namespace PerthCodeDojo
open System
open NUnit.Framework
[<AutoOpen>]
module Internals =
type Quantity = int
type Product =
@loosechainsaw
loosechainsaw / regex.fs
Created August 21, 2014 14:58
Regex WIP
namespace RegularLanguages
open System
open NUnit.Framework
[<AutoOpen>]
module Internals =
let private (|Char|_|) x =
if Char.IsLetter(x) then
Some(x)
namespace JsonParser
open System
open NUnit.Framework
module Json =
type Token =
| String of string
| Number of string
module Encryption =
module private Helpers =
let rec encrypt s =
match s with
| [] -> []
| h :: t -> ( char ((int h) + 13)) :: (encrypt t)
let rot13 (s: string) =
let characters = s.ToCharArray ()
let enc = characters |> List.ofArray |> Helpers.encrypt |> List.toArray
module Extensions =
type System.Collections.Generic.List<'a> with
member this.Split (first: int, last: int) =
let count = (last - first) + 1
let result = this.GetRange(first, count)
result
module Algorithms =
open Extensions
@loosechainsaw
loosechainsaw / fsbsearch.fsx
Created July 28, 2014 13:24
Code Dojo 1 - F# Implementation of Binary Search
module Algorithms =
let binary_search list value =
let rec impl(list: 'a list) (value :'a) (hi: int) (low:int) =
let index = (hi + low) / 2
match compare value (list.Item(index)) with
| 0 -> Some(index)
| 1 -> impl list value hi index
| -1 -> impl list value index low
| _ -> None
match list with