Skip to content

Instantly share code, notes, and snippets.

@ansrivas
ansrivas / encodings.md
Last active March 17, 2022 21:09
Convert iso-8859-1 to utf-8 in python
# convert iso-8859-1 to unicode to utf-8, where `v` is the string in `iso-8859-1` format
v.decode("iso-8859-1").encode("utf-8")

And as a note, this is also some basic rule:

If you have no way of finding out the correct encoding of the file, then try the following encodings, in this order:

utf-8
iso-8859-1 (also known as latin-1)
@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active May 12, 2025 13:07
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@mbursa
mbursa / kem-decryptor.py
Last active January 28, 2025 13:04
Python script to decrypt Kamstrup KEM files
# A Python script that decrypts the content of Kamstrup KEM file and imports meter files
# to wmbusmeters' config folder.
#
# The KEM file is a (sometimes zipped) xml file that contains xml-encrypted data using
# the xml-enc standard (http://www.w3.org/2001/04/xmlenc). The password needed to decrypt
# the xml-encrypted data can either be the CustomerId or something else selected by the
# person that has created the KEM file using Kamstrup software.
#
# This script takes the encrypted KEM file and decrypts its content (it automaticly detects
# the zip archive and extracts the kem file from it). The result is a XML with a list of meters