Skip to content

Instantly share code, notes, and snippets.

View yeus's full-sized avatar

Thomas Meschede yeus

View GitHub Profile
@hallundbaek
hallundbaek / FreeCAD-1.0rc1.nix
Last active October 5, 2024 16:42
A first attempt at creating a override for trying out the new FreeCAD 1.0rc1 on NixOS. Ideally the gtest should probably use the one from nixpkgs, but that resulted in issues that were easier solved by simply pulling the repo directly. Same goes for OndselSolver which should probably be its own package, alas I didn't do that.
pkgs.freecad.overrideAttrs (
final: prev: {
version = "1.0rc1";
src = pkgs.fetchFromGitHub {
owner = "FreeCAD";
repo = "FreeCAD";
rev = "1.0rc1";
hash = "sha256-bhRqWjYtwQ1mzZg03OmTFCt4eVgbc+YZnMNgwvRGvjc=";
};
@Vova-SH
Vova-SH / install_ha_2022_7_5.sh
Created July 24, 2022 14:14
Shell script for install HomeAssistant on Termux
pkg update
apt-get update
pkg upgrade
pkg install openssh
pkg install python nano make rust libcrypt libffi libjpeg-turbo binutils
pkg install mosquitto termux-api
python -m venv hass
@yeus
yeus / rate_limiter.py
Last active December 2, 2021 19:25
async rate limiting function using token bucket algorithm
"""
author: Thomas Meschede
license: MIT
"""
def rate_limit_burst(max_calls: float, interval: float):
"""
Rate-limits the decorated function locally, for one process. Using Token Bucket algorithm.
max_calls: maximum number of calls of function in interval
import { Component, defineAsyncComponent, defineComponent, h } from 'vue'
export function hydrateNever(componentOrFactory: Component): Component {
return makeHydrationBlocker(componentOrFactory, {
beforeCreate() {
this.never = true
},
})
}
@alyssais
alyssais / default.nix
Created January 22, 2019 11:32
Nix expression for building a reveal.js presentation using pandoc.
{ pkgs ? import (builtins.fetchTarball {
# nixpkgs-unstable 2019-01-22
url = https://github.com/NixOS/nixpkgs/archive/a5de41088031e6d3d4f799ef3964317a74e72169.tar.gz;
sha256 = "0ycsai65dbcwmns36a0pkxpsgpl86q273c27ag80nijfb1w88201";
}) {}
, revealjs ? pkgs.fetchFromGitHub {
owner = "hakimel";
repo = "reveal.js";
rev = "3.7.0";
@txomon
txomon / ratelimit.py
Created August 12, 2018 21:24
Rate limit python asyncio
import asyncio
import collections
async def ratelimit(*, max_request, in_interval):
slots = collections.deque()
while True:
slots.append(time() + in_interval)
yield
while len(slots) >= max_request:
left = slots[0] - time()
@ygotthilf
ygotthilf / jwtRS256.sh
Last active May 4, 2025 08:04
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@fpt
fpt / pykka_periodic.py
Created November 28, 2014 04:43
Pykka: periodic timer
#!/usr/bin/env python
# coding:utf-8
import pykka
import threading
import signal
import time
import sys
@ctokheim
ctokheim / cython_tricks.md
Last active March 4, 2024 23:27
cython tricks

Cython

Cython has two major benefits:

  1. Making python code faster, particularly things that can't be done in scipy/numpy
  2. Wrapping/interfacing with C/C++ code

Cython gains most of it's benefit from statically typing arguments. However, statically typing is not required, in fact, regular python code is valid cython (but don't expect much of a speed up). By incrementally adding more type information, the code can speed up by several factors. This gist just provides a very basic usage of cython.

//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//