Skip to content

Instantly share code, notes, and snippets.

View ramirez7's full-sized avatar
馃挆
Grey hairs are visible / I'm kinda of miserable, too

Armando Ramirez ramirez7

馃挆
Grey hairs are visible / I'm kinda of miserable, too
View GitHub Profile
@ramirez7
ramirez7 / PoolDeadlock.hs
Created November 8, 2017 18:14
Nested calls to Data.Pool.withResource can cause deadlock 馃槺
module PoolDeadlock where
import Control.Concurrent (threadDelay)
import Control.Concurrent.Async (replicateConcurrently_)
import Data.Pool
run :: Int -- ^ Pool size
-> Int -- ^ f sleep
-> Int -- ^ Concurrency degree
-> IO ()
module AsyncPool where
import Control.Concurrent (threadDelay)
import Control.Concurrent.Async (async)
import Control.Concurrent.MVar (newMVar, withMVar)
import Control.Concurrent.STM (atomically)
import Control.Concurrent.STM.TVar (newTVarIO, readTVar, writeTVar)
import Control.Monad (replicateM_, when)
import Data.Pool
位: import Dhall.Repl
位: defaultRepl
>>> List/head Integer [1, 2, 3]
Optional Integer
[1] : Optional Integer
>>> List/head Integer ([] : List Integer)
Optional Integer
[] : Optional Integer
位: :kind! Dh.Normalizer Int Bool
Dh.Normalizer Int Bool :: *
= Dh.Normalizer Int Bool
位: type family Id a where Id a = a
位: :kind! Id (Dh.Normalizer Int Bool)
Id (Dh.Normalizer Int Bool) :: *
= Dh.Expr Int Bool -> Maybe (Dh.Expr Int Bool)
位: :seti -XTypeApplications
位: :seti -XDataKinds
位: import Dalek.Repl
位: import Dalek.Exts.Time.Core
位: import Dalek.Exts.Time.Parser
位: import Dalek.Exts.Time.TypeCheck
位: import Dalek.Typer
位: import Dalek.TypeCheck
位: import Dalek.Core
位: repl @(Open '[DhTime]) parser normalizer (toTyper $ sendTyper typer)
;; I put this in my .emacs
(require 'haskell-commands)
(defun my-auto-format ()
(interactive)
;; see https://github.com/haskell/haskell-mode/blob/dd0ea640fa449d021399a17db65e4d50d3f0f2a9/haskell-commands.el#L811
(haskell-mode-buffer-apply-command "brittany"))
;; The args to call-process-region within haskell-mode-buffer-apply-command are hard-coded to nil,
;; so it looks like there's no way to use --indent=2
@ramirez7
ramirez7 / configuration.nix
Created March 20, 2019 16:12 — forked from globin/configuration.nix
prometheus on nixos
{ pkgs, lib, config, ... }:
{
networking = {
firewall.allowedTCPPorts = [
3000 # grafana
9090 # prometheus
9093 # alertmanager
];
useDHCP = true;
};
位: import System.Metrics.Prometheus.Metric.Histogram as H
位: h <- H.new []
位: s1 <- H.sample h
位: :print s1
s1 = HistogramSample (_t4::Buckets) 0.0 0
位: H.observe 2.2 h
位: H.observe 2.222 h
位: H.observe 1232.222 h
位: s2 <- H.sample h
// routes1.go
func Routes1(mux *http.ServeMux) {
mux.Handle("/route1/a", handler1A)
mux.Handle("/route1/b", handler1B)
mux.Handle("/route1/c", handler1C)
}
// routes2.go
func Routes2(mux *http.ServeMux) {
mux.Handle("/route2/x", handler2X)
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}