Skip to content

Instantly share code, notes, and snippets.

View benley's full-sized avatar
🐈

Benjamin Staffin benley

🐈
View GitHub Profile
@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"""
$ 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 / 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) []
with import <nixpkgs> {};
let
callPackage = pkgs.lib.callPackageWith (pkgs // self);
self = rec {
frame = callPackage ./frame.nix { };
grail = callPackage ./grail.nix { };
@benley
benley / default.nix
Last active August 29, 2015 14:14
Nix private packages example
{ system ? builtins.currentSystem, github_token ? "" }:
let
pkgs = import <nixpkgs> { inherit system; };
python27Packages = pkgs.recurseIntoAttrs (
callPackage ./third_party/python_packages.nix {
python = pkgs.python27;
self = combinedPython27Packages;
});
Fatal error running command:
Traceback (most recent call last):
File "/usr/bin/aurora2/apache/aurora/client/cli/__init__.py", line 394, in _execute
result = noun.execute(context)
File "/usr/bin/aurora2/apache/aurora/client/cli/__init__.py", line 481, in execute
return self.verbs[context.options.verb].execute(context)
File "/usr/bin/aurora2/apache/aurora/client/cli/jobs.py", line 243, in execute
context.print_out(config.job())
File "/usr/bin/aurora2/apache/aurora/client/cli/__init__.py", line 131, in print_out
lines = msg.split("\n")
@benley
benley / Gemfile.nix
Created January 6, 2015 21:35
nix expression for a custom ruby app with various custom gem dependencies
# WARNING: automatically generated file
# Generated by 'gem nix' command that comes from 'nix' gem
g: # Get dependencies from patched gems
{
aliases = {
archive_tar_minitar = g.archive_tar_minitar_0_5_2;
aws_sdk = g.aws_sdk_1_60_2;
aws_sdk_v1 = g.aws_sdk_v1_1_60_2;
docker_api = g.docker_api_1_17_0;
excon = g.excon_0_42_1;
@benley
benley / nix-profile.sh
Created January 6, 2015 07:57
tweaked nix login script
# Heavily cribbed from the equivalent NixOS login script.
# This should work better with multi-user nix setups.
export NIXPKGS_CONFIG="/etc/nix/nixpkgs-config.nix"
export NIX_OTHER_STORES="/run/nix/remote-stores/*/nix"
export NIX_USER_PROFILE_DIR="/nix/var/nix/profiles/per-user/$USER"
export NIX_PROFILES="/nix/var/nix/profiles/default $HOME/.nix-profile"
export NIX_PATH="/nix/var/nix/profiles/per-user/root/channels"
export PATH="$HOME/.nix-profile/bin:$HOME/.nix-profile/sbin:/nix/var/nix/profiles/default/bin:/nix/var/nix/profiles/default/sbin:$PATH"

Keybase proof

I hereby claim:

  • I am benley on github.
  • I am benley (https://keybase.io/benley) on keybase.
  • I have a public key whose fingerprint is 719C 0914 5AAF D8B2 0281 7248 8352 96E6 21E1 FA28

To claim this, I am signing this object:

@benley
benley / avgdur.py
Created August 13, 2013 03:17
calculate average runtimes of jenkins jobs
#!/usr/bin/python2.7
"""Average DURRRRRR - get average runtime of a jenkins job.
This is obviously just an example - a plain average of the runtimes
isn't actually all that useful. Use numpy, do something fancier.
"""
import datetime
import gflags
import json