Skip to content

Instantly share code, notes, and snippets.

View mt3o's full-sized avatar

Teodor Kulej mt3o

View GitHub Profile
@mt3o
mt3o / gist:f6f80ac963565b009f06712f90e9d638
Last active March 26, 2025 18:24
Linux Proton with Intel SDE
export PROTON_LOG=1
export WINEDEBUG="+timestamp,+pid,+tid,+seh,+debugstr,+module"
export STEAM_COMPAT_CLIENT_INSTALL_PATH=~/.steam/steam
export STEAM_COMPAT_DATA_PATH=~/.proton/
~/sde/sde -follow-subprocess -- ~/steam/steamapps/common/Proton\ -\ Experimental/proton run ~/steam/steamapps/common/Helldivers\ 2/bin/helldivers2.exe
@mt3o
mt3o / polymorhpic-array-elements.ts
Created February 24, 2025 09:20
Typescript won't accept Array with polymorphic elements
class Animal {
name: string | undefined;
}
class Cat extends Animal {
food: string | undefined;
}
let animals: Animal[] = [
{ name: "Whiskers", food: "fish" }, //won't go with TS
@mt3o
mt3o / polymorphic-patterns.ts
Created June 18, 2024 16:34
TS Polyomrphic patterns
// Very bad
const config={
where: "disk"|"redis"
}
if(config.where=="disk"){
//explicit code to save to disk
}else if(config.where=="redis"){
//explicit code to handle redis
@mt3o
mt3o / what-forces-layout.md
Created June 18, 2024 11:37 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.JLabel;
public class d {
public static void main(String[] args) {
int x = 650;
@mt3o
mt3o / git purge large unwanted file.sh
Created August 16, 2023 09:01
Diagnose & remove large files from git repo
# find large objects
git rev-list --objects --all |
git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' |
sed -n 's/^blob //p' |
sort --numeric-sort --key=2 |
cut -c 1-12,41- |
$(command -v gnumfmt || echo numfmt) --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest
# remove package.tar.xz from repo
@mt3o
mt3o / commandline.bat
Created March 9, 2023 13:21
gource snippet
gource --hide mouse --date-format "%Y-%m-%d" --highlight-dirs --filename-time 2 --multi-sampling --camera-mode overview --file-idle-time 320 --max-user-speed 400 --seconds-per-day 0.05 -o - | ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset medium -pix_fmt yuv420p -crf 9 -bf 0 gource.mp4
@mt3o
mt3o / siblings.js
Created December 12, 2022 08:06
Get all siblings of single DOM node
function siblings(el) {
return el.closest('*:not(:scope)').querySelectorAll(':scope > *');
}
@mt3o
mt3o / node.js
Created June 7, 2022 14:54
hack around ts import error unexpected symbol export
//hack around es6 modules incompatibility
//when import fetch from 'node-fetch'; fails
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
@mt3o
mt3o / multiprocessing_queue.py
Created June 16, 2021 16:39
python multiprocessing with intermediate queue
# stolen from: https://stackoverflow.com/questions/6672525/multiprocessing-queue-in-python
import multiprocessing
num_procs = 4
def do_work(message):
print "work",message ,"completed"
def worker():
for item in iter( q.get, None ):
do_work(item)