Skip to content

Instantly share code, notes, and snippets.

View wader's full-sized avatar
🦫

Mattias Wadman wader

🦫
View GitHub Profile
@wader
wader / gist:bd548cc5f20cc8650cc7739832d76db5
Created December 2, 2017 11:03
go regexp replace capture group
func replace(content string, re *regexp.Regexp, s string) (string, string) {
v := re.FindStringSubmatchIndex(content)
if v == nil {
return content, ""
}
p0 := v[2]
p1 := v[3]
return content[0:p0] + s + content[p1:], content[p0:p1]
}
@wader
wader / gist:1a5639aa6699b2b2e0ef6155ca06d3d3
Last active April 8, 2019 15:11
docker container with full privileges and no namepaces
docker run -ti --rm --user=0 --privileged --pid=host --userns=host --uts=host --network=host --ipc=host -v /:/host_root <image>
not much of a "container" but very useful for debugging
if you run this on docker for mac /host_root will be the root of the linuxkit vm and not your mac
package main
import (
"crypto/tls"
"net/http"
"net/http/httputil"
"net/url"
)
func main() {
@wader
wader / disable-syscalls.go
Last active March 14, 2018 00:10
disable syscalls with seccomp
// Usage: ./disable-syscalls socket fork vfork clone -- /usr/bin/curl http://test.com
package main
import (
"log"
"os"
"syscall"
"unsafe"
)
maybe something like this
don't think you need to do docket network create... should only be need if you use external
not sure about the service networks yml syntax when thre is settings (ipv4_address)
services:
app:
...
networks:
default # <-- to still be part of the compose <projectname>_default bridge network
Pod
Service
Volume
Namespace
namespace1
pod1
container1
container2
pod2

Pod Service Volume Namespace

namespace1 pod1 container1 container2 pod2

docker run --rm -ti -v "$PWD:$PWD" -w "$PWD" debian
apt-get update && apt-get install adb
adb connect ...
adb install -r file
adb push blabla /sdcard/Download
@wader
wader / Dockerfile
Last active August 26, 2018 16:12
Run command in image, for example list files in docker image
# docker build --no-cache https://gist.githubusercontent.com/wader/fd3fab0705cb75ecc964bc84a661d686/raw/ --build-arg IMAGE=alpine --build-arg CMD="find . | cut -c 2- | sort"
ARG IMAGE=alpine
FROM $IMAGE as image
FROM alpine
ARG CMD="find . | cut -c 2- | sort"
COPY --from=image / /image
WORKDIR /image
RUN $CMD
@wader
wader / go.mod
Created December 5, 2018 21:01
Reverse socks5 proxy
module github.com/wader/rsocks5
require (
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc // indirect
)