Skip to content

Instantly share code, notes, and snippets.

View boj's full-sized avatar

Brian Jones boj

  • Eagle River, Alaska
View GitHub Profile
@boj
boj / gist:188d8131632a0541b2c9af0e137db53a
Created July 28, 2016 04:41
FreeBSD 10.3-RELEASE-r6 Elixir 1.3.2 port build error
# make install clean
===> License APACHE20 accepted by the user
===> Found saved configuration for elixir-1.3.2
===> elixir-1.3.2 depends on file: /usr/local/sbin/pkg - found
===> Fetching all distfiles required by elixir-1.3.2 for building
===> Extracting for elixir-1.3.2
=> SHA256 Checksum OK for elixir/1.3.2/Docs.zip.
=> SHA256 Checksum OK for elixir/1.3.2/elixir-lang-elixir-v1.3.2_GH0.tar.gz.
===> Patching for elixir-1.3.2
===> Applying FreeBSD patches for elixir-1.3.2
@boj
boj / test.hs
Last active December 19, 2016 09:56
GADT Example
{-# LANGUAGE GADTs #-}
module Main where
data SpellHeal = SpellHeal Int deriving (Show)
data SpellDamage = SpellDamage Int deriving (Show)
data SpellRitual = SpellRitual Float deriving (Show)
data Creature = Creature Int deriving (Show)
{ config, pkgs, ... }:
{
imports =
[
./hardware-configuration.nix
];
boot.loader.grub.enable = true;
boot.loader.grub.version = 2;
@boj
boj / .spacemacs
Created March 6, 2017 19:00
.spacemacs
;; -*- mode: dotspacemacs -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration."
(setq-default
;; List of additional paths where to look for configuration layers.
;; Paths must have a trailing slash (ie. `~/.mycontribs/')
dotspacemacs-configuration-layer-path '()
@boj
boj / EitherBifunctor.hs
Created May 22, 2017 22:32
Data.Bifunctor example of Either A B to Either A C
-- Given some function with an return type Either A B
buildTemplate :: Text -> IO (Either TemplateError [TmplExpr])
-- Another function with the return type Either A C uses the prior function,
-- but due to the fact that the type signature varies, one cannot rely on
-- monadic chaining to work correctly for the failure case.
loadWeatherTemplates :: IO (Either TemplateError WeatherTemplates)
loadWeatherTemplates =
buildTemplate enterTemplate >>= \et ->
buildTemplate inputTemplate >>= \it ->
@boj
boj / default
Created September 12, 2017 10:07
Pinning nixpkgs in default.nix
let
config = {
allowUnfree = true;
};
inherit (import <nixpkgs> { }) fetchFromGitHub;
# Current rev points to 17.09-beta
pkgs = import (fetchFromGitHub {
owner = "NixOS";

Keybase proof

I hereby claim:

  • I am boj on github.
  • I am bojo (https://keybase.io/bojo) on keybase.
  • I have a public key ASBhz9ymtS2WPKVm0q28TfQB9uyLzp7DbiDCfb_kuip4YQo

To claim this, I am signing this object:

@boj
boj / Main.hs
Created October 19, 2017 09:48
Haskell iso lens example
#! /usr/bin/env nix-shell
#! nix-shell -i 'runghc -XOverloadedStrings -XLambdaCase' -p 'ghc.withPackages (pkgs: [ pkgs.lens pkgs.text ])'
module Main where
import Control.Lens
import Data.Text
data Route
= ForgotPassword
@boj
boj / Main.hs
Created November 15, 2017 08:47
Show how to use Haskell type symbols in Servant APIs to generate string URLs
#! /usr/bin/env nix-shell
#! nix-shell -i 'runghc -XOverloadedStrings -XDataKinds -XTypeOperators' -p 'ghc.withPackages (pkgs: [ pkgs.servant-server ])'
module Main where
import Data.List
import Data.Proxy
import GHC.TypeLits
import Servant
@boj
boj / Main.hs
Created December 8, 2017 22:51
Haskell ViewPatterns example
#! /usr/bin/env nix-shell
#! nix-shell -i 'runghc -XViewPatterns' -p 'ghc.withPackages (pkgs: [ pkgs.containers ])'
module Main where
import Data.Map (Map)
import qualified Data.Map as Map
f :: Int -> Map Int String -> String
f k (Map.lookup k -> Just s) = s