Skip to content

Instantly share code, notes, and snippets.

View pank-su's full-sized avatar
:shipit:
Working

Pank Su pank-su

:shipit:
Working
View GitHub Profile
@pank-su
pank-su / json_to_qml_model.py
Last active June 21, 2022 10:26
Simple function, which translate json to qml ListModel file
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("}")
@pank-su
pank-su / pgjwt_without.sql
Created June 29, 2023 12:07
Create pgjwt functions without using extension.
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 ||
@pank-su
pank-su / logid.cfg
Created January 21, 2024 09:03
MX Master 3S config to gnome
devices: (
{
name: "MX Master 3S";
smartshift:
{
on: true;
threshold: 30;
torque: 50;
};