Skip to content

Instantly share code, notes, and snippets.

View RainMark's full-sized avatar

RainMark

View GitHub Profile
@RainMark
RainMark / bash_strict_mode.md
Created March 1, 2024 10:25 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation
@RainMark
RainMark / parallel
Created March 1, 2024 09:07 — forked from mjambon/parallel
bash: Run parallel commands and fail if any of them fails
#! /usr/bin/env bash
#
# Run parallel commands and fail if any of them fails.
#
set -eu
pids=()
for x in 1 2 3; do
@RainMark
RainMark / colorize-emacs.bashsource
Created May 5, 2023 06:05 — forked from algal/colorize-emacs.bashsource
Setting up truecolor (24 bit color) in emacs in the terminal, under iTerm2, blink.sh, and others.
# sourcing this file will define a bash functions that
# tries to run subsequent calls to emacs with 24 bit color.
#
# It sets TERM=xterm-emacs-leg if
# - we've created a user-local terminfo record for xterm-emacs-leg, and
# - we're using iTerm2 or something has set COLORTERM=truecolor
#
# This will cause emacs to use 24 bit color only when it will work,
# inside or outside of tmux. I haven't found a way to auto-detect Blink.sh yet.
#
@RainMark
RainMark / httpsrv.py
Created January 4, 2023 06:14 — forked from darkr4y/httpsrv.py
python simple http server with upload & download
#!/usr/bin/env python
"""Extend Python's built in HTTP server to save files
curl or wget can be used to send files with options similar to the following
curl -X PUT --upload-file somefile.txt http://localhost:8000
wget -O- --method=PUT --body-file=somefile.txt http://localhost:8000/somefile.txt
__Note__: curl automatically appends the filename onto the end of the URL so
@RainMark
RainMark / anybind_aio.py
Created November 12, 2021 10:36 — forked from toke/anybind_aio.py
Using TPROXY to bind to any port on many IPs (asyncio variant)
import asyncio
import socket
BIND_IP = "127.0.0.1"
TCP_PORT = 1234
SOCK_BACKLOG = 32
IP_TRANSPARENT = 19
desc = f"""
Anybind; "bind" on many IPs and many Ports.
@RainMark
RainMark / snat_dnat_advantech.md
Created November 12, 2021 01:47 — forked from tomasinouk/snat_dnat_advantech.md
examples of SNAT, DNAT with iptables for Advantech, Conel routers, with comments (probably will work on other routers where iptables can be manipulated, care needs to be taken on applying these commands after reboot).

Some examples of SNAT, DNAT with iptables with comments

mainly used in start-up script

masquarade all outgoing packets to be WLAN0 IP

iptables -t nat -A PREROUTING -s 192.168.1.2 -i eth0 -j MASQUERADE

All packets leaving eth0 will have src eth0 ip address

@RainMark
RainMark / macros.el
Created July 22, 2020 03:09 — forked from caiorss/macros.el
Emacs Lisp/Elisp Macro Examples
;; Elisp session in REPL IELM
;;
;;
;;
ELISP> (defmacro inc (var)
(list 'setq var (list '1+ var)))
inc
ELISP> (setq x 0)
0 (#o0, #x0, ?\C-@)
@RainMark
RainMark / deploy-automated-hadoop-setup-on-lxd.sh
Created May 11, 2017 12:35 — forked from ruanbekker/deploy-automated-hadoop-setup-on-lxd.sh
Sets up a Hadoop 3 Node Cluster with LXC Containers on LXD (Automated Install)
#!/bin/bash
set -ex
UBUNTU_VERSION="14.04"
mkdirs(){
lxc delete hadoop-master --force
lxc delete hadoop-slave-1 --force
lxc delete hadoop-slave-2 --force
rm -rf /tmp/*