Skip to content

Instantly share code, notes, and snippets.

View henfiber's full-sized avatar

Ilias Ktn henfiber

View GitHub Profile
"""
This is based on https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm,
with the requirement that the maximum norm is used for distance calculations.
The algorithm is as follows, described for R^2, but it is easily extensible to
arbitrary dimensions >2:
- given points p_1, ..., p_n, we start by constructing our funnel
by calculating
dp_1 = (p_2 - p_1)
x_1_top = (dp_1_y + epsilon) / dp_1_x
@SimeonC
SimeonC / i18nextLanguageJson.ts
Last active January 3, 2024 15:56
Using Webpack code-split "backend" for i18next translations. Note that your withTranslations/useTranslations must use namespaces or include a default namespace or the read function doesn't get called
// Used for one JSON file for each language containing all namespaces
i18next.use({
type: 'backend',
read<Namespace extends keyof typeof en>(
language: LocaleCode,
namespace: Namespace,
callback: (
errorValue: unknown,
translations: null | typeof en[Namespace]
) => void
@cweitkamp
cweitkamp / bayesian.items
Last active December 4, 2021 23:14
Bayesian Sensor Aggregation
Switch proxySwitch "I am ... [MAP(sleeping.map):%s]"
Number proxyNumber "Probability [%.5f %%]"
Group gBAYESIAN "Bayesian Sleep Sensor" {
bayesian="proxySwitch" [ prior=0.5, threshold=0.85, state_given_true="ON", state_given_false="OFF" ]
}
Switch testSwitch1 "I am at home ... [MAP(yes-no.map):%s]" <presence> (gBAYESIAN) {
bayesian="ON" [ prob_given_true=0.99, prob_given_false=0.5 ]
}
@StevenACoffman
StevenACoffman / opa-vs-casbin.md
Last active April 7, 2024 02:43
OPA vs Casbin

Information in this Gist originally from this github issue, which is outdated.

As @RomanMinkin mentioned, you can also consider Casbin (https://github.com/casbin/casbin). It is the most starred authorization library in Golang. There are several differences between Casbin and OPA.

Feature Casbin OPA
Library or service? Library/Service Library/Service
How to write policy? Two parts: model and policy. Model is general authorization logic. Policy is concrete policy rule. A single part: Rego
RBAC hierarchy Casbin supports role hierarchy (a role can have a sub-role) Role hierarchies can be encoded in data. Also with the new graph.reachable() built-in function queries over those hierarchies are much more feasible now.
RBAC separation of duties Not supported Supported: two roles cannot be assigned together
@RLovelett
RLovelett / README.md
Last active March 19, 2024 12:52
Force RGB instead of YCbCr output for HDMI on Ubuntu

Force RGB pixel format over YCbCr

There are some monitors, in my case Dell U2413, that report having YCbCr support when plugged in over HDMI. My AMD Radeon RX 570 Series video card sees this YCbCr pixel format and then prefers that over the RGB pixel format. The result is that fonts, graphics and other visuals are pixelated and not smooth in Ubuntu.

This actually is not just a Linux problem. A similar problem exists on macOS with the same monitor hooked up over HDMI. In fact an article by John Ruble on the Atomic Object blog called Fixing the External Monitor Color Problem with My 2018 MacBook Pro attempts to fix the exact same thing.

Solution

All of the articles I could find exploring this topic advocate patching the EDID for the monitor. Unfortunately the macOS solution would not work here. Luckily I found a Reddit post that covered how to get it working.

@epcim
epcim / kubernetes_pods_docker_disk_usage.md
Last active January 22, 2024 03:57
docker disk space introspection kubernetes docker overlay

identify big pods/containers

investigage big files

DST=/mnt
find /var/lib -type f -size +1G -exec ls -lh {} \; | tee  $DST/bigfiles_var_lib_$(date "+%H%M").log
find /var/lib -type f -size +1G -exec ls -lh {} \; | awk '{ print $5 ": " $9 }' | sort -rh > $DST/bigfiles_var_lib_$(date "+%H%M").sorted.log

misbehave processes

@AnatomicJC
AnatomicJC / android-backup-apk-and-datas.md
Last active May 7, 2024 12:32
Backup android app, data included, no root needed, with adb

Backup android app, data included, no root needed, with adb

Note: This gist may be outdated, thanks to all contributors in comments.

adb is the Android CLI tool with which you can interact with your android device, from your PC

You must enable developer mode (tap 7 times on the build version in parameters) and install adb on your PC.

Don't hesitate to read comments, there is useful tips, thanks guys for this !

@chriswayg
chriswayg / create-cloud-template.sh
Last active May 1, 2024 20:47
This script will download a cloud image of many Linux distros and create a Proxmox 6 KVM template from it.
#!/bin/bash
set -o errexit
clear
printf "\n*** This script will download a cloud image and create a Proxmox VM template from it. ***\n\n"
### HOW TO USE
### Pre-req:
### - run on a Proxmox 6 server
### - a dhcp server should be active on vmbr1
@ciotlosm
ciotlosm / Readme.md
Last active February 5, 2024 15:04
Kiosk mode for lovelace

Kiosk mode

Installation

Add kiosk.js file with the content below to your www folder in config.

Like any other custom script, use ui-lovelace.yaml resources section to reference the kiosk.js file.

Make sure you add kiosk somewhere in your URL. You can use it in the id of your view or in the query string.

@henfiber
henfiber / KB-Buying-guide-EU.md
Last active May 3, 2024 06:38
Buying keyboards and keyboard components from EU

Europe

  • SkinFlint : Price comparison site which has some nice filtering options per switch type etc. Searches for offers in UK, Germany, Poland and Austria
  • mykeyboard.eu : Keyboards, keycaps and accessories. Based in Belgium.
  • candykeys.com : European Store selling Vortex, Leopold, KBP, Anne Pro keyboards, keycap sets and components (ISO + ANSI). Based in Germany, ships to EU.
  • falba.tech : custom wooden bamboo cases, and some acrylic and carbon ones. Switch packs (65 browns at 48EUR). Other parts for the GH60, Atreus, ErgoDox. Also Microcontrollers, diodes, leds etc.
  • 42keebs.eu - Mostly PCBs, tools and accessories. Located in Czech Republic.
  • KEYGEM : Switches, Keycaps, lubes, cables, DIY kits and deskmats. Based in Germany, ships to the EU and worldwide.
  • [Eloquent Clicks - Custom Mechanical Keyboard Store](https://www.eloquen