Skip to content

Instantly share code, notes, and snippets.

View kapb14's full-sized avatar
😤

Aleksandr Karushin kapb14

😤
View GitHub Profile
@CHERTS
CHERTS / hotplug_add_cpu_and_mem.sh
Created September 1, 2021 09:34
Hotplug add CPU and Memory
#!/bin/bash
# Bring CPUs online
for CPU_DIR in /sys/devices/system/cpu/cpu[0-9]*
do
CPU=${CPU_DIR##*/}
echo "Found cpu: '${CPU_DIR}' ..."
CPU_STATE_FILE="${CPU_DIR}/online"
if [ -f "${CPU_STATE_FILE}" ]; then
if grep -qx 1 "${CPU_STATE_FILE}"; then
@CHERTS
CHERTS / get_linux_scheduler.sh
Last active March 3, 2023 13:21
Get Linux i/o scheduler and params
for i in $(ls -1 /sys/block/ | grep -oE 'sd[a-z]|nvme.*'); do echo -n "$i: rotational: $(cat /sys/block/$i/queue/rotational) | \
scheduler: $(cat /sys/block/$i/queue/scheduler) | \
nr_requests: $(cat /sys/block/$i/queue/nr_requests) | \
rq_affinity: $(cat /sys/block/$i/queue/rq_affinity)"; [ -f "/sys/block/$i/queue/read_ahead_kb" ] && echo -n " | read_ahead_kb: $(cat /sys/block/$i/queue/read_ahead_kb)"; [ -f "/sys/block/$i/queue/iosched/writes_starved" ] && echo -n " | writes_starved: $(cat /sys/block/$i/queue/iosched/writes_starved)"; [ -f "/sys/block/$i/queue/iosched/read_expire" ] && echo -n " | read_expire: $(cat /sys/block/$i/queue/iosched/read_expire)"; echo ""; done #| awk '!(NR%2){print p "\t\t\t" $0}{p=$0}'
@CHERTS
CHERTS / wget_on_bash.sh
Created April 28, 2021 12:05
Wget on pure Bash
#!/usr/bin/env bash
#
# Program: Wget on pure bash <wget_on_bash.sh>
#
# Author: Mikhail Grigorev <sleuthhound at gmail dot com>
#
# Current Version: 1.0.0
#
# License:
@flox1an
flox1an / default.conf
Last active September 1, 2023 07:26
nginx config that uses the oauth2-proxy (via auth_request) to authenticate against gitlab and then proxies all requests to a backend service while setting the auth headers X-User and X-Email
server {
listen 80;
server_name localhost;
location /oauth2/ {
proxy_pass http://oauth-proxy:4180;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Auth-Request-Redirect $request_uri;
@kekru
kekru / add CA cert on CentOS Debian Ubuntu.md
Last active July 29, 2024 12:10
Add CA cert to local trust store on CentOS, Debian or Ubuntu
  • Open a webpage that uses the CA with Firefox
  • Click the lock-icon in the addressbar -> show information -> show certificate
  • the certificate viewer will open
  • click details and choose the certificate of the certificate-chain, you want to import to CentOS
  • click "Export..." and save it as .crt file
  • Copy the .crt file to /etc/pki/ca-trust/source/anchors on your CentOS machine
  • run update-ca-trust extract
  • test it with wget https://thewebsite.org
@samuelcolvin
samuelcolvin / dns_server.py
Last active November 4, 2024 02:17
requires python 3.5+ and dnslib, see https://github.com/samuelcolvin/dnserver for full/better implementation
from datetime import datetime
from time import sleep
from dnslib import DNSLabel, QTYPE, RD, RR
from dnslib import A, AAAA, CNAME, MX, NS, SOA, TXT
from dnslib.server import DNSServer
EPOCH = datetime(1970, 1, 1)
SERIAL = int((datetime.utcnow() - EPOCH).total_seconds())
@mylk
mylk / selenium.service
Created August 16, 2016 14:17
Selenium standalone server systemd script
# /etc/systemd/system/selenium.service
# assumes selenium server and chromedriver exist in the following paths:
# /var/selenium/selenium-server-standalone-2.45.0.jar
# /var/selenium/chromedriver
[Unit]
Description=Selenium Standalone Server
Requires=xvfb.service
After=xvfb.service
@mylk
mylk / xvfb.service
Created August 16, 2016 14:15
Xvfb systemd script
# /etc/systemd/system/xvfb.service
[Unit]
Description=X virtual framebuffer
[Service]
Type=simple
User=root
ExecStart=/usr/bin/Xvfb :99 -ac
@kapb14
kapb14 / SigningPdfLoop.ps1
Last active June 22, 2016 08:56
набросок скрипта. после запуска батника который подписывает, осуществляется проверка "есть ли одноименный файл во временной папке и в папке с подписанными файлами", если есть - удаляет файл из временной папки.
# define folders being used
$tmpdir = "c:\tmp_pdf"
$inputdir = "c:\in_pdf"
$signeddir = "c:\signed_pdf"
$outdir = "c:\out_pdf"
$x = "C:\sign_policy_cades_cleanCopy.bat"
@jirutka
jirutka / ldap.conf
Last active July 17, 2024 10:40
Simple script for OpenSSH server to load authorization keys from LDAP. It requires just POSIX shell and ldapsearch utility. To manage keys in LDAP, use https://github.com/jirutka/ssh-ldap-pubkey.
# /etc/ssh/ldap.conf
# See ldap.conf(5) for details
# This file should be world readable but not world writable.
BASE ou=People,dc=example,dc=org
URI ldap://localhost