Skip to content

Instantly share code, notes, and snippets.

View benley's full-sized avatar
🐈

Benjamin Staffin benley

🐈
View GitHub Profile
@benley
benley / debian-netinstall-hack.md
Created August 5, 2012 08:06
A quick and dirty netinstall method for Debian

A quick and dirty netinstall method for Debian

Requirements:

  • An existing computer (or virtual machine) running Linux. Other unix variants may work, but no guarantees. You need root access.
  • An internet connection. Duh.
  • The target machine and your netboot server must be on the same vlan (Ethernet segment). If you're doing this at home, they probably are.
  • The target machine must be connected to the network via wired ethernet, not wifi. PXE booting doesn't work with wifi.

For purposes of this document, I'm going to assume that you are installing Debian on an x86 or amd64 system.

@benley
benley / mandelbrot.sh
Created February 19, 2013 08:30
Mandelbrot set generator in Bash
#!/bin/bash -i
# Draws a mandelbrot set.
# Author: Benjamin Staffin
#
# Simulates floating point by using big integers. Flagrantly uses two integers
# instead of complex numbers. I couldn't be arsed to calculate infinity limits
# of logarithmic functions in bash, so this just uses escape time values for
# colors.
#
# Algorithm reference: http://en.wikipedia.org/wiki/Mandelbrot_set#For_programmers
@benley
benley / gist:5953657
Created July 9, 2013 00:24
python vim niceties
" You most likely want these set in your vimrc:
filetype plugin indent on
" These three are used by the indent function below:
let s:maxoff = 50 " maximum number of lines to look backwards.
let pyindent_nested_paren="&sw*2"
let pyindent_open_paren="&sw*2"
" See http://google-styleguide.googlecode.com/svn/trunk/pyguide.html,
@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

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 / 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"
@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;
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 / 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;
});
with import <nixpkgs> {};
let
callPackage = pkgs.lib.callPackageWith (pkgs // self);
self = rec {
frame = callPackage ./frame.nix { };
grail = callPackage ./grail.nix { };