Skip to content

Instantly share code, notes, and snippets.

@mpapi
mpapi / whenever.sh
Last active August 22, 2024 16:26
A simple shell script that uses inotify in Linux to run shell commands whenever files matching a pattern are changed.
#!/bin/sh
#
# Usage: whenever.sh [pattern] [command]
#
# Executes a command whenever files matching the pattern are closed in write
# mode. "{}" in the command is replaced with the matching filename (via xargs).
# Requires inotifywait from inotify-tools.
#
# For example,
@yashgorana
yashgorana / msedge-debloat.reg
Last active August 12, 2024 21:32
Microsoft Edge debloat (using Group Policies)
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Edge]
; edge
"BackgroundModeEnabled"=dword:00000000
"BingAdsSuppression"=dword:00000001
"CryptoWalletEnabled"=dword:00000000
"DiagnosticData"=dword:00000000
"EdgeAssetDeliveryServiceEnabled"=dword:00000000
"EdgeCollectionsEnabled"=dword:00000000
@cbp44
cbp44 / random_windows_hostname.md
Last active July 4, 2024 22:10
Random Windows hostname generator

Random Windows Hostname from Linux Shell

Shell function one-liner to produce a pseudorandom hostname in the style of Windows 7, Windows 8 and Windows 10 e.g. DESKTOP-V1XZZQ3

random_windows_hostname() {
    printf "DESKTOP-$(/usr/bin/tr -dc A-Z0-9 </dev/urandom | /usr/bin/head -c 7)"
}
echo "$(random_windows_hostname)"   # produces DESKTOP-V1XZZQ3
@felipou
felipou / retry.sh
Last active March 26, 2024 16:41
Retry command
#!/bin/bash
#
# Created by Felipe Machado - 2016/02/14
#
# A retry command for bash
# Retries the given command up to MAX_RETRIES, with an interval of SLEEP_TIME
# between each retry. Just put it on your bash_profile and be happy :)
# Usage:
# retry [-s SLEEP_TIME] [-m MAX_RETRIES] COMMAND_WITH_ARGUMENTS
#
@t0phr
t0phr / GetPw.py
Last active May 4, 2023 11:06
Scan script for nzbget.
#!/usr/bin/python2.7
##############################################################################
### NZBGET SCAN SCRIPT ###
#
# Scans filename of incoming NZBs for embedded passwords.
#
##############################################################################
### OPTIONS ###
# The RegEx to match the password in the filename.
#regex=(.*)\{\{(.*)\}\}.nzb
@fago
fago / watch.sh
Created March 17, 2014 20:59
Inotify script to trigger a command on file changes, e.g. rsync
#!/bin/bash
# (c) Wolfgang Ziegler // fago
#
# Inotify script to trigger a command on file changes.
#
# The script triggers the command as soon as a file event occurs. Events
# occurring during command execution are aggregated and trigger a single command
# execution only.
#
# Usage example: Trigger rsync for synchronizing file changes.
@marcoagner
marcoagner / kill_process.py
Last active May 11, 2022 20:11
Python script to kill a process by its name
import os, signal
def check_kill_process(pstring):
for line in os.popen("ps ax | grep " + pstring + " | grep -v grep"):
fields = line.split()
pid = fields[0]
os.kill(int(pid), signal.SIGKILL)
@lazabogdan
lazabogdan / SassMeister-input.scss
Last active August 14, 2020 18:10
Sass spacing utility
// ----
// libsass (v3.3.2)
// ----
$spacer: 1rem;
$spacer-x: $spacer;
$spacer-y: $spacer;
$spacers: ();