Table of Contents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ~/s/journaldriver $ cargo update | |
| Updating registry `https://github.com/rust-lang/crates.io-index` | |
| Removing adler32 v1.0.2 | |
| Updating aho-corasick v0.6.4 -> v0.6.8 | |
| Removing arrayvec v0.4.7 | |
| Adding ascii v0.9.1 | |
| Updating atty v0.2.10 -> v0.2.11 | |
| Updating backtrace v0.3.8 -> v0.3.9 | |
| Updating backtrace-sys v0.1.21 -> v0.1.24 | |
| Updating base64 v0.9.1 -> v0.9.3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// Implementation of a log-encoder decorator that can prepend | |
| /// journald log priorities to any given `log4rs`-encoder. | |
| #[derive(Debug)] | |
| struct JournaldDecorator<E: Encode>(E); | |
| /// Helper function to map from `log`-crate log levels to journald log | |
| /// priorites. Please see `sd-daemon(3)` for detailed information on | |
| /// these levels. | |
| fn journald_priority(level: &Level) -> &'static str { | |
| match level { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE MultiWayIf #-} | |
| -- | This module implements a door that can be opened and closed, and | |
| -- locked/unlocked with a specified code when in closed state. | |
| -- | |
| -- The state diagram looks roughly like this (p. simple): | |
| -- | |
| -- <--Open--- <--Unlock-- | |
| -- [Opened] [Closed] [Locked] | |
| -- --Close--> ----Lock--> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- | A type-level, constraint-writing function that ensures that some | |
| -- versioned type is migratable throughout its entire version history. | |
| -- | |
| -- Assumes that type version history starts at '1'. | |
| {-# LANGUAGE ConstraintKinds #-} | |
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE MultiParamTypeClasses #-} | |
| {-# LANGUAGE TypeFamilies #-} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- | Test something with an in-memory acid-state | |
| acidTest :: forall state event query result. | |
| (IsAcidic state, UpdateEvent event, MethodState event ~ state, | |
| QueryEvent query, MethodState query ~ state, | |
| MethodResult query ~ result) | |
| => String -- ^ Test description | |
| -> state -- ^ Initial state for test | |
| -> event -- ^ Event to test | |
| -> query -- ^ Query to check | |
| -> (result -> Bool) -- ^ Function to test query result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; This demonstrates how to advise[1] magit functions that perform | |
| ;; potentially destructive operations (for example `magit-git-push') | |
| ;; with a confirmation prompt. | |
| ;; | |
| ;; The TL;DR of advising is that a function is "wrapped" around the | |
| ;; function to be advised, with various different behaviours that can | |
| ;; be used (e.g. only conditionally executing the original function). | |
| ;; | |
| ;; [1]: https://www.gnu.org/software/emacs/manual/html_node/elisp/Advising-Functions.html#Advising-Functions | |
| ;; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -e | |
| function cleanup { | |
| git checkout src/ibrowse.erl | |
| } | |
| trap cleanup EXIT | |
| echo "Patching in main/1 function with hex.pm test" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Generate an immutable /etc/resolv.conf from the networking.nameservers setting: | |
| environment.etc."resolv.conf" = with lib; with pkgs; { | |
| source = writeText "resolv.conf" '' | |
| ${concatStringsSep "\n" (map (ns: "nameserver ${ns}") config.networking.nameservers)} | |
| options edns0 | |
| ''; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extern crate crius; | |
| use crius::command::{RunnableCommand, Command, CommandError}; | |
| /// Convenience type alias for breaker function pointers. | |
| pub type BreakerFn<I, O> = fn(I) -> Result<O, Box<CommandError>>; | |
| /// Convenience type alias for working with crius commands: | |
| pub type Breaker<I, O> = | |
| RunnableCommand<I, O, | |
| BreakerFn<I,O>, |