Skip to content

Instantly share code, notes, and snippets.

@AndersonIncorp
AndersonIncorp / wireguard-mikrotik-torrent-proxy.md
Created December 30, 2023 14:25
Proxy torrent traffic via home router, hides and encrypts torrent traffic to dedicated server running torrent client.

Overview

  • Home MikroTik router
    • Static IP: 203.0.113.2
  • Dedicated server
    • Static IP: 203.0.113.1

51413 home router port will be forwarded to/from dedicated server via wireguard interface, this allows server to download torrents without exposing it's IP or hosting provider knowing about it.

@AndersonIncorp
AndersonIncorp / fix.sh
Created May 23, 2017 12:53
GRUB loading. Welcome to GRUB! error: file `/boot/grub/i386-pc/normal.mod` not found.
# GRUB loading.
# Welcome to GRUB!
#
# error: file `/boot/grub/i386-pc/normal.mod` not found.
# Entering rescue mode...
grub rescue> ls
hd(0) (hd0,msdos1)
grub rescue> set
cmdpath=(hd0)
prefix=(hd0,msdos1)/boot/grub
@AndersonIncorp
AndersonIncorp / install.md
Created June 29, 2018 16:36
Install any linux distro on VPS with low RAM, locked ISO boot

Overview

Scenario

  • Your VPS provider doesn't support ISO mount
  • Your VPS has low RAM and cannot load whole ISO image
  • Your current /boot is to small to contain ISO file

Workaround

  • Boot low memory ISO (CorePure64.iso ~ 14MB)
  • Create new partition ~1GB / size of your ISO
  • dd your ISO into that partition
@AndersonIncorp
AndersonIncorp / netboot.xyz.md
Created June 27, 2018 21:48
Install netboot.xyz.lkrn into grub

Install netboot.xyz.lkrn into grub

wget https://boot.netboot.xyz/ipxe/netboot.xyz.lkrn -O /boot/netboot.xyz.lkrn
nano /etc/grub.d/40_custom
#/etc/grub.d/40_custom
menuentry "netboot.xyz.lkrn" {
    linux16 (hd0,msdos1)/netboot.xyz.lkrn # /boot is (hd0,msdos1) drive
}
#
# One of
@AndersonIncorp
AndersonIncorp / redis_lua_smembers_hgetall_list.lua
Created September 10, 2023 20:58
lua script to get members of set then return hash for each key
https://gist.github.com/luke/dbca647bf07d1843ab47
local members = redis.call('SMEMBERS', KEYS[1])
local results = {}
for index, key in ipairs(members) do
results[index] = redis.call('HGETALL', KEYS[1] .. '/' .. key)
end
return results
1
@AndersonIncorp
AndersonIncorp / build-php-zts7.2.1-archlinux.txt
Created March 25, 2018 19:04
build-php-zts7.2.1-archlinux.txt php-zts7.2.1 or php7.2.1 without conflict with main php
# ! /bin/bash
# Build of php-zts OR php (if remove --enable-maintainer-zts flag) as second php into /usr/local/php/php-zts7.2.1
# Based on
# https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=php-zts
mkdir -p /root/aur-php/
cd /root/aur-php/
curl -O https://aur.archlinux.org/cgit/aur.git/snapshot/php-zts.tar.gz
tar -xzf php-zts.tar.gz -C patch
curl -O -L https://php.net/distributions/php-7.2.1.tar.xz
@AndersonIncorp
AndersonIncorp / mikrotik-ovpn.md
Last active March 5, 2022 22:54
Short guide for setting up MikroTik ovpn server

CA cert

> System > Certificates
    > [Add new]
        Name: ca
        Country: UA
        Common name: ca
        Key size: 4096
        Key Usage: key cert. sign
@AndersonIncorp
AndersonIncorp / arch-openvpn-udp-tcp-server.md
Last active March 5, 2022 21:27
MIT License; Short guide for setting up openvpn-server service (tcp+udp), full network (redirect-gateway def1); Optional - Second VPS with traffic redirect to first via iptables; Optional - SSH tunneling for DPI prevention (pubkey)
$ pacman -S openvpn easy-rsa
$ cp -a /etc/easy-rsa/. /etc/easy-rsa-clientnet/
$ cd /etc/easy-rsa-clientnet/
$ export EASYRSA=$(pwd)
$ easyrsa init-pki
$ easyrsa build-ca nopass
$ easyrsa gen-req server nopass
$ easyrsa sign-req server server
@AndersonIncorp
AndersonIncorp / postfix.md
Last active January 24, 2022 22:51
postfix && dovecot virtual email setup (redirect to gmail+alias from domain)

postfix && dovecot virtual email setup (redirect to gmail+alias from domain)

Example shows 2 domains in 1 IP address && 1 postfix instance. All redirected to Gmail.
First domain used as myhostname and is main domain. Others is virtual_alias_domains
Dovecot configured to use passwd database without IMAP && POP3. SMTP auth only
Gmail configured to send emails from our domains (using smtp TLS port 25).
DNS && SPF && PTR records. Example provided.

Brief config overview
Domains /etc/postfix/main.cf
@AndersonIncorp
AndersonIncorp / install.sh
Last active November 30, 2021 05:56
OS X to Linux gcc cross compiler build (arch linux x86_64 as target)
#!/bin/bash
set -e
# Prerequirements
# brew install gcc (gmp libmpc mpfr isl)
# copy /usr/lib && /usr/include from arch linux into your CC_ROOT.
# /usr/local/linux/usr/include
# /usr/local/linux/usr/lib
# /usr/local/linux/usr/local/include
# arch linux is target enviroment for this cross compiler
# x86_64 binutils && gcc