Skip to content

Instantly share code, notes, and snippets.

View imerr's full-sized avatar
🍪
Coding

Robin Rolf imerr

🍪
Coding
View GitHub Profile
@imerr
imerr / at.slice
Last active September 11, 2023 13:15
ArchiveTeam docker cpu priority
# in /etc/systemd/system/at.slice on debian
[Slice]
# optional: maximum memory usage of this slice, prevents system oom situations if a container balloons due to changes
#MemoryMax=20G
# if the cpu is 100% maxed out, at.slice processes don't get any cpu at all. They only get cpu if there is otherwise idle capacity
CPUWeight=idle
# for more options see man systemd.resource-control (or https://manpages.debian.org/bookworm/systemd/systemd.resource-control.5.en.html I guess)
@imerr
imerr / gist:614e534218a6b93be1a40b088dee885a
Last active June 4, 2024 16:28
cursed ipv6 snat for archiveteam docker containers
# The following is a guide for debian 12 (bookworm), it should work on all modern distros and the concepts will apply to any OS of your choosing
# What this will do is create a dual-stack (so ipv4 and ipv6) docker network you can add to your containers and add NAT for this network so any requests are mapped to a random IP from the specified range
# NOTE: Due to how linux does SNAT (source: http://blog.asiantuntijakaveri.fi/2017/03/linux-snat-with-per-connection-source.html) the outgoing ip SNAT picks is "sticky", linux hashes the source ip and uses that to pick the outgoing IP, in the usual /64 setup it seems to switch between 2 outgoing ips
# The blog post links a kernel patch to change this, but I don't want to get into patching the kernel (here, or at all to be honest).
# I have thought of a workaround to try, adding many SNAT rules with a sub-set of the ip range for each source port (as those should be random), then you'd get ~40k (rough untested guesstimate) ips per container, but I don't kno
@imerr
imerr / deterministicnetworkobjects.cs
Last active June 27, 2022 09:21
DeterministicObject parent stuff (untested)
public struct DeterministicObjectSpawnState {
public byte PrefabIndex;
public Vector3 Position;
public Quaternion Rotation;
// ...
}
public class DeterministicObject : MonoBehaviour {
public void Init(DeterministicObjectSpawnState state) {
// ... do something ...
}
@imerr
imerr / add_file_to_apk.sh
Created May 30, 2019 10:00
Add file to apk and resign
aapt add $PATH_TO_APK $FILES
zipalign -c -v 4 $PATH_TO_APK
apksigner sign --ks $PATH_TO_KEYSTORE $PATH_TO_APK
@imerr
imerr / systemd-multi.md
Last active September 12, 2018 10:21
Systemd start multiple instances with main control

Template service: /etc/systemd/system/[email protected]

[Unit]
Description=manages the NAME service, instance %i
PartOf=NAME.target

[Service]
Type=simple
User=root
@imerr
imerr / sign
Last active August 20, 2018 02:54
sign an executable
set PATH=%PATH%;C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\x64
signtool.exe sign /tr http://timestamp.digicert.com /td sha256 /fd sha256 filename.exe
@imerr
imerr / nginx-lua-unity-cloud-build.conf
Created April 26, 2018 05:57
Unity cloud build hook for build downloading with nginx lua
server {
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
server_name example.com;
root /var/www/example/httpdocs/;
include /etc/nginx/vhost-common.conf;
index index.html index.html index.php;
client_max_body_size 100m;
@imerr
imerr / xsplit-pretzel.js
Created April 20, 2018 02:55
Loads current playing track from pretzel api
/**
* @name URLTOLOAD
* @label Url to Load
* @type text
* @description The web address/url from where to extract text
*/
var URLTOLOAD = "https://api.pretzel.rocks/api/v1/playing/YOUR ID HERE?limit=1";
/**
@imerr
imerr / gist:7fb5ca8a03f7d81838be0f641bc5c956
Last active April 11, 2018 03:18
reverse download nginx proxy
server{
listen 80 default_server;
listen [::]:80 default_server;
allow 1.2.3.4; # whitelist server
deny all;
location / {
return 403;
}
location ~/i/(?<rdomain>[a-zA-Z0-9-\.]+)/ {
@imerr
imerr / backup.sh
Created December 12, 2017 21:46
MySQL Backup Script
#!/bin/bash
########################
######## CONFIG ########
########################
databases=("database1" "database2" "database3")
mysql_host="localhost"
mysql_user="asdf"
mysql_password="pass"
storage_dir="/backups"
name="mysql"