Skip to content

Instantly share code, notes, and snippets.

View dhess's full-sized avatar

Drew Hess dhess

View GitHub Profile
@ekmett
ekmett / TypedNBE.hs
Last active September 7, 2020 19:37
Typed normalization-by-evaluation using a slowed category action
{-# Language CPP #-}
{-# Language BlockArguments #-}
{-# Language GADTs #-}
{-# Language RankNTypes #-}
{-# Language ViewPatterns #-}
{-# Language TypeApplications #-}
{-# Language BangPatterns #-}
{-# Language TypeOperators #-}
{-# Language TypeFamilyDependencies #-}
{-# Language DataKinds #-}
#!/bin/bash
set -euo pipefail
# uncomment to debug
# set -x
echo "1️⃣. Does catalina know to create the nix directory?"
if ! grep nix /etc/synthetic.conf > /dev/null 2>&1; then
echo "nix missing from /etc/synthetic.conf. Adding it (will request sudo)"
echo "nix" | sudo tee -a /etc/synthetic.conf > /dev/null
@ssinyagin
ssinyagin / wan_bachup_via_lte.sh
Created May 5, 2018 19:15
WAN backup routing via LTE
### WAN backup routing via LTE ###
# A Linux device, such as PC Engines APU, can be equipped with an LTE modem, but
# sometimes it's desirable to use the mobile connection only if the wired
# connection is unavailable.
# The following scenario is for Debian 9 on an APU box, but it's also
# applicable to any other Linux device.
# The DHCP client is tweaked to ignore the DNS server addresses that are
{ config, lib, ... }:
with lib;
let
cfg = config.services.nixBinaryCacheCache;
nginxCfg = config.services.nginx;
title author
Solution to servant API type indentation problem
Oleg

This post is a literate Haskell file: so there are few imports, and {-# LANGUAGE TypedKitchenSink #-}.

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE OverloadedStrings #-}
title author
Passing a DB connection to handlers in Servant
Oleg

This write-up is motivated by discussion in servant/#704 issue. I try to summarize the main points.

As this is a literate haskell file, we'll need to do a small prelude dance:

@arsdehnel
arsdehnel / iam-terraform-create-policy.tf
Last active September 21, 2023 18:12
AWS IAM policies for running Terraform from an EC2 instance.
resource "aws_iam_policy" "terraform_create_policy" {
name = "terraform_create_policy"
path = "/"
policy = "${data.aws_iam_policy_document.terraform_create_policy.json}"
}
data "aws_iam_policy_document" "terraform_create_policy" {
statement {
sid = "1"
actions = [
@phadej
phadej / Example.hs
Created October 14, 2016 14:58
servant-machines
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE OverloadedStrings #-}
module Main (main) where
import Prelude ()
import Prelude.Compat
import Control.Concurrent (threadDelay)
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Control.Monad.IO.Class
import Control.Monad.Trans.Class
import Prelude hiding (log)
--------------------------------------------------------------------------------
-- The API for cloud files.
class Monad m => MonadCloud m where
saveFile :: Path -> Bytes -> m ()
@andrew-azarov
andrew-azarov / supermicro-mass-upgrade-ipmi.py
Last active January 14, 2023 07:20
Mass upgrade script for supermicro ipmi, needs requests and requests_toolbelt
#!/usr/bin/env python
# coding=utf8
"""
Copyright (c) 2015 ServerAstra Ltd.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: