Skip to content

Instantly share code, notes, and snippets.

View benley's full-sized avatar
🐈

Benjamin Staffin benley

🐈
View GitHub Profile
@benley
benley / freeipa-server.nix
Created February 7, 2024 18:38 — forked from s1341/freeipa-server.nix
working freeipa config
{
config,
lib,
...
}: let
cfg = config.services.freeipa-server;
in {
options.services.freeipa-server = {
enable = lib.mkEnableOption "freeipa service";
router = lib.mkOption {
(require 's)
(defun count-leading-whitespace (str)
"Count leading indentation chars in STR."
(let ((trimmed (string-trim-left str)))
(- (length str) (length trimmed))))
(defun unindent-string (str)
"Remove common leading whitespace from each line in STR."
(let* ((str-as-lines (s-lines str))
@benley
benley / org-to-gfm.el
Last active May 1, 2019 00:13
org-to-gfm.el
;;; org-to-gfm --- Export a org-mode file to Github-flavored Markdown
;;;
;;; Commentary:
;;; To convert INPUT_FILE.org and produce OUTPUT_FILE.md, run something like:
;;;
;;; emacs -q --no-splash --no-x-resources --batch --script org-to-gfm.el INPUT_FILE.org OUTPUT_FILE.md
;;;
;;; Code:
(unless (require 'use-package nil t) (package-install 'use-package))
#+NAME: diff
#+BEGIN_SRC bash :results verbatim :exports results :wrap example diff
# macro used to generate inline diffs in this document
diff --new-line-format='+%L' \
--old-line-format='-%L' \
--unchanged-line-format=' %L' \
<(echo "$in") <(echo "$out") ;:
#+END_SRC
#+NAME: a
local string = import "string.libsonnet";
local
parseKey(x) = string.strip(
local x_ = std.splitLimit(x, " ", 1);
if std.length(x_) == 1 then x
else x_[std.length(x_) - 1]
),
parseValue(x) = (
@benley
benley / .nixpkgs.json
Created February 11, 2019 23:55
nix monorepo example layout
{ "url": "https://github.com/nixos/nixpkgs/archive/804c227b83faa017c377eb899d18e5931e0ad936.tar.gz" }
From 3f369cf8b9f7134d0792f6b141d39b5342a8274f Mon Sep 17 00:00:00 2001
From: Benjamin Staffin <[email protected]>
Date: Mon, 14 Jan 2019 17:27:06 -0500
Subject: [PATCH] Vastly simplify setup.py for distro compatibility
---
setup.py | 81 +-------------------------------------------------------
1 file changed, 1 insertion(+), 80 deletions(-)
diff --git a/setup.py b/setup.py
local xorshift32(seed) = (
local maxint = (1<<32) - 1;
// seed must be non-zero
local x = if seed == 0 then 4036811160 else seed;
local x1 = x ^ (x << 13);
local x2 = x1 ^ (x1 >> 17);
local x3 = x2 ^ (x2 << 5);
x3 & maxint
);
/****
Copyright 2018 Postmates Inc
Copyright 2018 Benjamin Staffin
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:
#!/usr/bin/env runhaskell
import System.Process (callCommand)
runcmd args =
putStrLn ("+ " ++ cmd) >> callCommand cmd
where cmd = unwords args
-- (Name of your laptop's internal display, x res, y res)
(internalOutput, intX, intY) = ("eDP1", 3840, 2160)