Skip to content

Instantly share code, notes, and snippets.

@dtchepak
dtchepak / gist:5856633
Created June 25, 2013 07:28
Feedly subscription from RSS subscription extension in Chrome
http://cloud.feedly.com/#subscription%2Ffeed%2F%s
@dtchepak
dtchepak / reader_myattempt.cs
Last active December 18, 2015 17:49
my attempt at reader in c#
using System;
using NUnit.Framework;
namespace Workshop
{
public static class ReaderExtensions
{
public static Func<T, B> Select<T, A, B>(this Func<T, A> reader, Func<A, B> f)
{
return t => f(reader(t));
@dtchepak
dtchepak / reader.cs
Last active December 18, 2015 17:49
reader exercise in c#
using System;
using NUnit.Framework;
namespace Workshop
{
public static class ReaderExtensions
{
public static Func<T, B> Select<T, A, B>(this Func<T, A> reader, Func<A, B> f)
{
throw new NotImplementedException("TODO: pass example 1 and 2");
@dtchepak
dtchepak / stringCalc2.hs
Last active December 18, 2015 01:29
My attempt at first 4 or so steps of string calc kata, using Parsec. Not strictly following the kata requirements, just experimenting.
{- LANGUAGE OverloadedStrings -}
import Control.Applicative ((<*))
import Data.Functor ((<$))
import Data.Text (Text)
import Text.Parsec
import Text.Parsec.Text (GenParser)
type Parser = GenParser ()
defaultDelim :: Parser Char
defaultDelim = newline <|> char ',' -- <|> is "or". default delimiter is newline or comma
@dtchepak
dtchepak / stringCalc.hs
Last active December 17, 2015 23:58
My attempt at first 4 or so steps of string calc kata, using hand-rolled parser combinators. Not strictly following the kata requirements, just experimenting.
import Data.Char
import Data.Maybe
newline = is '\n'
comma = is ','
defaultDelim = newline ||| comma
customDelim = do
is '/'
is '/'
delim <- char
@dtchepak
dtchepak / surveyCsv.hs
Last active December 17, 2015 17:49
Attempt at Survey Csv exercise in Haskell. https://gist.github.com/dtchepak/5640717
import Data.Char
import Data.List
import Data.Maybe
import Data.Monoid
import Data.Traversable (traverse)
data ProgrammingLanguage
= CSharp
| FSharp
| Haskell
@dtchepak
dtchepak / surveyCsv.fs
Created May 24, 2013 13:39
Attempt at Survey Csv exercise in F#. https://gist.github.com/dtchepak/5640717
(* This attempt at the problem (https://gist.github.com/dtchepak/5640717) was
based on some real code I had to write.
The aim of this particular approach was to have a deterministic column order,
plus ensure headers and data stayed in the correct order. I ended up with a
DSL-sort-of-thing to define columns:
* `col` to make a column with a particular header and selector; and
* `lookupCol` to make a header and selector to lookup a result for a language.
This is probably unecessary for this case, but seemed appropriate for the real
case which had more columns and column types, so I thought I'd try it out here too.
@dtchepak
dtchepak / surveyCsvExercise.md
Last active December 17, 2015 16:39
Survey to CSV coding exercise.

Survey CSV exercise

Background

We are surveying developers at a number of sites to find their favourite programming language. Each response from a site is stored in a type that contains the site name, and a map/dictionary of programming languages and the number of votes they received. In C# this could look something like this:

class SurveyResponse {
    public string Site;
 public Dictionary Results;
@dtchepak
dtchepak / xenum.cs
Created April 23, 2013 22:29
The @xerxesb enum catamorphism. (Ignore the equality members boilerplate)
using System;
using NUnit.Framework;
using Shouldly;
public class Mushroom { }
public sealed class Xenum : IEquatable<Xenum> {
private readonly Mushroom _mushroom;
private readonly string _s;
private readonly int _a;
private readonly int _b;
//monads.js
//
exports.bestSellingCategories = function () {
return [ createCat(42, "MOL", false)
, createCat(101, "Both kinds", false)
, createCat(418, "http", true)
];
}
createCat = function(id,name,shh) { return { id: id, name: name, isSecret: shh}; }