Skip to content

Instantly share code, notes, and snippets.

View benley's full-sized avatar
🐈

Benjamin Staffin benley

🐈
View GitHub Profile
@benley
benley / bazel_in_docker.sh
Created April 9, 2018 20:01
Run Bazel daemon in a docker container
#!/usr/bin/env bash
set -o pipefail
set -o errexit
set -o nounset
CONTAINER_NAME="bazel-$USER"
# replace this with your own image where bazel is installed:
IMAGE="replace_this/bazel:0.11.1"
#!/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)
/****
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:
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
);
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
@benley
benley / .nixpkgs.json
Created February 11, 2019 23:55
nix monorepo example layout
{ "url": "https://github.com/nixos/nixpkgs/archive/804c227b83faa017c377eb899d18e5931e0ad936.tar.gz" }
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) = (
#+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
@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))
(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))