Skip to content

Instantly share code, notes, and snippets.

View ps1dr3x's full-sized avatar
👨‍💻
0x1A4

Michele Federici ps1dr3x

👨‍💻
0x1A4
View GitHub Profile
@ps1dr3x
ps1dr3x / hot-partition-resize
Created May 19, 2019 13:28
Hot partition resize
swapoff -a
fdisk /dev/xxx
# delete partitions partitionX + swap (d)
# create new primary partitions partitionX + swap (n + p) with the new size
# change parititon type (t) partitionX -> 83, swap -> 82
# add bootable flag (a) partitionX
# write changes (w)
partprobe
@ps1dr3x
ps1dr3x / increase-open-files-limit-linux.txt
Last active December 9, 2018 15:48
Increase open files limit (Linux)
Append this lines to /etc/security/limits.conf
* hard nofile 500000
* soft nofile 500000
root hard nofile 500000
root soft nofile 500000
Log-out and log-in and check new limits
Hard:
@ps1dr3x
ps1dr3x / xset-led-wayland.sh
Created October 26, 2018 17:44
Turn on keyboard backlight/leds on wayland (xset led 3 alternative)
# "input0::scrolllock" might be different (?)
# On
sudo sh -c 'echo 1 > /sys/class/leds/input0::scrolllock/brightness'
# Off
# sudo sh -c 'echo 0 > /sys/class/leds/input0::scrolllock/brightness'
@ps1dr3x
ps1dr3x / self-signed-cert-with-altnames.sh
Last active October 8, 2018 10:35
Create self-signed certificate with main details and altnames (one liner)
# Location of openssl.cnf might be different
openssl req -new -newkey rsa:4096 -x509 -sha256 -days 3650 -nodes \
-subj "/C=IT/ST=BO/L=Bologna/O=Aperture Science SRL/CN=example.com" \
-extensions SAN \
-config <(cat /etc/ssl/openssl.cnf \
<(printf "\n[SAN]\nsubjectAltName=DNS:www.example.com,DNS:sub.example.com,IP:123.123.123.123")) \
-out example.crt -keyout example.key
@ps1dr3x
ps1dr3x / check-page-for-keyword.sh
Last active February 20, 2018 15:58
Script for periodically check a web page for a keyword
#!/bin/sh
#
# Script for periodically (default: 10m) check a web page for a keyword
#
# Gist:
# https://gist.github.com/ps1dr3x/5a5697ea2d37d06a34fdb38ef36050d4
#
# Usage:
# check-for-page-keyword.sh host keyword [seconds]
#
@ps1dr3x
ps1dr3x / docker-cheatsheet
Last active October 7, 2020 14:23
Docker & docker-compose cheat sheet
# Remove all containers
docker rm $(docker ps -aq)
# Remove dangling images
docker rmi $(docker images -q -f dangling=true)
# Remove all images
docker rmi $(docker images -aq)
# Remove all the unused volumes
@ps1dr3x
ps1dr3x / get-cookie.js
Created March 28, 2017 15:09
Get cookie by name