Skip to content

Instantly share code, notes, and snippets.

View dcecile's full-sized avatar

Dan Cecile dcecile

View GitHub Profile
{-# LANGUAGE GHC2021 #-}
{-# LANGUAGE ExplicitNamespaces #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NoFieldSelectors #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE DisambiguateRecordFields #-}
{-# LANGUAGE OverloadedRecordDot #-}
from contextlib import contextmanager
@contextmanager
def exception_context_manager(suppress_exception: bool):
print("context start")
try:
yield
except Exception as e:
print("context exception", e)
if not suppress_exception:
#!/usr/bin/env perl
use strict;
use warnings;
use File::Copy qw(mv);
use Data::Dumper qw(Dumper);
die if @ARGV < 2;
my $destination = $ARGV[@ARGV - 1];
@dcecile
dcecile / enumMapping.ts
Last active September 2, 2018 00:32
TypeScript discriminated unions
enum EventType {
connectTwitter,
addSource,
}
type EventPayload = {
[EventType.connectTwitter]: { id: number }
[EventType.addSource]: { x: string; y: string }
}
@dcecile
dcecile / commit_emojis.txt
Last active June 28, 2018 01:07
Commit emojis
♻️ for refactoring
🔥 for removing old stuff
✅ for tests
🕴️ for rules
🔨 for build system
📝 for docs
🏗️ for infrastructure
🔧 for small tweaks/fixes
✨ for new features or polish
using NUnit.Framework;
using NUnitLite;
using System;
using System.Reflection;
using System.Linq;
public static class Solution
{
public static int Solve() =>
(new[] { 1, 2, 3}).Sum(x => x * 2);
def puzzle(seq: Seq[Int]): Unit =
seq match {
case head :: rest =>
println(s"$head :: $rest")
case Nil =>
println("Nil")
case _ =>
println("_")
}
import Html exposing (beginnerProgram, div, button, text)
import Html.Events exposing (onClick)
-- "You will not see runtime errors in practice" except here ;)
compute model value = value % model
main =
beginnerProgram { model = 1, view = view, update = update }
view model =
import Html exposing (Html, Attribute, beginnerProgram, text, div, input)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
import String
convert : String -> String
convert input =
String.toInt input
|=> Result.toMaybe
|+> maybeFilter (\x -> x < 10)