Skip to content

Instantly share code, notes, and snippets.

View sgnn7's full-sized avatar
🤔
ǝʌᴉʇɔǝdsɹǝd ɹnoʎ ǝƃuɐɥƆ

Srdjan Grubor sgnn7

🤔
ǝʌᴉʇɔǝdsɹǝd ɹnoʎ ǝƃuɐɥƆ
View GitHub Profile
@sgnn7
sgnn7 / iptables-block-repeating-offenders.conf
Last active October 27, 2016 20:12
fail2ban permanent ban configuration
# Fail2Ban configuration file
#
# Author: Srdjan Grubor <sgnn7@sgnn7.org>
[Definition]
# Option: actionstart
# Notes: Executed once at start of Fail2Ban.
# Values: CMD
actionstart = iptables -N fail2ban-PERMABAN-LOGGER
# project nfd (0.5.0) configured on Thu Jan 12 19:43:23 2017 by
# waf 1.8.9 (abi 98, python 2070bf0 on linux2)
# using ./waf configure --prefix=/usr --includedir=/usr/include --mandir=/usr/share/man --infodir=/usr/share/info --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib/arm-linux-gnueabihf --libexecdir=/usr/lib/arm-linux-gnueabihf --without-websocket --without-libpcap
#
----------------------------------------
Setting top to
/usr/src/packages/BUILD/nfd-0.5.0+dev1.2d26161
----------------------------------------
Setting out to
/usr/src/packages/BUILD/nfd-0.5.0+dev1.2d26161/build
@sgnn7
sgnn7 / get_latest_kernel.sh
Last active June 13, 2018 05:51
Fetches latest mainline kernel from upstream Ubuntu and verifies the validity of the files retrieved
#!/bin/bash -e
CURRENT_DIR=$(pwd)
BASE_URI="http://kernel.ubuntu.com/~kernel-ppa/mainline"
FINGERPRINT="60AA 7B6F 3043 4AE6 8E56 9963 E50C 6A09 17C6 22B0"
ARCH=$(dpkg --print-architecture)
declare -A FILES=([sources]="SOURCES" \
[commit]="COMMIT" \
[linux-image]="linux-image- generic_ ${ARCH}" \
@sgnn7
sgnn7 / aws_ec2_wait.sh
Last active December 17, 2020 15:17
Wait for AWS EC2 snapshot or volume for longer than 20 mins
#!/bin/bash -e
EC2_REGION="us-west-1"
DEFAULT_PROGRESS_WAIT=5
# ========== SNAPSHOT WAIT ==============
snapshot_id="snap-testtesttest"
while [ "$snapshot_progress" != "100%" ]; do
sleep "$DEFAULT_PROGRESS_WAIT"
@sgnn7
sgnn7 / flatpak_mutliarch.md
Last active August 10, 2017 16:29
Build foreign arch target Flatpak in a Docker instance (Docker optional though)

Multiarch Flatpak in Docker

  • (Optional if on Docker) Run your docker instance
    • Ensure that you include --privileged flag
    • Ensure to have qemu-user-static package in your Dockerfile
  • Add --arch flag to flatpak's manifest or build-init, runtime --install, runtime --update, build-export, and build-bundle stages if doing it manually.
  • Add new binfmt for your target arch. This is because you won't have qemu within the Sdk probably and you can't bindmount /usr into the flatpak container
    • WARNING! This will change handling of those arch QEMU emulators on your host too!
    • Mount binfmt with mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
    • Remove old qemu mapping with echo -1 > /proc/sys/fs/binfmt_misc/qemu-<arch_name>
@sgnn7
sgnn7 / create_csr.sh
Last active October 12, 2017 13:28
Script to easily generate a CSR even if you have SAN names
#!/bin/bash -e
BITS=${BITS:-4096}
KEY_ENCRYPTION_PASS=$(apg -a 1 -E '?|$%()\<>^!*`{}[],.' -m 16 -n 1)
if [ $# -lt 2 ]; then
echo "Usage $0 <FQDN> [ <subjAltName> ... ] <CSR challenge pass>"
exit 1
fi
$ sudo dhcpdump -i wlan0
...
TIME: 2017-12-21 10:43:43.110
IP: 192.168.10.1 (9c:ad:ef:31:c2:3e) > 192.168.10.148 (d8:fc:93:14:df:3e)
OP: 2 (BOOTPREPLY)
HTYPE: 1 (Ethernet)
HLEN: 6
HOPS: 0
XID: b7f2490e
SECS: 0
@sgnn7
sgnn7 / Dockerfile
Last active December 11, 2018 10:09
Mesos deb build on Ubuntu 18.04 for Ubuntu 18.04 deployment
FROM ubuntu:18.04
LABEL version="0.1"
ENV OUTPUT_DIR="/opt/artifacts"
RUN mkdir $OUTPUT_DIR
VOLUME $OUTPUT_DIR
# Packaging requirements
@sgnn7
sgnn7 / dynamic_obj_creation.go
Last active June 18, 2018 14:01
Instantiate an abstract Golang struct dynamically with parameters
package main
// Author: Srdjan Grubor
// License: Apache-2.0
import (
"fmt"
)
// Interface common for all classes
class OldErrorClass
def self.new(msg)
Class.new(RuntimeError) do
def initialize(*args)
@args = args
end
define_method(:to_s) do
@args.each.with_index.reduce(msg) do |m,(x,i)|
m.gsub(Regexp.new("\\{#{i}}"), x || 'nil')
end