Skip to content

Instantly share code, notes, and snippets.

View benley's full-sized avatar
🐈

Benjamin Staffin benley

🐈
View GitHub Profile
abutinniana
achlida
acila
adelin
adrie
aduna
adusto
aima
albria
alisa
@benley
benley / jq.BUILD
Created June 21, 2017 20:55
bazel build jq
licenses(["notice"])
cc_binary(
name = "jq",
visibility = ["//visibility:public"],
srcs = glob([
"*.h",
"*.c",
]),
copts = [
#!/usr/bin/env bash
# Copyright 2016 Postmates Inc.
#
# Author: Benjamin Staffin
#
# Logging library for bash scripts
#
# Features:
# * Nicely formatted messages with timestamp, source file and line number
# * Stack traces on abnormal exits, similar to Python
{ config, lib, ... }:
{
nixpkgs.config.packageOverrides = super: let self = super.pkgs; in
{
myHaskellEnv = self.haskellPackages.ghcWithHoogle
(haskellPackages: with HaskellPackages; [
# libraries
arrows async cgi criterion
# tools
module Parse where
import Control.Monad (void)
import qualified Data.Char
import Text.Megaparsec
import Text.Megaparsec.String
import qualified Text.Megaparsec.Lexer as L
data JsonnetNumber = JInt Integer
| JFloat Double
@benley
benley / rules.prom
Last active December 15, 2016 19:56
# What's the difference in meaning between these two prometheus rules?
query_version_a =
(
sum
by (source)
(
(
(
rate(cpu_user_seconds_total[3m])
@benley
benley / P1b.hs
Last active December 5, 2016 07:25
{-# LANGUAGE TupleSections #-}
module P1b where -- http://adventofcode.com/2016/day/1
import Data.String.Utils (split, strip)
data Direction = North | East | South | West
runbunny :: Integral a => Read a =>
[(a, a)] -- coordinates already visited
# Generated by running `configure --enable-unicode=ucs2` on MacOS 10.11.6
DEFINES_DARWIN = [
"Py_PYCONFIG_H",
"DOUBLE_IS_LITTLE_ENDIAN_IEEE754=1",
"ENABLE_IPV6=1",
"HAVE_ACOSH=1",
"HAVE_ADDRINFO=1",
"HAVE_ALARM=1",
"HAVE_ALLOCA_H=1",
"HAVE_ASINH=1",
"""gen_build_data: generate build_data from various templates.
This does something very simple: concatenates bazel's stable-status and
volatile-status linkstamp data with an optional header and footer.
"""
def _gen_build_data_impl(ctx):
cmd = ["cat"]
inputs = [
ctx.version_file, # volatile-status.txt
#!/bin/bash
# This script will be run bazel when building process starts to
# generate key-value information that represents the status of the
# workspace. The output should be like
#
# KEY1 VALUE1
# KEY2 VALUE2
#
# If the script exits with non-zero code, it's considered as a failure