Skip to content

Instantly share code, notes, and snippets.

View Glutexo's full-sized avatar
🇨🇿
Wypili moją krew na hejnał

Glutexo Glutexo

🇨🇿
Wypili moją krew na hejnał
  • Frýdek, Czechia
View GitHub Profile
@Glutexo
Glutexo / getitem.py
Created September 9, 2022 10:24
__getitem__ example
from unicodedata import name
ANIMALS = (
"🐶🐱🐭🐹🐰🦊🐻🐼🐻🐨🐯🦁🐮🐷🐽🐸🐵🙈🙉🙊🐒🐔🐧🐦🐤🐣🐥🦆🦅🦉🦇🐺🐗🐴🦄🐝🪱🐛🦋🐌🐞🐜🪰🪲🪳🦟🦗🕷🕸🦂🐢🐍🦎🦖🦕🐙🦑🦐🦞🦀🐡🐠🐟🐬🐳🐋🦈🦭🐊"
"🐅🐆🦓🦍🦧🦣🐘🦛🦏🐪🐫🦒🦘🦬🐃🐂🐄🐎🐖🐏🐑🦙🐐🦌🐕🐩🦮🐈🪶🐓🦃🦤🦚🦜🦢🦩🕊🐇🦝🦨🦡🦫🦦🦥🐁🐀🐿🦔🐾🐉🐲"
)
class Emoticons:
@Glutexo
Glutexo / rounding.py
Created August 22, 2022 10:01
Rounding in Python
ANIMALS = {
"🐇": "🐰",
"🐁": "🐭",
"🐈": "🐱",
"🐕": "🐶",
"🐅": "🐯",
"🐄": "🐮",
"🐖": "🐷",
"🐒": "🐵",
"🐥": "🐤",
@Glutexo
Glutexo / combinations.exs
Created June 13, 2022 13:21
Recursive combinations with subsets
defmodule Combination do
def combine([]) do
[]
end
def combine([head | tail]) do
tail_combinations = combine(tail)
merged_combinations = Enum.map(
[[]] ++ tail_combinations,
fn c -> c ++ [head] end
@Glutexo
Glutexo / Pokemon.csv
Last active March 21, 2022 16:34
Hra na myšlenou potvoru
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
Stáhněte si z https://raw.githubusercontent.com/frenzymadness/Data_analysis_workshop/master/data/Pokemon.csv.
@Glutexo
Glutexo / get_core_version_from_insights_client_rpm.py
Last active February 4, 2022 20:51
Get Insights Core version from Insights Client RPM
from contextlib import contextmanager
from os.path import join
from rpmfile import open as rpm_open
from sys import argv
from zipfile import ZipFile
EGG_PATH = join(".", "etc", "insights-client", "rpm.egg")
VERSION_PATH = join("insights", "VERSION")
@Glutexo
Glutexo / magic_cell.py
Last active November 30, 2021 20:41
A cell object that doesn’t require knowledge of any names
_NOTHING = object()
DELETE = object()
class Cell:
def __init__(self, value=_NOTHING):
if value is not _NOTHING:
self.value = value
def __call__(self, value=_NOTHING):
@Glutexo
Glutexo / cell.py
Created November 30, 2021 19:55
A mutable cell with the simplest API possible
_SENTINEL = object()
class Cell:
def __init__(self, value=_SENTINEL):
if value is not _SENTINEL:
self.value = value
def __call__(self, value=_SENTINEL):
if value is not _SENTINEL:
@Glutexo
Glutexo / data_collector.patch
Last active November 9, 2021 21:26
Data Collector patch for Insights Core to limit collection only to a single file
Index: insights/client/data_collector.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/insights/client/data_collector.py b/insights/client/data_collector.py
--- a/insights/client/data_collector.py (revision 42907d96132d4877ac588e6aa090b0cd4adbfcf1)
+++ b/insights/client/data_collector.py (date 1636398517420)
@@ -320,6 +320,13 @@
rm_commands = rm_conf.get('commands', [])
@Glutexo
Glutexo / get_file_from_insights_archive.py
Last active March 21, 2022 16:33
Get a file from an Insights archive
from collections import namedtuple
from contextlib import contextmanager
from functools import partial
from io import BytesIO
from io import StringIO
from os.path import join
from re import escape
from re import fullmatch
from shlex import quote
from tarfile import open as tar_open
@Glutexo
Glutexo / uninstall-all-pip-packages.xonsh
Created September 12, 2021 17:12
xonsh script to uninstall all pip packages
for line in $(pip freeze).split("\n"):
. try:
. package, _ = line.split("==")
. except ValueError:
. continue
. else:
. $(pip uninstall -y @(package))