Skip to content

Instantly share code, notes, and snippets.

View animatedlew's full-sized avatar

Lewie [m80] animatedlew

View GitHub Profile
from pathlib import Path
import pickle
import hmac
path = Path(__file__).parent
def run():
secret_key = b"@SECRET@"
data = {'seed': 42}
@animatedlew
animatedlew / updatedns.scpt
Created November 6, 2023 19:07
AppleScript that points DNS settings to Google.
set var to "Do you want to point your DNS to Google servers?"
set question to display dialog var buttons {"Update DNS", "Quit"} giving up after 5
set answer to button returned of question
if answer is "Update DNS" then
do shell script "networksetup -setdnsservers Wi-Fi 8.8.8.8 8.8.4.4" with administrator privileges
delay 3
do shell script "dscacheutil -flushcache" with administrator privileges

When $a \ne 0$, there are two solutions to $(ax^2 + bx + c = 0)$ and they are

$$ x = {-b \pm \sqrt{b^2-4ac} \over 2a} $$

$$ \sum_{i=0}^n{x^{-2} \over DL_i} \times 2^{-\frac{1}{2}} $$

$$ \sqrt[3]{\sum_{i=1}^{\infty}}

function modulus(xs) {
let output = [];
while (true) {
if (xs.length) {
let [a, b] = [xs.shift(), xs.shift()];
if (b > a) output.push(a);
else {
let c = b;
while (true) {
let d = a - c;
function *fibonocci(t) {
let a = 1, b = 0, c = 0;
while(c < t) {
yield c;
c = a + b;
a = b; b = c;
}
}
let output = Array.from(fibonocci(21), n => n * 2);
@animatedlew
animatedlew / spinner.sh
Last active March 24, 2019 22:30 — forked from rpetrich/spinner.sh
Moon loading spinner
#!/bin/bash
while :; do
for c in 🌕 🌖 🌗 🌘 🌑 🌑 🌑 🌒 🌓 🌔 🌕;do
echo -en "\r" "$c"
sleep 0.1
done
done
#!/bin/bash
tput reset
icon=("|" "/" "-" "\\")
for n in {1..100}
do
tput cup 0 0
echo "${icon[n%4]}"
#!/bin/bash
tput reset
for n in {1..100}
do
tput cup 0 0
echo $n
sleep 0.01
done
#!/bin/bash -e
usage() { echo "tarch file"; }
if [[ -z $1 ]]; then usage; exit 1; fi
total=$(tar cf - "$1" | wc -c)
gzip=$(tar czf - "$1" | wc -c)
bzip2=$(tar cjf - "$1" | wc -c)
gzip_goal=$(echo "scale=2; ${gzip} / ${total} * 100" | bc)
function perm1(input /* string */) {
if (!input.length) return [input];
let results = input.split('').reduce((results, c) => {
let tail = input.split(c).join('');
return results.concat(perm1(tail).map(p => c + p));
}, []);
return results;
}