Skip to content

Instantly share code, notes, and snippets.

@eddy-geek
eddy-geek / necessary-verbs.sh
Created September 18, 2023 23:32
Audio fix for ALC298 in 16T90R-K.ADB9U1, kernel bug 212041 #13
#!/bin/sh
hda-verb /dev/snd/hwC0D0 0x20 0x500 0x0
hda-verb /dev/snd/hwC0D0 0x20 0x500 0x0
hda-verb /dev/snd/hwC0D0 0x20 0x500 0x99
hda-verb /dev/snd/hwC0D0 0x20 0x500 0x99
hda-verb /dev/snd/hwC0D0 0x20 0x500 0x99
hda-verb /dev/snd/hwC0D0 0x20 0x480 0x0
hda-verb /dev/snd/hwC0D0 0x20 0x500 0x99
hda-verb /dev/snd/hwC0D0 0x20 0x480 0x0
hda-verb /dev/snd/hwC0D0 0x20 0x500 0x99
def get_jpg_quality(pim: 'PIL.Image.Image') -> int:
"""
Implement quality computation following ImageMagick heuristic algorithm:
https://github.com/ImageMagick/ImageMagick/blob/7.1.0-57/coders/jpeg.c#L782
Usage:
```
pim = Img.open(...)
quality = get_jpg_quality(pim)
```
See also https://stackoverflow.com/questions/4354543/

Comparing length of json-encoded DataFrame. to_json doc

Conclusions with my sample dataset

  • CSV
    • can be signifantly more compact if your data has lots of nans / strings, since their encoding is empty / not-quoted
    • but index is lost
    • and careful with incompatible quoting if you embed csv in json
  • split is the most compact json encoding that keeps column and index names, use it over columns (default) / record
# Copyright (C) 2022 by Edward O.
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without l> imitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// based on a keyboard map from an 'xkb/symbols/gb' file
default partial alphanumeric_keys
xkb_symbols "basic" {
// Describes the differences between a very simple en_US
// keyboard and a very simple U.K. keyboard layout defined by
// the SVR4 European Language Supplement and sometimes also
// known as the IBM 166 layout.
@eddy-geek
eddy-geek / kttest
Created July 15, 2018 21:08
kodetravel xkb test
partial alphanumeric_keys modifier_keys
xkb_symbols "dev" {
name[group1]= "KodeTravel (kode)";
key.type[group1] = "EIGHT_LEVEL";
key <AD01> { [ q, Q, 0x1007067, 0x10000b6 ] };
key <AD02> { [ w, W, egrave, ediaeresis ] };
key <AD03> { [ e, E, eacute, Greek_epsilon ] };
key <AD04> { [ r, R, ecircumflex, registered ] };
@eddy-geek
eddy-geek / lafayette_install.py
Created May 22, 2018 16:32 — forked from fabi1cazenave/lafayette_install.py
Qwerty-Lafayette installer for XKB
#!/usr/bin/env python3
import os
import shutil # backups...
import textwrap # dedent hard-coded symbol strings
from lxml import etree
from lxml.builder import E
XKB = '/usr/share/X11/xkb/'
NAME = 'lafayette'
LAYOUTS = {'fr': [{
@eddy-geek
eddy-geek / simple_python_datasource.py
Created January 9, 2018 19:26 — forked from linar-jether/simple_python_datasource.py
Grafana python datasource - using pandas for timeseries and table data. inspired by and compatible with the simple json datasource
from flask import Flask, request, jsonify, json, abort
from flask_cors import CORS, cross_origin
import pandas as pd
app = Flask(__name__)
cors = CORS(app)
app.config['CORS_HEADERS'] = 'Content-Type'