Skip to content

Instantly share code, notes, and snippets.

View benley's full-sized avatar
🐈

Benjamin Staffin benley

🐈
View GitHub Profile
/****
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)
@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"
def _check_call(repo_ctx, cmd_and_args):
"""
Execute a command with arguments, fail if it returns non-zero.
Similar to subprocess.check_call.
"""
result = repo_ctx.execute(cmd_and_args, timeout=10)
if result.return_code != 0:
fail(("Non-zero return code({1}) when executing '{0}':\n" + "Stdout: {2}\n"
+ "Stderr: {3}").format(" ".join(cmd_and_args), result.return_code,
// Helper functions and stuff related to unit conversions
{
// Parse a k8s memory resource value and return it in bytes as an integer
//
// From the Kubernetes API docs:
// > You can express memory as a plain integer or as a fixed-point integer using
// > one of these suffixes: E, P, T, G, M, K. You can also use the power-of-two
// > equivalents: Ei, Pi, Ti, Gi, Mi, Ki.
parseMemory(x)::
@benley
benley / wat
Created October 10, 2017 01:33
Oct 09 21:32:05 alnitak kernel: ------------[ cut here ]------------
Oct 09 21:32:05 alnitak kernel: WARNING: CPU: 0 PID: 0 at /tmp/nix-build-linux-4.13.5.drv-0/linux-4.13.5/net/core/dev.c:5504 net_rx_action+0x237/0x350
Oct 09 21:32:05 alnitak kernel: Modules linked in: snd_usb_audio snd_usbmidi_lib snd_rawmidi snd_seq_device igb ptp thunderbolt pps_core dca nls_utf8 ntfs asix usbnet mii libphy ctr ccm rfcomm af_packet ipt_MASQUERADE nf_nat_masquerade_ipv4 nf_conntrack_netlink nfnetlink xfrm_user xfrm_algo xt_addrtype br_netfilter bridge stp llc cmac bnep msr zram zsmalloc snd_hda_codec_hdmi snd_hda_codec_realtek snd_hda_codec_generic hid_rmi rmi_core 8250_dw i2c_designware_platform i2c_designware_core efi_pstore pstore x86_pkg_temp_thermal intel_powerclamp coretemp crct10dif_pclmul crc32_pclmul ghash_clmulni_intel intel_cstate intel_uncore intel_rapl_perf efivars snd_soc_skl snd_soc_skl_ipc snd_soc_sst_ipc snd_soc_sst_dsp snd_hda_ext_core snd_soc_sst_match tpm_crb hid_multitouch mousedev joydev snd_soc_core
#!/usr/bin/env python
"""Send desktop notifications when AC power status changes."""
from __future__ import print_function
import dbus
from dbus.mainloop import glib
import gobject
onMessage="Power plugged in!"
@benley
benley / nvim-client
Created August 14, 2017 05:04 — forked from rf-/nvim-client
#!/usr/bin/env python
import neovim, os, re, sys, time
# Get a list of buffers that haven't been deleted. `nvim.buffers` includes
# buffers that have had `:bdelete` called on them and aren't in the buffer
# list, so we have to filter those out.
def get_listed_buffers(nvim):
return set(buf.number for buf in nvim.buffers \
if nvim.eval('buflisted(%d)' % buf.number))
@benley
benley / bazel.sh
Last active July 13, 2017 16:43
handy dandy bazel-in-docker wrapper
#!/usr/bin/env bash
set -o pipefail
set -o errexit
set -o nounset
CONTAINER_NAME="bazel-$USER"
IMAGE="bazel-$USER"
function log {
echo "(wrapper) $*" 1>&2
@benley
benley / plantnames.txt
Created July 2, 2017 03:22
generated plant names
American Bluet
Anchadeleaf Sunflower
Appalachian Toathlea
Apupamper Milkweed
Arethean Yevile
Arthallia
Beeded Beary
Bellflowel Purtlefon
Bent Lilyius
Betce-Hel Pelil