Skip to content

Instantly share code, notes, and snippets.

Avatar

James JamesTheAwesomeDude

View GitHub Profile
@JamesTheAwesomeDude
JamesTheAwesomeDude / gamertag_to_uuid.sh
Last active Jan 13, 2021
Completely self-contained bash+curl+sed script to convert Xbox Live Gamertags into Minecraft pseudo-UUIDs for use with Floodgate-enabled servers
View gamertag_to_uuid.sh
#!/bin/bash
set -e
set -o pipefail
# https://github.com/OpenXbox/xbox-webapi-python/blob/v2.0.10/xbox/webapi/authentication/manager.py#L43-L58
printf 'Click this:\n\t%s\n' "https://login.live.com/oauth20_authorize.srf?response_type=code&client_id=${client_id=388ea51c-0b25-4029-aae2-17df49d23905}&approval_prompt=auto&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fauth%2Fcallback&scope=Xboxlive.signin+Xboxlive.offline_access" > /dev/stderr
code=$(printf '%s\n' "HTTP/1.1 200 OK" "Content-Type: text/html" "" "<script>window.close();</script>" | nc -l 8080 | sed -n -e '1 s/^GET .\+code=\([^& ]*\).*$/\1/p')
# https://github.com/OpenXbox/xbox-webapi-python/blob/v2.0.10/xbox/webapi/authentication/manager.py#L83-L114
bearer_token=$(
@JamesTheAwesomeDude
JamesTheAwesomeDude / ishygddt.css
Last active Jan 6, 2021
Some sanity in WordPress styles
View ishygddt.css
a {
/* bruh why does Suki nerf this" */
text-decoration: underline;
}
.entry-content p>code[class^='language-'], p>code[class*=' language-'] {
/* https://wordpress.stackexchange.com/q/380863/52811" */
white-space: nowrap;
}
View modfl.py
import fcntl
def modfl(fd, flags):
'''Adds all given positive flags to, and removes all given negative flags from, the given file descriptor'''
# e.g.: modfl(f, (+os.O_SYNC, -os.O_NONBLOCK))
# would make f synchronous and blocking
#OR-in positive flags; NAND-out negative ones
ins = lambda fl, x: (fl | x) if x >= 0 else (fl &~ -x)
# 1. Get the current flag field
@JamesTheAwesomeDude
JamesTheAwesomeDude / zendd.py
Last active Jan 3, 2021
Zenity-based GNU dd GUI (Py2&Py3 wrapper)
View zendd.py
#!/usr/bin/env python
from __future__ import division
import sys, os, stat, fcntl, subprocess, select, re
from functools import reduce
#TODO: rewrite this whole program as a sub-512-byte Perl script
def main(args=sys.argv[1:]):
dcmd = ['dd'] + args + ['status=progress']
@JamesTheAwesomeDude
JamesTheAwesomeDude / 6653.py
Last active Nov 4, 2020
Histogram: 2020 Electoral College victory-margin odds
View 6653.py
#!/usr/bin/env python3
import json,re,math,sys
import statistics
import matplotlib.pyplot as plt
# python3 6653.py < 6653.json
#or
# curl https://www.predictit.org/api/marketdata/markets/6653 | python3 6653.py
data = json.load(sys.stdin)
View location.html
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>GPS Trace 0.3</title>
<script src="http://www.ishygddt.xyz/~james/openlocationcode.min.js"></script>
<script src="http://www.ishygddt.xyz/~james/distVincenty.js"></script>
<script>
const softwareVersionString="My Apologies 20200805 - https://www.github.com/JamesTheAwesomeDude"
@JamesTheAwesomeDude
JamesTheAwesomeDude / restorecon-xtables-lock.service
Last active Jul 31, 2020
Fix for RHEL Bugs #1436904 #1376343
View restorecon-xtables-lock.service
# /etc/systemd/system/restorecon-xtables-lock.service
# Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1436904#c3
# HOWEVER, IF YOU ARE READING THIS, you probably need to be
# configuring the McAfee Firewall *instead of* interacting with iptables yourself:
# https://docs.mcafee.com/bundle/endpoint-security-10.6.6-firewall-product-guide-linux/page/GUID-481C8EE3-A371-4D86-8BF4-BB5C18B8C7F9.html
# Example:
# /opt/McAfee/ens/fw/bin/mfefwcli --fw-rule-add --name ALLOW_OUTBOUND --action allow --direction out --notes "unblock everything lolol"
[Unit]
@JamesTheAwesomeDude
JamesTheAwesomeDude / python3
Created Jul 20, 2020
RHSCL python3 integration
View python3
#!/bin/sh
# ~/.local/bin/python3
exec scl enable rh-python36 -- python3 "$@"
@JamesTheAwesomeDude
JamesTheAwesomeDude / ncACMEutil.sh
Last active May 6, 2020
Namecheap cron script to "automatically" renew Let's Encrypt / ACME-compatible certs
View ncACMEutil.sh
#!/bin/sh
# cd ~/ssl;ln -vs csrs/*.csr www.csr
#cron: 0 0 1 * * "${HOME}/ssl/ncACMEutil.sh" renew www.csr
#CONFIG
cpanellogin=1234567#get this from the "Products" page
cd "${HOME}/ssl"
account_key="lec.key"
account_contact="mailto:webmaster@example.org"
webroot="${HOME}/public_html"#TODO: support different webroots per-domain
@JamesTheAwesomeDude
JamesTheAwesomeDude / minecraft@.service
Last active Jan 8, 2021
systemd user-unit file for Minecraft server
View minecraft@.service
# ~/.config/systemd/user/minecraft@.service
# loginctl enable-linger "${USER}"
# systemctl --user daemon-reload
# systemctl --user enable minecraft@-srv-minecraft-survival.service
# ln -svf ../jars/paper-1.16.1_101.jar /srv/minecraft/survival/server.jar
# systemctl --user start minecraft@-srv-minecraft-survival.service
[Unit]
Description=Minecraft Server (%I)