Skip to content

Instantly share code, notes, and snippets.

Dungeon: Sastasha
Dungeon: Tam-Tara Deepcroft
Dungeon: Copperbell Mines
Trial: Ifrit
Dungeon: Thousand Maws of Toto-Rak
Dungeon: Haukke Manor
Dungeon: Brayflox's Longstop
Trial: Titan
Dungeon: Stone Vigil
Trial: Garuda
@sonnyksimon
sonnyksimon / chunker.py
Created September 30, 2024 15:26
Chunking combinations and simple lists
#!/usr/bin/env python
class SimpleChunker:
"""For chunking simple lists"""
def __init__(self, size, chunksize):
self.size = size
self.chunksize = chunksize
self.chunk = 0
self.total = size
@sonnyksimon
sonnyksimon / firstDayOfMonth.jq
Last active May 30, 2024 12:53
example input: "2024-01-01"
(strptime("%Y-%m-%d") | mktime | strftime("%Y-%m-01") | strptime("%Y-%m-%d") | mktime | todate)
@sonnyksimon
sonnyksimon / _string-similarity.txt
Last active February 23, 2024 04:18
string similarity
Can we implement all of these algorithms?
Similarity Algorithms:
- Cosine
- Fuzzy Wuzzy
- Jaccard
- Jaro
- Jaro Winkler
- Q-gram
- Sørensen DIce
@sonnyksimon
sonnyksimon / yaml2json
Created October 1, 2023 07:26
yaml2json: Compact script for yaml to json conversion
#!/usr/bin/env python
"""yaml2json: Compact script for yaml to json conversion"""
import yaml
import json
import sys
args = [open(x,'r') for x in sys.argv[1:]]
args = [sys.stdin.read(), *args] if not sys.stdin.isatty() else args
files = [yaml.safe_load(y) for y in args]
#!/usr/bin/sh
# yaml2json
cat myFile.yml | python -c 'import yaml; import json; import sys; f = sys.stdin.read(); conf = yaml.safe_load(f); out = json.dumps(conf, separators=(",",":")); print(out)'
@sonnyksimon
sonnyksimon / parseCSV.jq
Created September 7, 2022 19:03
jq --slurp --raw-input
split("\n")
| (
.[0]
| split(",")
) as $head
| .[1:]
| map
(
split(",")
| to_entries
@sonnyksimon
sonnyksimon / google-spending.js
Created August 29, 2022 03:31
Calculate Google Spending from Chrome Console
// Google Activity URL: https://pay.google.com/gp/w/u/0/home/activity
// add the id `x-payments-hist` to the tbody
// containing the payments after viewing
// all records (i.e. it says "No more transactions")
let payments = [];
let rows = document.querySelectorAll("#x-payments-hist > tr");
rows.forEach(function(node) {
let r = {};
@sonnyksimon
sonnyksimon / applyjq.py
Last active June 20, 2022 16:39
Python JQ in windows
import subprocess
import json
def applyjqtxt(filter, text):
echo = subprocess.Popen(('echo', text), stdout=subprocess.PIPE)
output = subprocess.check_output(('jq', filter), stdin=echo.stdout)
echo.wait()
return output
def applyjq(filter, data):
@sonnyksimon
sonnyksimon / isNotANumber.js
Created January 13, 2021 19:02
js isNotANumber
const isNotANumber = (v) => {
const n = Number(v);
return n !== n;
}
export default isNotANumber;