Skip to content

Instantly share code, notes, and snippets.

@promto-c
promto-c / Python_LRU_Cache_Usage_Guide.md
Last active May 22, 2025 07:33
A detailed guide to using Python's functools.lru_cache for efficient function caching. Covers basic usage, cache management, custom cache control, and additional insights for optimal utilization in various development scenarios. Ideal for Python developers looking to enhance performance with caching techniques.

1703673950911

Python lru_cache Usage Guide

Overview

The lru_cache decorator in Python's functools module implements a caching strategy known as Least Recently Used (LRU). This strategy helps in optimizing the performance of functions by memorizing the results of expensive function calls and returning the cached result when the same inputs occur again.

Basic Usage

from functools import lru_cache
@jianyun8023
jianyun8023 / book-convert.sh
Created April 21, 2022 10:36
ebook convert base on eCore
#!/bin/bash
workdir=$(pwd)
filepath=$1
format=$2
outdir=$3
book_convert(){
filepath=$1
format=$2
tmp_dir="$HOME/Downloads/eCoreCmdtmp/$(uuidgen)"
mkdir -p $tmp_dir
@StephenCleary
StephenCleary / chat.lua
Last active May 18, 2025 16:11
Starting point for a custom TCP Wireshark dissector in Lua
-- authors: Hadriel Kaplan <hadriel@128technology.com>, Stephen Cleary
-- Copyright (c) 2015-2022, Hadriel Kaplan, Stephen Cleary
-- This code is in the Public Domain, or the BSD (3 clause) license if Public Domain does not apply in your country.
-- Thanks to Hadriel Kaplan, who wrote the original FPM Lua script.
-- This is a starting point for defining a dissector for a custom TCP protocol.
-- This approach assumes that each message has a header that indicates the message length.
-- The code in this example uses a 4-byte header which is just a 4-byte big-endian message length,
-- and this length does not include the length of the header.
-- Modify the sections marked TODO to adjust these assumptions.
@pranaysy
pranaysy / lz76benchmarks.py
Last active November 6, 2025 08:14
Comparison of LZ76 complexity implementations
"""
A demo comparison of three different implementations for estimating Lempel-Ziv complexity (1976)
Implementations compared:
- Pure Python version, by Naereen
- Numba (str), as implemented in EntroPy by Raphael Vallat
- Numba, updated for speed, based on numpy integer arrays
Simple comparisons for equality of estimates and performance to address issue:
https://github.com/raphaelvallat/entropy/issues/14
@raysan5
raysan5 / custom_game_engines_small_study.md
Last active January 7, 2026 20:51
A small state-of-the-art study on custom engines

CUSTOM GAME ENGINES: A Small Study

a_plague_tale

WARNING: Article moved to separate repo to allow users contributions: https://github.com/raysan5/custom_game_engines

A couple of weeks ago I played (and finished) A Plague Tale, a game by Asobo Studio. I was really captivated by the game, not only by the beautiful graphics but also by the story and the locations in the game. I decided to investigate a bit about the game tech and I was surprised to see it was developed with a custom engine by a relatively small studio. I know there are some companies using custom engines but it's very difficult to find a detailed market study with that kind of information curated and updated. So this article.

Nowadays lots of companies choose engines like [Unreal](https:

@kfreezen
kfreezen / datagridcomboboxcolumn-singleclick.markdown
Last active August 2, 2023 08:14
DataGridComboBoxColumn single-click edit. Commit edit after selection changed

I experienced some frustration with lack of other examples on getting select boxes to work on WPF DataGrid.

The first problem I encountered was that combo boxes did not have single-click to edit. That's what the Setters are for.

The next problem was that once I selected an item in a combobox, the combobox would not leave edit mode if I clicked directly into the next row. That's what the LostFocus and GotFocus events fix.

<!-- XAML -->
<DataGridComboBoxColumn
    ItemsSource="{Binding Source=Blah}"
@sherdim
sherdim / plot_csd_erp.ipynb
Last active November 7, 2024 09:31
Current Source Density with mne-python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@erdincay
erdincay / sugh.sh
Last active October 8, 2025 17:41
su GitHub (downloading all repositories from a given user)
#!/bin/bash
if [ -z "$1" ]; then
echo "waiting for the following arguments: username + max-page-number"
exit 1
else
name=$1
fi
if [ -z "$2" ]; then
@raphaelvallat
raphaelvallat / ecg_derived_respiration.ipynb
Last active April 8, 2025 22:14
Extract respiration signal and respiratory rate from ECG using R-R interval.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.