This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def json_to_qml_model(json_array: list, filename: str): | |
with open(filename, "w", encoding="utf-8") as topic_model_file: | |
topic_model_file.write("""import QtQuick 2.0\n | |
ListModel {\n""") | |
for obj in json_array: | |
topic_model_file.write(" ListElement {\n") | |
[topic_model_file.write(f""" {key}: {repr(value)}\n""") | |
for key, value in obj.items()] | |
topic_model_file.write(" }\n") | |
topic_model_file.write("}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION url_encode(data bytea) RETURNS text LANGUAGE sql AS $$ | |
SELECT translate(encode(data, 'base64'), E'+/=\n', '-_'); | |
$$ IMMUTABLE; | |
CREATE OR REPLACE FUNCTION url_decode(data text) RETURNS bytea LANGUAGE sql AS $$ | |
WITH t AS (SELECT translate(data, '-_', '+/') AS trans), | |
rem AS (SELECT length(t.trans) % 4 AS remainder FROM t) -- compute padding size | |
SELECT decode( | |
t.trans || |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
devices: ( | |
{ | |
name: "MX Master 3S"; | |
smartshift: | |
{ | |
on: true; | |
threshold: 30; | |
torque: 50; | |
}; |