Skip to content

Instantly share code, notes, and snippets.

View euank's full-sized avatar

Euan Kemp euank

View GitHub Profile
@euank
euank / Dockerfile
Last active March 14, 2023 23:40
ECS / EC2 Metadata entrypoint example
FROM golang:1.4
COPY entrypoint.sh /entrypoint.sh
COPY main.go main.go
RUN go build -o main main.go
RUN chmod +x /entrypoint.sh
EXPOSE 8080
ENTRYPOINT ["/entrypoint.sh"]
CMD ["./main"]
@euank
euank / Windows compile.md
Last active November 4, 2021 22:03
Build instructions for ponscripter-fork on windows. Possibly outdated (see project's instructions instead)

Install MinGW. Within it select the following items:

  • mingw32-libz (dev/dll)
  • mingw32-autoconf
  • mingw32-automake
  • mingw32-gcc
  • mingw32-gcc-g++
  • msys-core

Afterwards, run the pi.bat (postinstall) script that should be at C:\MinGW\msys\1.0\postinstall\pi.sh

@euank
euank / README.md
Last active July 11, 2021 02:54
Fix chrome's console.log 'TypeError: Illegal invocation'

Chrome exhibits behavior different from firefox (and other javascript environments) in that console.log requires "this" to be console. This issue is discussed here.

Simple failing code is

var helloWorld = function(callback) { 
  callback("Hello World"); 
}; 
helloWorld(console.log);

The included snippet makes failing code function correctly without any other changes required. It just has to be run before any console.logs. Similar code can be written for console.info and so on.

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
@euank
euank / libvirt_ignition.sh
Last active July 31, 2017 04:54
ignition example
function libvirt::domain::add_ignition() {
file=${1:?must set domain xml file}
ignition=${2:?must set ignition file path}
xmlstarlet ed -P -L -i "//domain" -t attr -n "xmlns:qemu" --value "http://libvirt.org/schemas/domain/qemu/1.0" "${file}"
xmlstarlet ed -P -L -s "//domain" -t elem -n "qemu:commandline" "${file}"
xmlstarlet ed -P -L -s "//domain/qemu:commandline" -t elem -n "qemu:arg" "${file}"
xmlstarlet ed -P -L -s "(//domain/qemu:commandline/qemu:arg)[1]" -t attr -n "value" -v "-fw_cfg" "${file}"
xmlstarlet ed -P -L -s "//domain/qemu:commandline" -t elem -n "qemu:arg" "${file}"
xmlstarlet ed -P -L -s "(//domain/qemu:commandline/qemu:arg)[2]" -t attr -n "value" -v "name=opt/com.coreos/config,file=${ignition}" "${file}"