Skip to content

Instantly share code, notes, and snippets.

View chazer's full-sized avatar

Aleksy Chajzer chazer

  • Warszawie, Polska
View GitHub Profile
@chazer
chazer / docker-cheats.md
Last active March 16, 2022 12:14
Docker cheats

Copy volume

docker run --rm \
  -v "$VOLUME_FROM":/from:ro \
  -v "$VOLUME_TO":/to \
  -u root alpine \
  sh -c 'rm -rf /to 2>/dev/null; cd /from; cp -av . /to'
@chazer
chazer / linux-cheatsheet.md
Last active October 25, 2020 16:29
Linux cheatsheet

Linux cheatsheet

Fill file with zeros

bash -c 'read blocks blocksize < <(stat -c "%b %B" "$1"); dd if=/dev/zero bs=${blocksize} count=${blocks} of="$1" conv=notrunc status=progress' - /FILE

Create swap file

@chazer
chazer / ssh-cheatsheet.md
Last active September 29, 2020 10:37
SSH cheatsheet

SSH cheats

Copy folder to remote server

REMOTE=server.fqdn
sudo tar -cz -C `pwd` . \
    | ssh "$REMOTE" "sudo mkdir -p $(pwd) && sudo tar --same-owner --same-permissions -xzv -C $(pwd)"

Allow sudo without password on remote server

@chazer
chazer / Web proxy with Query String patch.md
Last active May 3, 2020 03:14
Web proxy with Query String patch

Example, how to remove argument from http request.

Replace requests like:

DELETE /v1/path/FILE?multipart-manifest=delete HTTP/1.1"

with:

DELETE /v1/path/FILE?
@chazer
chazer / gitignore.md
Created December 20, 2019 04:38
gitignore cheatsheet

The .gitignore file cheat sheet

Gitignore rules

Wildcard match

Rule RegExp Description
* ^[^/]+/?$ one file/dir name
** ^.*/?$ multiple file/dir names
Docker project for antminer-monitor
@chazer
chazer / docker-compose-tool
Last active October 16, 2017 12:53
docker-compose project switching
#!/bin/sh
sed_escape() { sed -e 's/[]\/$*.^|[]/\\&/g'; };
replace_env() {
local FILE=$1; shift
local ENV=$1; shift
local VAL=$1
[ -f "$FILE" ] || (
echo "File not found $FILE" >&2