Skip to content

Instantly share code, notes, and snippets.

View euank's full-sized avatar

Euan Kemp euank

View GitHub Profile
let
overlay = self: super: rec {
my-hello = super.callPackage ./pkgs/hello/default.nix {};
hello = if super.hello.version > my-hello.version then super.hello else my-hello;
};
unstable = import <nixos-unstable> {
overlays = [ overlay ];
config = { };
};
in
@euank
euank / ffinull.lua
Last active February 21, 2018 07:28
ffi = require "ffi"
null = ffi.new("void*", nil)
print("not null: ", not null)
print("null == nil: ", null == nil)
--- Prints:
--
-- not null: false
-- null == nil: true
$ pwd
/lib
$ ls -alh os-release
lrwxrwxrwx. 1 root root 37 Nov 29 13:34 os-release -> ./os.release.d/os-release-workstation
$ x=os-release
$ echo "${x:A}"
/usr/lib/os.release.d/os-release-workstation
$ echo "${x:a}"
/usr/lib/os-release
@euank
euank / example.rs
Last active December 29, 2017 04:07
//! If you're on a Unix system, try something like:
//!
//! `yes | cargo run --example count_keys`
//!
//! (Originally from
//! https://github.com/paulkernfeld/tokio-stdin/blob/master/examples/count_keys.rs)
extern crate futures;
extern crate tokio_stdin;
extern crate tokio_timer;
@euank
euank / repro-example.sh
Last active October 22, 2017 22:47
Based on https://github.com/moby/moby/issues/34672#issuecomment-331527204, what if it was rslave in both parts?
#!/bin/bash
[ $UID == 0 ] || (echo "Must be root" && exit 1)
# c1 and c2 represent two different docker containers starting at once
c1=1
c2=2
function ovlOpts() {
echo -n "lowerdir=$tmpdir/lower,upperdir=$tmpdir/$1/diff,workdir=$tmpdir/$1/work"
@euank
euank / get-moby-commit.sh
Created August 30, 2017 04:00
This resolves a docker/docker-ce tag into a moby commit hash.
#!/bin/bash
set -e
tag=${1:?arg should be a docker-ce tag, such as 'v17.07.0-ce'}
tmp=$(mktemp -d)
cd $tmp
wget https://raw.githubusercontent.com/shykes/moby-extras/master/cmd/moby-components
$ git checkout v1.7.1
$ echo "/vendor" > .ignore
$ rg '^//.*\+.*build' --no-filename -N | sort | uniq -c | sort -nr
211 // +build !ignore_autogenerated
44 // +build linux
23 // +build !linux
12 // +build windows
5 // +build !windows
5 // +build !linux,!windows
5 // +build cgo,linux
@euank
euank / test-sha.sh
Created June 12, 2017 19:52
Reproduce inconsistent sha output for docker2aci
#!/bin/bash
set -euo pipefail
for i in $(seq 1 20); do
mkdir "fetch-$i"
pushd "fetch-$i"
../bin/docker2aci docker://euank/manylabels:busybox
sudo rkt fetch --insecure-options=image *.aci > sha
sudo rkt image cat-manifest $(cat sha) > rktmanifest
cat *.aci | gunzip | tar x
@euank
euank / cloud-init.yaml
Created June 9, 2017 20:26
what linode puts at /var/lib/coreos-install/user_data
#cloud-config
users:
- name: "core"
- passwd: "***"
# The formatting of the following section is important. Don't change it!
# sytemd-networkd and dhcpcd are both packaged in Container Linux. We'll use systemd
# because that's what's used in the most minimal, out-of-the-box config at this time,
# and dhcpcd is disabled. We're giving systemd a dhcp config file so we can tell it
# to not use IPv6 privacy extensions. We also need DHCP=ipv4 b/c DHCP=all causes
-rwxr-xr-x 117 root root 2.0M Apr 26 14:06 /usr/bin/git
-rwxr-xr-x 117 root root 2.0M Apr 26 14:06 /usr/bin/git-receive-pack
-rwxr-xr-x 117 root root 2.0M Apr 26 14:06 /usr/bin/git-upload-archive
-rwxr-xr-x 117 root root 2.0M Apr 26 14:06 /usr/libexec/git-core/git
-rwxr-xr-x 117 root root 2.0M Apr 26 14:06 /usr/libexec/git-core/git-add
-rwxr-xr-x 117 root root 2.0M Apr 26 14:06 /usr/libexec/git-core/git-am
-rwxr-xr-x 117 root root 2.0M Apr 26 14:06 /usr/libexec/git-core/git-annotate
-rwxr-xr-x 117 root root 2.0M Apr 26 14:06 /usr/libexec/git-core/git-apply
-rwxr-xr-x 117 root root 2.0M Apr 26 14:06 /usr/libexec/git-core/git-archive
-rwxr-xr-x 117 root root 2.0M Apr 26 14:06 /usr/libexec/git-core/git-bisect--helper