Signatures of functions, methods and class constructors can be given like they would be written in Python.
import serial | |
from serial.tools import miniterm | |
import subprocess, sys, re, os | |
class ESPMiniterm(miniterm.Miniterm): | |
def handle_menu_key(self, c): | |
if c == '\x15': # ctrl-u | |
self.upload_file() | |
else: | |
super(ESPMiniterm, self).handle_menu_key(c) |
""" | |
Given a dictionary, transform it to a string. Then byte encode that string. Then base64 encode it and since this will go | |
on a url, use the urlsafe version. Then decode the byte string so that it can be else where. | |
""" | |
data = base64.urlsafe_b64encode(json.dumps({'a': 123}).encode()).decode() | |
# And the decode is just as simple... | |
data = json.loads(base64.urlsafe_b64decode(query_param.encode()).decode()) | |
# Byte encode the string, base64 decode that, then byte decode, finally transform it to a dictionary |
In some cases, it is possible that PostgreSQL tables get corrupted. This can happen in case of hardware failures (e.g. hard disk drives with write-back cache enabled, RAID controllers with faulty/worn out battery backup, etc.), as clearly reported in this wiki page. Furthermore, it can happen in case of incorrect setup, as well.
One of the symptoms of such corruptions is the following message:
ERROR: missing chunk number 0 for toast value 123456 in pg_toast_45678
This almost surely indicates that a corrupted chunk is present within a table file. But there is a good way to get rid of it.
// Tracking cursor position in real-time without JavaScript | |
// Demo: https://twitter.com/davywtf/status/1124146339259002881 | |
package main | |
import ( | |
"fmt" | |
"net/http" | |
"strings" | |
) |
If you are using APFS Case Sensitive File system and trying to use Steam, it will flicker & silently fail or show the following error message:
steam requires that '~/library/application support/steam/steam.appbundle/steam/contents/macos' be on a case-insensitive filesystem.
To fix the issue, follow the instruction here.