Skip to content

Instantly share code, notes, and snippets.

View leycec's full-sized avatar
🐻
Coding fat one-liners from Canadian cottage country

Cecil Curry leycec

🐻
Coding fat one-liners from Canadian cottage country
  • Ionovate
  • Ontario, Canada
View GitHub Profile
@braindevices
braindevices / #btrfs benchmark for daily used desktop OS
Last active June 2, 2024 07:18
which file sytem to use for daily work? should we turn on btrfs compression?
#btrfs benchmark for daily used desktop OS
@rnag
rnag / metaclasses.py
Last active May 29, 2024 05:08
Field Property Support in Dataclasses, for Python 3.7+
from __future__ import annotations
import builtins
from collections import deque
from dataclasses import field as dataclass_field, Field, MISSING
from logging import getLogger
log = getLogger(__name__)
@davesteele
davesteele / cache_dict.py
Last active October 19, 2023 14:23
Python LRU Caching Dictionary - a dict with a limited number of entries, removing LRU elements as necessary
from collections import OrderedDict
# >>> import cache_dict
# >>> c = cache_dict.CacheDict(cache_len=2)
# >>> c[1] = 1
# >>> c[2] = 2
# >>> c[3] = 3
# >>> c
# CacheDict([(2, 2), (3, 3)])
# >>> c[2]
@skyzyx
skyzyx / homebrew-gnubin.md
Last active May 31, 2024 13:04
Using GNU command line tools in macOS instead of FreeBSD tools

macOS is a Unix, and not built on Linux.

I think most of us realize that macOS isn't a Linux OS, but what that also means is that instead of shipping with the GNU flavor of command line tools, it ships with the FreeBSD flavor. As such, writing shell scripts which can work across both platforms can sometimes be challenging.

Homebrew

Homebrew can be used to install the GNU versions of tools onto your Mac, but they are all prefixed with "g" by default.

All commands have been installed with the prefix "g". If you need to use these commands with their normal names, you can add a "gnubin" directory to your PATH from your bashrc.

@JettJones
JettJones / pystack.py
Created September 21, 2017 18:34
performance of various ways to get the callers name in python
import sys
import inspect
import time
import traceback
def deeper(func, depth):
if depth > 0:
return deeper(func, depth-1)
else:
return func()
@somada141
somada141 / vtk_load_stl.md
Last active January 27, 2022 06:46
Load an the contents of an STL file into a vtkPolyData object with Python and VTK #python #vtk #fileIO #visualizaton #stl

Assuming we have an .stl file under filenameSTL we can load the contents of that file using the vtkSTLReader class as such:

readerSTL = vtk.vtkSTLReader()
readerSTL.SetFileName(filenameSTL)
# 'update' the reader i.e. read the .stl file
readerSTL.Update()

polydata = readerSTL.GetOutput()