Skip to content

Instantly share code, notes, and snippets.

View hclivess's full-sized avatar
🏠
Working from home

Jan Kučera hclivess

🏠
Working from home
View GitHub Profile
@hclivess
hclivess / whydevslovedyna.json
Last active January 28, 2023 13:46
Why Devs Love Dynatrace Dashboard
{
"metadata": {
"configurationVersions": [
6
],
"clusterVersion": "1.258.87.20230120-140924"
},
"id": "a630b218-1648-4efb-82d4-71e41b859695",
"dashboardMetadata": {
"name": "Best Practices Overview",
@hclivess
hclivess / raise_inheritance.py
Created January 5, 2023 04:15
Python raise inheritance to never forget
try:
try:
try:
print(1/0)
except Exception as e:
raise(e)
except:
print("I will not raise")
except:
print("I never trigger")
@hclivess
hclivess / async_gather.py
Created December 11, 2022 20:35
Simple asynchronous gather function
import asyncio
pets = ["aliens", "cats", "dogs", "ostriches"]
def print_pet(pet):
print(pet)
async def main():
await asyncio.gather(print_pet(pet) for pet in pets)
@hclivess
hclivess / sync_to_async.py
Created November 27, 2022 15:19
minimalistic asyncio on synchronous functions that do not support it
import asyncio
def static_hi(this):
"""this function is not asynchronous"""
return this
async def printer():
"""notice arguments are not passed directly"""
"D:\Hry\steamcmd\steamcmd.exe" +login anonymous +app_update 1110390 +exit
start "" "%~dp0ServerHelper.bat" +InternetServer/Ostrava
from numpy.random import seed
from numpy.random import normal
import matplotlib.pyplot as plt
def get_ndist_list(loc=0, scale=1, size=100):
return list(normal(loc=loc, scale=scale, size=size))
def define_x_axis(y_axis):
x_axis = []
@hclivess
hclivess / montequanto.py
Created July 7, 2022 12:47
bitmap quantum montecarlo dirty code
import time
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as stats
import math
import cairo
class TexasRanger:
@hclivess
hclivess / client.py
Created July 3, 2022 00:54 — forked from nephics/client.py
Test of experimental Tornado feature for a streaming request body handler
#
# Test of experimental Tornado feature for a streaming request body handler, see
# https://github.com/nephics/tornado/commit/1bd964488926aac9ef6b52170d5bec76b36df8a6
#
#
# Client sending file to server
#
import tornado.httpclient as httpclient
@hclivess
hclivess / wm.py
Last active July 2, 2022 18:28
word miner
import random
import requests
import re
def fetch(max_length=12, min_length=6):
title = None
while not title or min_length < len(title) > max_length:
url = "https://en.wikipedia.org/wiki/Special:Random"
mashup = requests.get(url).text
@hclivess
hclivess / check.py
Created June 30, 2022 16:59
check if a specific dictionary entry is within a list of dictionaries
target_list = [{"ip": 1, "ad": 0}, {"ip": 2, "ad": 0}]
s2 = {"ip": 2}
s3 = {"ip": 3}
if s2["ip"] not in [x["ip"] for x in target_list]:
print(f"{s2['ip']} is new")
if s3["ip"] not in [x["ip"] for x in target_list]:
print(f"{s2['ip']} is new")