Skip to content

Instantly share code, notes, and snippets.

View JamesTheAwesomeDude's full-sized avatar

James E. A. JamesTheAwesomeDude

View GitHub Profile
import csv
CSVFILE='2018H1.csv'# TL:DR:
#Spending money:
# -,Personal.Recreation.Social,28.37
# -,Groceries,45.32
#Getting money:
# +,Income.Job,420.69
#Being subsidized:
rotr = lambda v,n=1,s=8: ((v>>n)|(v<<(s-n)))&~(~0<<s)
rotl = lambda v,n=1,s=8: ((v<<n)|(v>>(s-n)))&~(~0<<s)
#rot*(number, number_of_bits_to_shift, size_of_number)
assert rotr(0b11110011,3) \
== 0b01111110
assert rotl(0xDEADBEEF,20,32) \
== 0xEEFDEADB
@JamesTheAwesomeDude
JamesTheAwesomeDude / app.ini
Created September 18, 2018 03:35
Gitea RST support
; append this FRAGMENT to gitea/custom/conf/app.ini
; NOTE: you must first run apt install python3-pip
; and python3 -m pip install docutils
; (if the latter is NOT run as root, be sure that ~/.local/bin is in PATH)
[markup.restructuredtext]
ENABLED = true
FILE_EXTENSIONS = .rst
RENDER_COMMAND = rst2html.py
IS_INPUT_FILE = false
@JamesTheAwesomeDude
JamesTheAwesomeDude / rst2msword.bat
Last active September 16, 2019 13:23
Open ReStructuredText in Microsoft Word
SET pythonfolder=%LocalAppData%\Programs\Python\Python37
SET rst2odt="%pythonfolder%\Scripts\rst2odt.py"
SET msword="C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE" /t
SET flags=--strip-comments --report=none
%rst2odt% %flags% %1 "%~dpn1.odt"
REM TODO stackoverflow.com/q/13402898
REM TODO stackoverflow.com/a/22194521
start "" %msword% "%~dpn1.odt"
@JamesTheAwesomeDude
JamesTheAwesomeDude / golf-location-parameters.js
Last active December 12, 2019 23:17
One-statement parsing location.parameters
decodeURIParam=p=>//<223 bytes w/o whitespace and comments
Object.assign(//Create a new object,
...//the union of the following objects:
p//location.parameters
.match(/^\??(.*)$/)//has a leading '?'
[1]//(which we don't want)
.split('&')//split the rest into '&'-delimited chunks,
.filter(S=>S)//remove null chunks (from duplicate or trailing ampersands)
.map(S=>S//take each chunk
.match(/^([^=]*)=?(.*)$/))//and split it via key=value
@JamesTheAwesomeDude
JamesTheAwesomeDude / cgi-bin_v0.cgi
Last active February 23, 2020 10:49
banned halfbrick prototype
#!/bin/sh
cd "$(dirname "${0}")/.."
case "${REQUEST_METHOD}" in
GET)
printf 'Status: %s\r\n' "200 OK"
printf 'Content-Type: %s\r\n' "application/json"
printf '\r\n'
exec cat "X.v0.json"
@JamesTheAwesomeDude
JamesTheAwesomeDude / 99-Arduino.rules
Last active April 7, 2020 03:45
necessary/skeletal Arduino "sketch" files
# /etc/udev/rules.d/99-arduino.rules
SUBSYSTEM=="tty", ATTRS{manufacturer}=="*Arduino*", GROUP="james"
@JamesTheAwesomeDude
JamesTheAwesomeDude / ncACMEutil.sh
Last active May 6, 2020 18:45
Namecheap cron script to "automatically" renew Let's Encrypt / ACME-compatible certs
#!/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 / python3
Created July 20, 2020 05:06
RHSCL python3 integration
#!/bin/sh
# ~/.local/bin/python3
exec scl enable rh-python36 -- python3 "$@"
<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"