Skip to content

Instantly share code, notes, and snippets.

View benley's full-sized avatar
🐈

Benjamin Staffin benley

🐈
View GitHub Profile
@benley
benley / exhibitor2dns.hy
Created February 13, 2015 09:15
mostly literal translation of exhibitor2dns.py into hylang
#!/usr/bin/env hy
(import argparse boto logging requests)
(def *usage*
"exhibitor2dns: Dynamic DNS for Exhibitor-run Zookeeper ensembles.")
(defn parse_args []
(setv parser
(apply (. argparse ArgumentParser) []
$ pkgs/development/web/iojs/update-iojs
Getting latest stable version from https://iojs.org/dist/
-> 1.5.1
Getting latest nightly version from https://iojs.org/download/nightly/
-> 1.5.2-nightly201503173c8ae2d934
Finding hash for https://iojs.org/dist/v1.5.1/iojs-v1.5.1.tar.gz
-> 0zdxdb9n0yk6dp6j6x3bka7vrnf7kz8jjcpl6fw5fr9f742s9s26
Finding hash for https://iojs.org/download/nightly/v1.5.2-nightly201503173c8ae2d934/iojs-v1.5.2-nightly201503173c8ae2d934.tar.gz
-> 10blf1hr80fknrzyrbj7qy2xn7wilnyn6y2r7ijrw2gns4ia3d0h
$ echo $?
@benley
benley / elasticsearch.aurora.py
Last active August 29, 2015 14:19
Aurora job with Nix packages example
# Most of a working example elasticsearch instance
include('common/nix.aurora')
include('common/util.aurora')
proc_elasticsearch = Process(
name = 'elasticsearch',
daemon = True,
cmdline = unindent(
r"""
let
lib = import <nixpkgs/lib>;
docker_registry = https://docker-registry.example.com;
master_zk_url = zk://zookeeper.example:2181/mesos;
attributes = {
os = "nixos";
host = null; # hostname
rack = "1"; # us-east-1a etc
{ config, lib, pkgs, ... }:
services.mesos.master = {
enable = true;
zk = "zk://zookeeper.example.com:2181/mesos";
extraCmdLineOptions = [
"--cluster=name_your_cluster"
];
quorum = 2 # floor((number of mesos masters)/2) + 1
};
##### DPI STUFF
# Fonts: 192dpi
Xft/DPI 196608
### Use either this:
#Gdk/UnscaledDPI 196608
#Gdk/WindowScalingFactor 1
### *or* this:
@benley
benley / hydra.aurora
Created June 1, 2015 09:08
Hydra on aurora
include('lib/nix.aurora')
include('lib/structs.aurora')
include('hydra.secrets')
class Logo(Struct):
url = Required(String)
filetype = Default(String, 'png')
GRAVATAR = Logo(
url = "https://secure.gravatar.com/avatar/13ddbf022b98acb2e32dbe8d72b81b22.jpg",
@benley
benley / middleware.wsgi
Last active February 24, 2017 10:33
wsgi middleware for basic Prometheus monitoring instrumentation
"""WSGI middleware for basic Prometheus monitoring instrumentation."""
import prometheus_client
import werkzeug.wrappers
Counter = prometheus_client.Counter
Histogram = prometheus_client.Histogram
INF = float('inf')
{ pythonPackages }:
let
buildPythonScript = { src, ... }@args:
let
name = args.name or (removeSuffix ".py" (baseNameOf src));
setup.py = builtins.toFile "setup.py" ''
import setuptools
setuptools.setup(
name = "${name}",
#!/usr/bin/env python
"""Generate authorized_keys for Github users/teams/organizations."""
from __future__ import print_function
import github
from pyglib import app
from pyglib import gflags
from pyglib import log
gflags.DEFINE_string(