Skip to content

Instantly share code, notes, and snippets.

@cardinal9999
cardinal9999 / Tab Close Detect.html
Created November 11, 2021 20:25
A bookmarklet to warn the user if they try to close a tab in the browser.
<p>Tab Close Detect</p><br/>
<a href="javascript:document.addEventListener(&quot;DOMContentLoaded&quot;,function(){document.body.focus()},!1),window.addEventListener(&quot;beforeunload&quot;,function(e){e.preventDefault(),e.returnValue=&quot;&quot;});">Activate Tab Close Detect</a>
@cardinal9999
cardinal9999 / RSA-js.js
Created September 2, 2021 16:07
A CryptoQuail mini-package to encrypt with RSA in JavaScript.
export function generate_d(p, q, e) {
var J = (p-1) * (q-1);
var a = 0;
while (e * a) % J != 1{
a++;}
return a}
export function encrypt(m, n, e){
return Math.pow(m, e) % n}
export function decrypt(c, d, n){
return Math.pow(c, d) % n}
@cardinal9999
cardinal9999 / typo-generator.py
Last active December 4, 2022 00:49
Generate a list of typos with this simple brute-forcing tool.
data = {
"a": "qzs",
"b": "nv",
"c": "xv",
"d": "fs",
"e": "wrd3",
"f": "dgrc",
"h": "gj",
"i": "uo",
"m": "n",
@cardinal9999
cardinal9999 / anomaly-cleaner
Last active October 3, 2021 01:24
Remove outliers from any dataset.
def clean_anomalies(list_, strictness):
cleaned = []
c = sum(list_) / len(list_)
s = strictness / 100
d = c / s
for i in list_:
if not abs(i) > abs(d) + abs(c):
cleaned.append(i)
return cleaned