Skip to content

Instantly share code, notes, and snippets.

@devdave
devdave / printout.py
Created April 7, 2023 16:14
print portal names for valheim
View printout.py
"""
1. Download & install Python, be sure to click option for it to be added to the system Path
2. Save this to Desktop or somewhere/anywhere
3. Find the file path to your valheim world db file.
4. Put the file path in between the quotes on line 23 / test_file
5. Using the command line, run `python printout.py`
"""
def portals(dbfile):
with open(dbfile, 'rb') as db:
@devdave
devdave / main.reds
Created March 8, 2023 14:58
Updated broken/cheat breach mini game for Cyberpunk 2077
View main.reds
//Breach protocol simplifier
//Copy to r6/scripts/breach/ make sure to create "breach" directory if it doesn't exist
// 1.6 compat
@replaceMethod(MinigameGenerationRuleScalingPrograms)
protected func OnProcessRule(out size: Uint32, out grid: array<array<GridCell>>) -> Bool {
let atStart: Bool;
let combinedPowerLevel: Float;
let extraDifficulty: Float;
let i: Int32;
@devdave
devdave / valheimdb_snippet.py
Created February 4, 2023 21:46
A short snippet to seek through a valheim db file and retrieve a lit of portals
View valheimdb_snippet.py
# sourced from https://www.reddit.com/r/valheim/comments/lixlu7/any_way_to_look_up_the_name_of_a_portal_you_forgot/iibfmuo/
import mmap
def portals(dbfile):
db = open(dbfile, 'rb')
mm = mmap.mmap(db.fileno(), 0, prot=mmap.PROT_READ)
i, l = 0, set()
while True:
@devdave
devdave / contractions.py
Created December 1, 2022 21:44 — forked from nealrs/contractions.py
Expand common (and some very uncommon) english contractions
View contractions.py
"""
this code is not mine! i shamelessly copied it from http://stackoverflow.com/questions/19790188/expanding-english-language-contractions-in-python
all credits go to alko and arturomp @ stack overflow.
basically, it's a big find/replace.
"""
import re
cList = {
"ain't": "am not",
@devdave
devdave / counter.py
Created December 1, 2022 18:42
simple script to summarize the contents of a directory of docx files
View counter.py
from pathlib import Path
from collections import Counter
from docx import Document # pip install python-docx
from nltk.tokenize import sent_tokenize, word_tokenize # pip install nltk==3.5
ROOT = Path(r"C:\\REDACTED\\book\\")
@devdave
devdave / python-people.md
Created November 15, 2022 16:14 — forked from samuelcolvin/python-people.md
An incomplete list of people in the Python community to follow on Twitter and Mastodon.
View python-people.md

Python People

An incomplete list of people in the Python community to follow on Twitter and Mastodon.

With the risk that Twitter dies, I'd be sad to lose links to interesting people in the community, hence this list.

I would love you to comment below with links to people I've missed.

More context and comments at the end of the list.

@devdave
devdave / Speech Recognition.ahk
Created June 30, 2022 16:34 — forked from Uberi/Speech Recognition.ahk
Speech recognition with Microsoft's SAPI. A simple SpeechRecognizer class provides a quick and easy way to use speech recognition in your scripts. Inspired by some [prototype code](http://www.autohotkey.com/board/topic/24490-voice-recognition-com/) made a long time ago.
View Speech Recognition.ahk
#NoEnv
#Warn All
#Warn LocalSameAsGlobal, Off
#Persistent
/*
Speech Recognition
==================
A class providing access to Microsoft's SAPI. Requires the SAPI SDK.
@devdave
devdave / Concepts.md
Created May 29, 2022 19:30 — forked from DarinM223/Concepts.md
Rust concept explanations
View Concepts.md

My explanation of the main concepts in Rust

There are three main concepts with Rust:

  1. Ownership (only one variable "owns" the data at one time, and the owner is in charge of deallocating)
  2. Borrowing (you can borrow a reference to an owned variable)
  3. Lifetimes (all data keeps track of when it will be destroyed)

These are fairly simple concepts, but they are often counter-intuitive to concepts in other languages, so I wanted to give a shot at

@devdave
devdave / nde_winamp_format.txt
Created April 22, 2022 19:07
Winamp media library NDE (Nullsoft Database Engine) format
View nde_winamp_format.txt
Nullsoft Database Engine Format Specifications v1.0
---------------------------------------------------
1. Tables
@devdave
devdave / gist:86caf21b18e2a9c35ad451bf4e3ff762
Created September 4, 2021 03:44 — forked from hest/gist:8798884
Fast SQLAlchemy counting (avoid query.count() subquery)
View gist:86caf21b18e2a9c35ad451bf4e3ff762
def get_count(q):
count_q = q.statement.with_only_columns([func.count()]).order_by(None)
count = q.session.execute(count_q).scalar()
return count
q = session.query(TestModel).filter(...).order_by(...)
# Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ...
print q.count()