Skip to content

Instantly share code, notes, and snippets.

View genothomas's full-sized avatar
🎯
Focusing

Geno Thomas genothomas

🎯
Focusing
View GitHub Profile
@genothomas
genothomas / generate_directory_index_caddystyle.py
Created March 24, 2022 16:27 — forked from glowinthedark/generate_directory_index_caddystyle.py
Generate directory index (recurse subfolders with `-r` or `--recursive`). Use `-h` or `--help` for all options
#!/usr/bin/env python3
# ---
# Copyright 2020 glowinthedark
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
#
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
@genothomas
genothomas / http_multithreaded.py
Created March 24, 2022 16:26 — forked from glowinthedark/http_multithreaded.py
Multi-threaded Python3 HTTP Server
#!/usr/bin/env python3
import sys, os, socket
from socketserver import ThreadingMixIn
from http.server import SimpleHTTPRequestHandler, HTTPServer
HOST = socket.gethostname()
class ThreadingSimpleServer(ThreadingMixIn, HTTPServer):
pass
@genothomas
genothomas / private_fork.md
Created March 10, 2022 22:47
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare [email protected]:usi-systems/easytrace.git

@genothomas
genothomas / sockping.sh
Created June 22, 2021 06:38 — forked from khmarochos/sockping.sh
To establish a TCP-connection and be keeping it alive
#!/bin/bash
function log {
echo $(date) ' >> ' $* >&2
}
function die {
echo $* >&2
exit 1
}
for dir in $(find /export/secondary2/snapshots -wholename '/export/secondary2/snapshots/*/*' -type d); do { files=$(ls "${dir}" | wc -l); if [[ "${files}" -gt 2 ]]; then echo $dir; ls -tl "${dir}"; for file in $(ls -t "${dir}" | tail --lines +3); do { read -p "Remove ${file}?" -n 1 -r; if [[ "${REPLY}" =~ ^[Yy]$ ]]; then echo " ... removing ${dir}/${file}"; rm "${dir}/${file}"; else echo " ... skipping ${dir}/${file}"; fi; } done; fi; } done
for dir in $(find /export/secondary2/snapshots -wholename '/export/secondary2/snapshots/*/*' -type d -mtime +21); do { if [[ "$(ls ${dir} | wc -l)" -lt 1 ]]; then continue; fi; ls -tl "${dir}"; read -p "Remove ${dir}?" -n 1 -r; if [[ "${REPLY}" =~ ^[Yy]$ ]]; then echo " ... removing ${dir}"; rm -rf "${dir}"; else echo " ... skipping ${dir}"; fi; } done
@genothomas
genothomas / servers
Created June 22, 2021 06:37 — forked from khmarochos/servers
To run a command on a bunch of servers, so you can say: spread.sh --command 'rm -rf / &' --grep-criteria '#centos|#msdos'
#
# The format is following:
# hostname:username:port:ssh-key #comments #tags
# All parameters besides of the first are optional
#
# Regular servers
host1
host2
host3
# The servers where we shall use an alternative username to log in
@genothomas
genothomas / diskhogs.sh
Created June 22, 2021 06:36 — forked from khmarochos/diskhogs.sh
Ever craved for a tool to monitor what files are growing faster than other ones? Just run it by cron: diskhogs.sh /var/lib/libvirt/images
#!/bin/sh
# Checking the spool directory
SPOOL=/var/spool/diskhogs
if [ ! -e "${SPOOL}" ]; then
mkdir -p "${SPOOL}"
fi
if [ ! -d "${SPOOL}" ]; then
echo "There are no ${SPOOL} directory" >&2
exit 1
@genothomas
genothomas / .bash_today
Created June 22, 2021 06:36 — forked from khmarochos/.bash_today
.bash_today: This simple script lists today’s tasks every time you log in (or create a new window in your screen)
# Just add me to your .bashrc:
# [ -x ~/.bashrc_today ] && . ~/.bashrc_today
TODAYD="${HOME}/.today.d"
if [ ! -d "${TODAYD}/today" ]; then
mkdir -p "${TODAYD}/today"
fi
TODAY=$(date +%F)
#!/bin/sh
PATH=/bin:/usr/bin
HOME=~
HOSTNAME=$(hostname)
USER=$(echo "${HOSTNAME}" | sed "s/\.tucha13\.net$//")
INCLUDES="/etc/rsync-backup.includes"
EXCLUDES="/etc/rsync-backup.excludes"
BSERVERADDR="backup.z2.tucha13.net"
BSERVERPORT="22"
@genothomas
genothomas / nginx-tuning.md
Created June 2, 2021 14:03 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.