Skip to content

Instantly share code, notes, and snippets.

@Zetaphor
Zetaphor / markov_chain.py
Created February 17, 2024 07:11
ChatGPT authored Markov Chain in Python
"""
Read a collection of JSON files from a directory as the inputs to a Markov Chain.
Also adds the user inputs to the dictionary as the conversation progresses.
Assumes it's using the formatted data from the NeoLLaMder project.
Written by ChatGPT
"""
import json
import random
import re
@Zetaphor
Zetaphor / docker-selenium.sh
Last active November 15, 2023 03:05
Music download automation
docker pull selenium/standalone-chrome
docker run -d -p 4444:4444 --shm-size=2g selenium/standalone-chrome
@Zetaphor
Zetaphor / keychron_linux.md
Created July 11, 2022 21:31 — forked from andrebrait/keychron_linux.md
Keychron keyboards on Linux + Bluetooth fixes

Here is the best setup (I think so :D) for K-series Keychron keyboards on Linux.

Most of these commands have been tested on Ubuntu 20.04 and should also work on most Debian-based distributions. If a command happens not to work for you, take a look in the comment section.

Make Fn + F-keys work

Keychron Keyboards on Linux use the hid_apple driver (even in Windows/Android mode), both in Bluetooth and Wired modes. By default, this driver uses the F-keys as multimedia shortcuts and you have to press Fn + the key to get the usual F1 through F12 keys.

@Zetaphor
Zetaphor / bash-sensors.sh
Last active October 29, 2021 21:21
Bash Sensors
echo 🌡 AMD: `sensors | grep 'edge:' | cut -c 16-18 | rev | cut -c 2-100 | rev`°C
echo 🌡 NVIDIA: `nvidia-smi -q -d temperature | grep 'GPU Current Temp' | cut -c 45-47 | xargs`°C
echo 🌡 2TB: `sensors | grep 'Composite:' | sed -n '1p' | cut -c 16-18 | rev | cut -c 2-10 | rev`°C
echo 🌡 1TB: `sensors | grep 'Composite:' | sed -n '2p' | cut -c 16-18 | rev | cut -c 2-10 | rev`°C
echo ⌬ CPU: `top -bn1 | sed -n '/Cpu/p' | awk '{print $2}' `%
echo ⌧ RAM `free -m | awk 'NR==2{printf "%.2fGB (%.2f%%)\n", $3/1024,$3*100/$2 }'`
echo 🌡 CPU `cat /sys/class/thermal/thermal_zone0/temp | sed 's/.\{3\}$/.&/' | rev | cut -c 5-10 | rev`°C
echo ֎ FAN: `sensors | grep cpu_fan | cut -c 17-100 | rev | cut -c 5-100 | rev | xargs`RPM
@Zetaphor
Zetaphor / test.json
Last active September 22, 2021 23:22
{
"MRData": {
"xmlns": "http:\/\/ergast.com\/mrd\/1.4",
"series": "f1",
"url": "http://ergast.com/api/f1/2018/circuits.json",
"limit": "30",
"offset": "0",
"total": "21",
"CircuitTable": {
"season": "2018",
@Zetaphor
Zetaphor / airdots.sh
Created October 16, 2019 19:42
Automatically reconnect bluetooth headphones
#!/bin/bash
##### CONFIGURATION #####
MAC="E8:EC:A3:30:0C:62"
MODE="connect"
#########################
STATUS=$(bluetoothctl info $MAC | grep "Connected" | awk '{print $2}')
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "ctrl+\\",
"command": "workbench.action.toggleSidebarVisibility"
},
{
"key": "ctrl+b",
"command": "-workbench.action.toggleSidebarVisibility"
},
@Zetaphor
Zetaphor / pre-commit
Created May 1, 2018 16:48 — forked from hraban/pre-commit.md
Git pre-commit hook (.git/hooks/pre-commit) to prevent accidentally committing debug code (add NOCOMMIT in source comment)
#!/bin/sh
# This pre-commit hook will prevent you from committing any line (or filename) containing
# the string NOCOMMIT. Use that tag in comments around source code you want to avoid
# accidentally committing, like temporary IP addresses or debug printfs.
#
# To add it to an existing repository, save it to .git/hooks/pre-commit (or append, if
# that file already exists). Remember to make executable (chmod +x ...)
#
# To automatically add this pre-commit hook to every repository you create or clone:
@Zetaphor
Zetaphor / random-string.js
Created April 30, 2018 17:39
Javascript Random String
Math.random().toString(36).split('0.')[1]
@Zetaphor
Zetaphor / console.debugMode.js
Created October 27, 2017 15:37
Console.log debugMode mute toggle
let origLog = window.console.log
window.console.debugMode = true
window.console.log = function () {
if (!window.console.debugMode) return
for (let i = 0; i < arguments.length; i++) {
origLog(arguments[i])
}
}
console.log({dsa: 1}, 'dsadsa', 12321)