Skip to content

Instantly share code, notes, and snippets.

#r "packages/Suave/lib/net40/Suave.dll"
open Suave // always open suave
open Suave.Successful // for OK-result
open Suave.Web // for config
startWebServer defaultConfig (OK "Hello World!")
@eqr
eqr / example1.cs
Last active February 17, 2018 22:17
Gird.NET example
List<Person> persons = GetAllPersons();
var cache = CacheFactory.CreateCache(persons);
cache.AddIndexer(new Indexer<Person, string>(p => p.Name));
// Returns all persons with name Jane
var janes = cache.Get(p => p.Name, "Jane").ToList();
cache.AddIndexer(new Indexer<Person, string>(p => p.LastName));
// Returns all persons with last name Smith
var smiths = cache.Get(p => p.LastName, "Smith").ToList();
@eqr
eqr / example2.cs
Created February 17, 2018 22:01
Grid.NET adding/removing
var cache = CacheFactory.CreateCache(Person.CreateTestData());
cache.AddIndexer(new Indexer<Person, string>(p => p.Name));
cache.AddItems(new Person("Jane", "Dow", new DateTime()), new Person("Jill", "Jungle", new DateTime()));
@eqr
eqr / Program.cs
Last active July 24, 2019 17:03
array iteration
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApp1
{
using System.Diagnostics;
using System.Threading.Tasks;
defmodule Composition do
def inc(x) do
x + 1
end
def square(x) do
x * x
end
def double(x) do
def shape(%Tetris.Brick{name: :l}) do
[
{2, 1},
{2, 2},
{2, 3}, {3,3}
]
end
def shape(%Tetris.Brick{name: :l}) do
[
{2, 1},
{2, 2},
{2, 3},
{3, 3}
]
end
inputs:
Enum.flat_map(["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"],
& Path.wildcard(&1, match_dot: true)) -- ["lib/foo/bar.ex"]
inputs:
["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
ignored_files = [
"lib/tetris/shape.ex"
]
[
inputs:
Enum.flat_map(
["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"],
&Path.wildcard(&1, match_dot: true)
) -- ignored_files