Skip to content

Instantly share code, notes, and snippets.

@torgeir
torgeir / --etc--systemd--system--after-sleep.service
Created February 19, 2022 15:57
Bring back display after sleep. Keywords: manjaro nvidia lightdm blurlock i3exit xrandr. Double -- in filename means /
[Unit]
Description=Make the screen come back after waking from suspend
After=suspend.target
[Service]
Type=oneshot
ExecStartPre=/bin/sleep 5s
ExecStart=/home/torgeir/bin/after-sleep.sh
[Install]
@torgeir
torgeir / js-map-set-complex-objects.js
Created February 16, 2022 14:50
Js Map and Sets for complex objects
var o = {}
var m = new Map()
m.set(o, 42)
m.get({}) // undefined
m.get(o) // 42
var s = new Set()
s.add(1)
s.add(2)
s.add(2)
@torgeir
torgeir / linux-test-disk-write-speed.sh
Created December 1, 2021 21:58
Linux test disk write speed
dd if=/dev/zero of=test.img bs=1G count=5 oflag=dsync && rm test.img
# 5+0 records in
# 5+0 records out
# 5368709120 bytes (5,4 GB, 5,0 GiB) copied, 3,69591 s, 1,5 GB/s
@torgeir
torgeir / wine-helix-native-vst.log
Last active March 18, 2024 10:17
Wine installing Helix Native 3.11 on Ubuntu Studio 21.01 with wine-staging 6.12
# Install a bunch of Windows DLLs needed to make Native work
# https://ubuntuhandbook.org/index.php/2021/05/wine-6-9-released-install-in-ubuntu-21-04-20-04/
sudo apt install --install-recommends winehq-staging
wine 'wineboot'
sudo apt install winetricks
# on manjaro with x11 this worked fine
winetricks vcrun2013 gdiplus urlmon
# on arch with wayland (amd) I needed
winetricks dxvk vcrun2013 gdiplus urlmon
@torgeir
torgeir / org-w3c-dom-serializer.kt
Created July 8, 2021 05:48
Org w3c dom serializer xml node to string kotlin
// https://xerces.apache.org/xerces2-j/faq-dom.html
private val loadSaveSerializer by lazy {
val registry = DOMImplementationRegistry.newInstance()
val domImplementation = registry.getDOMImplementation("LS") as DOMImplementationLS
domImplementation.createLSSerializer()
}
loadSaveSerializer.writeToString(..)
@torgeir
torgeir / bigquery-geojson-with-properties.json
Last active June 23, 2021 11:47
Geojson with properties, extracted from bigquery
[
{
"json": "{\"type\":\"MultiLineString\",\"coordinates\":\"[[[11.36588,61.13079], ... , [11.007229,61.572116]]]\",\"properties\":{\"description\":\"Stengt på grunn ... . \"}}"
},
...
{
"json": "{\"type\":\"LineString\",\"coordinates\":\"[[10.402729,62.429979], ... ,[10.335529,62.561779]]\",\"properties\":{\"description\":\"Stengt på grunn ... .\"}}"
}
]
@torgeir
torgeir / fix-monitors.sh
Last active June 20, 2021 05:58
xrandr config to bring back my display port monitor samsung lc32hg70qquxen on the DQ77kb
xrandr --output eDP1 --off
#xrandr --output DP1 --off
xrandr \
--display :0 \
--output VIRTUAL1 --off \
--output eDP1 --off \
--output DP1 --primary --mode 1024x768 --pos 0x0 --rotate normal --auto \
--output DP2 --off \
--output HDMI2 --off \
@torgeir
torgeir / gradle.build.kts
Created June 15, 2021 12:09
Gradle no plugin solution for building fat jars
val fatJar = task<Jar>("fatJar") {
with(tasks["jar"] as CopySpec)
duplicatesStrategy = DuplicatesStrategy.INCLUDE
from(configurations.runtimeClasspath.get().map {
if (it.isDirectory) it
else zipTree(it)
})
manifest {
attributes["Main-Class"] = "io.ktor.server.netty.EngineMain"
}
@torgeir
torgeir / zoom-mute-status-setup.md
Last active October 13, 2022 21:21
Example configurations for AnyBar and Ubsersicht to get a visual cue representing your zoom mute status. Credits https://gist.github.com/tyhawkins/66d6f6ca8b3cb30c268df76d83020a64
(ns core)
(def not-nil? (complement nil?))
(def prime?
(memoize
#(.isProbablePrime (BigInteger. (str %)) 100)))
(def char-to-int
(memoize