Skip to content

Instantly share code, notes, and snippets.

View pocc's full-sized avatar
🏠
Working from home

Ross Jacobs pocc

🏠
Working from home
View GitHub Profile
@pocc
pocc / test_alert.js
Created December 28, 2021 00:19
Check whether javascript can be run
console.log('working')
alert('working')
@pocc
pocc / time_systems.js
Created December 23, 2021 00:50
Show alternative timesystems for the day
function uint6ToB64 (nUint6) {
// Taken from https://developer.mozilla.org/en-US/docs/Glossary/Base64
return nUint6 < 26 ?
nUint6 + 65
: nUint6 < 52 ?
nUint6 + 71
: nUint6 < 62 ?
nUint6 - 4
: nUint6 === 62 ?
43
@pocc
pocc / .editorconfig
Created November 26, 2021 22:41
My editorconfig (cross-platform, cross-application editor config file)
; This file helps unify code style.
;
; Plugins are available for
; notepad++, emacs, vim, gedit,
; textmate, visual studio, and more.
;
; See http://editorconfig.org for details.
# top-most EditorConfig file
root = true
@pocc
pocc / chess-elo.py
Created November 26, 2021 22:33
Python math to help me understand Chess ELO
# Using this article as a basis: https://metinmediamath.wordpress.com/2013/11/27/how-to-calculate-the-elo-rating-including-example/
print("Scenario: If you are a ELO 2000 player, why can't you play against an ELO 400 player enough times that you get infnite ELO?\n")
r1 = 2000
r2 = 400
R1 = 10**(r1/r2) # 10^(2400/400) = 100,000
R2 = 10**(r2/r1) # 10^(800/400) = 10
@pocc
pocc / verify_suffixes.py
Created October 2, 2021 18:55
A way to find CcSLD's that are also valid websites
# This script will check whether listed tlds will resolve to an IP address
import re
import requests
import socket
PUBLIC_SUFFIX_URL = 'https://publicsuffix.org/list/public_suffix_list.dat'
resp = requests.get(PUBLIC_SUFFIX_URL)
resptext = resp.text
# Remove comments and double new lines
@pocc
pocc / bump.sh
Created October 4, 2020 16:59
Increment patch in a git project and increment version in the package.json of node project
# Auto increment Z of X.Y.Z if a new pull request is merged
LATEST_TAG=$(git describe --abbrev=0)
INITIAL_TAG=$LATEST_TAG
for i in $(git log $LATEST_TAG..HEAD --format="%cI %H" | sort -rV | grep "Merge pull request" | awk '{ print $2 }'); do
NEXT_TAG=$(echo $LATEST_TAG | awk -F. -v OFS=. '{$NF++;print}')
BODY_ABBREV="$(git show $i --format=%b | head -n1)"
git tag -a "$NEXT_TAG" -m "Tag for $BODY_ABBREV" $i
printf "Tagging commit $i with $NEXT_TAG and pushing to master\n"
git push origin "$NEXT_TAG"
LATEST_TAG=$NEXT_TAG
@pocc
pocc / permanently_delete_all.js
Last active December 29, 2023 03:41
Bookmarklet to permanently delete all notion pages that have already been deleted.
javascript:(function(){
// Author: Ross Jacobs
// Purpose: Use as a browser bookmarklet to bulk delete notion pages in trash
// License: Apache 2.0
async function getSpaceId() {
resp = await fetch("https://www.notion.so/api/v3/loadUserContent", {"credentials":"include","headers":{"accept":"*/*","cache-control":"no-cache","content-type":"application/json","pragma":"no-cache","sec-fetch-mode":"cors","sec-fetch-site":"same-origin"},"referrerPolicy":"same-origin","body":"{}","method":"POST","mode":"cors"});
json = await resp.json();
spaceId = Object.keys(json.recordMap.space)[0];
return spaceId;
}
@pocc
pocc / moving_bitmask.py
Last active January 22, 2020 05:51
Move a text shark across a * field
"""
This script moves a shark across a terminal screen. A toy example is shown below, with the same mechanism.
ABCDE
FGHIJ
KLMNO
PQRST
Only show a bit mask consisting of 3x2 chars like
@pocc
pocc / tshark_loss.sh
Last active January 12, 2020 00:13
Demonstrates that tshark will consistently lose some percentage of packets. Change sleep number as suits your needs.
#!/usr/bin/env bash
# Ross Jacobs 2020 Apache2
# Demonstrates that tshark will consistently lose some percentage of packets.
# Change sleep number as suits your needs.
#
# See also https://www.networkcomputing.com/networking/wireshark-packet-capture-tshark-vs-dumpcap
cd /tmp
tshark -q -w tshark.pcap & tshark_pid=$!
dumpcap -q -w dumpcap.pcap & dumpcap_pid=$!
@pocc
pocc / native_example.py
Created December 9, 2019 21:51
Chromium native messaging example, but using python 3 instead of 2
#!/usr/bin/env python3
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Modified to work with python3 by Ross Jacobs
# A simple native messaging host. Shows a Tkinter dialog with incoming messages
# that also allows to send message back to the webapp.
try:
import struct
import sys