Skip to content

Instantly share code, notes, and snippets.

@KuJoe
KuJoe / gist:445bca3099395bf2011db3151e7531d7
Created August 27, 2019 05:49
Find and set CPU priority
PID=`ps -ef | grep "PROCESSNAME" | grep -v "grep" | awk '{print $2}'`
for i in $PID; do sleep 1;
sudo /usr/bin/renice +10 $i;
done
<?php
# Quick and dirty script to check and notify me when a Twitch channel gets Affiliate status.
# https://github.com/KuJoe
$lockfile = '/DIR/TO/FILE.LOCK';
if (file_exists($lockfile)) {
exit;
} else {
@KuJoe
KuJoe / all_links.php
Last active January 8, 2021 15:34
UserSpice pagination not working example
WEB_SYSTEM='apache2'
WEB_RGROUPS='www-data'
WEB_PORT='8080'
WEB_SSL_PORT='8443'
WEB_SSL='mod_ssl'
PROXY_SYSTEM='nginx'
PROXY_PORT='80'
PROXY_SSL_PORT='443'
STATS_SYSTEM='awstats'
WEB_BACKEND='php-fpm'
@KuJoe
KuJoe / gist:0689259465d69c8c1ecc54a8f1f92520
Created July 2, 2021 15:51
LuckPerm error starting Minecraft server
[11:43:38] [Server thread/ERROR]: Could not load 'plugins/LuckPerms-Bukkit-5.3.48.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: me.lucko.luckperms.common.loader.LoadingException: Unable to create a temporary file
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:157) ~[patched_1.17.jar:git-Paper-69]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:414) ~[patched_1.17.jar:git-Paper-69]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:322) ~[patched_1.17.jar:git-Paper-69]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.loadPlugins(CraftServer.java:393) ~[patched_1.17.jar:git-Paper-69]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:275) ~[patched_1.17.jar:git-Paper-69]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1118) ~[patched_1.17.jar:git-Paper-69]
at net.minecraft.server.MinecraftServer.lambd
@KuJoe
KuJoe / gist:b8d422ee4272b78ec68a3868e5e6fb9c
Created April 20, 2022 10:40
Simple bash script to create a list of TOR exit node IPs and format to deny them in nginx
#!/bin/bash
/usr/bin/wget -q -O - "https://www.dan.me.uk/torlist/?exit" -U SXTorBlocker/1.0 > /tmp/temp_tor_list
/usr/bin/wget -q -O - "https://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=$IP_ADDRESS&port=80" -U NoSuchBrowser/1.0 >> /tmp/temp_tor_list
/usr/bin/wget -q -O - "https://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=$IP_ADDRESS&port=9998" -U NoSuchBrowser/1.0 >> /tmp/temp_tor_list
/usr/bin/cat /tmp/temp_tor_list | grep -v ":" | grep -v "#" > /tmp/torlist
/usr/bin/sort -u /tmp/torlist > /tmp/nginxtorlist
/usr/bin/sed "s/^/deny /g; s/$/;/g" /tmp/nginxtorlist > /etc/nginx/block-tor.txt
/usr/bin/systemctl reload nginx
@KuJoe
KuJoe / script.js
Created May 30, 2022 02:52
Javascript image upload function
function ajax_file_upload(file_obj) {
if(file_obj != undefined) {
$("h2").text("Starting upload...");
var form_data = new FormData();
for(i=0; i<file_obj.length; i++) {
if (!isImage(file_obj[i].name)) {
return failValidation("ext");
}
if (!validateSize(file_obj[i].size)) {
return failValidation("size");
@KuJoe
KuJoe / multi_robocopy.ps1
Created July 14, 2022 01:16
Multi-process RoboCopy Powershell script
###
#
# This script runs robocopy jobs in parallel by increasing the number of outstanding i/o's to the copy process. Even though you can
# change the number of threads using the "/mt:#" parameter, your backups will run faster by adding two or more jobs to your
# original set.
#
# To do this, you need to subdivide the work into directories. That is, each job will recurse the directory until completed.
# The ideal case is to have 100's of directories as the root of the backup. Simply change $src to get
# the list of folders to backup and the list is used to feed $ScriptBlock.
#
@KuJoe
KuJoe / gist:7d160aae3879077b1dacae8e03c897bc
Created January 3, 2023 19:19
nginx + Cloudflare script
#!/bin/bash
CLOUDFLARE_FILE_PATH=${1:-/etc/nginx/conf.d/cloudflare.conf}
echo "#Cloudflare" > $CLOUDFLARE_FILE_PATH;
echo "" >> $CLOUDFLARE_FILE_PATH;
echo "# - IPv4" >> $CLOUDFLARE_FILE_PATH;
for i in `curl -s -L https://www.cloudflare.com/ips-v4`; do
echo "set_real_ip_from $i;" >> $CLOUDFLARE_FILE_PATH;
@KuJoe
KuJoe / domain.conf
Created January 12, 2023 14:33
nginx reverse proxy config
server {
server_name example.com;
access_log off;
error_log off;
location / {
proxy_pass http://my.synology.ddns
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;