Skip to content

Instantly share code, notes, and snippets.

bash-3.2$ command -v sw_vers && sw_vers # OS X only
/usr/bin/sw_vers
ProductName: Mac OS X
ProductVersion: 10.13.2
BuildVersion: 17C205
bash-3.2$ command -v uname && uname -a # Kernel version
/usr/bin/uname
Darwin Maximilians-MBP 17.3.0 Darwin Kernel Version 17.3.0: Thu Nov 9 18:09:22 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64 x86_64
bash-3.2$ command -v stack && stack --version
/usr/local/bin/stack
maximiliantagher@Maximilians-MBP ~/D/t/citext> bash
bash-3.2$ command -v sw_vers && sw_vers # OS X only
/usr/bin/sw_vers
ProductName: Mac OS X
ProductVersion: 10.13.2
BuildVersion: 17C88
bash-3.2$ command -v uname && uname -a # Kernel version
/usr/bin/uname
Darwin Maximilians-MBP 17.3.0 Darwin Kernel Version 17.3.0: Thu Nov 9 18:09:22 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64 x86_64
bash-3.2$ command -v stack && stack --version
bash-3.2$ command -v sw_vers && sw_vers # OS X only
/usr/bin/sw_vers
ProductName: Mac OS X
ProductVersion: 10.13.1
BuildVersion: 17B1003
bash-3.2$ command -v uname && uname -a # Kernel version
/usr/bin/uname
Darwin Maximilians-MBP 17.2.0 Darwin Kernel Version 17.2.0: Fri Sep 29 18:27:05 PDT 2017; root:xnu-4570.20.62~3/RELEASE_X86_64 x86_64
bash-3.2$ command -v stack && stack --version
/usr/local/bin/stack
@MaxGabriel
MaxGabriel / gist:9e757f2da60ac53b45bb06b2b097d86b
Last active October 31, 2019 22:45
persistent-postgresql case insensitive text
-- First enable citext in psql: CREATE EXTENSION IF NOT EXISTS citext;
-- Create Model/CustomTypes.hs
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Model.CustomTypes where
maximiliantagher@Maximilians-MBP ~/D/t/stack-issue> stack ghci --verbose
Version 1.5.1, Git revision 600c1f01435a10d127938709556c1682ecfd694e (4861 commits) x86_64 hpack-0.17.1
2017-11-16 14:30:58.199868: [debug] Checking for project config at: /Users/maximiliantagher/Documents/tmp/stack-issue/stack.yaml
@(Stack/Config.hs:974:9)
2017-11-16 14:30:58.200754: [debug] Loading project config file stack.yaml
@(Stack/Config.hs:999:13)
2017-11-16 14:30:58.201947: [debug] Trying to decode /Users/maximiliantagher/.stack/build-plan-cache/x86_64-osx/lts-9.13.cache
@(Data/Store/VersionTagged.hs:72:5)
2017-11-16 14:30:58.215946: [debug] Success decoding /Users/maximiliantagher/.stack/build-plan-cache/x86_64-osx/lts-9.13.cache
@(Data/Store/VersionTagged.hs:76:13)

Keybase proof

I hereby claim:

  • I am maxgabriel on github.
  • I am maxgabriel (https://keybase.io/maxgabriel) on keybase.
  • I have a public key ASDGLrNkRBb6XgmcswXZXyvv1blRELY3g1CDWmF8BFHupwo

To claim this, I am signing this object:

@MaxGabriel
MaxGabriel / molecules.rb
Last active November 15, 2016 04:15
Script written to simulate merging of hyaluronic acid molecules
#!/usr/bin/env ruby
require 'csv'
require 'set'
## HA (hyaluronic acid) molecule merging script
## Written by Max Tagher, licensed to the Public Domain under Creative Commons Zero 1.0
### Overview
# This script runs a simulation of HA molecules merging with one another.
@MaxGabriel
MaxGabriel / main.hs
Created April 23, 2016 22:29
Example usage of Data.Reaper
{-# LANGUAGE MultiWayIf #-}
module Main where
import Data.Time
import System.Random
import Control.Reaper
import Control.Concurrent
import Control.Monad
import Data.IORef
@MaxGabriel
MaxGabriel / ekg-yesod.md
Last active August 6, 2020 09:46
Monitoring a Yesod app with EKG

Monitoring a Yesod app with EKG

Monitoring is critical to a well-functioning production system. OS-level metrics like CPU load and RAM usage are a good start, but you'll eventually want to record application-level metrics like how long it's taking you to service each HTTP request, or how much time is spent in garbage collection. Once tracked, this data can be used by humans and machines (like monitoring systems) to gain insight into how your app is running.

In this post I'll show how you can use EKG, a popular Haskell metrics library, to add application-level metrics to your Yesod app.

A Brief Overview of EKG Metric Types

EKG allows reporting four different types of metrics from your app:

@MaxGabriel
MaxGabriel / ekgjson.json
Created April 4, 2016 02:50
Example JSON output from EKG, a Haskell monitoring tool
{
"myapp":{
"home_requests":{
"type":"c",
"val":0
}
},
"ekg":{
"server_timestamp_ms":{
"type":"c",