Skip to content

Instantly share code, notes, and snippets.

View dlnilsson's full-sized avatar

Daniel Nilsson dlnilsson

  • Gothenburg, Sweden
  • 00:25 (UTC +02:00)
View GitHub Profile
@emilien-jegou
emilien-jegou / result.ts
Created February 24, 2025 14:31
Typescript error handling
import type { Prettify } from 'ts-essentials';
export type Result<T = unknown, E = unknown> = Success<T> | Failure<E>;
export interface Success<T> {
kind: 'success';
value: T;
}
export interface Failure<E> {
@t3dotgg
t3dotgg / try-catch.ts
Last active April 29, 2025 18:59
Theo's preferred way of handling try/catch in TypeScript
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};
@agners
agners / elgate-wave3-fix.sh
Created June 5, 2022 12:22
Elgato Wave:3 Pulseaudio "unstuck"
#!/bin/sh
# Getting Elgato Wave:3 Microphone input "unstuck" on Linux & Pulseaudio
# Replace <card-name> with your microphones card name (check "pacmd list-cards")
# It looks something like "usb-Elgato_Systems_Elgato_Wave_3_<serial>-00"
pacmd set-card-profile alsa_card.<card-name> output:analog-stereo
pacmd set-card-profile alsa_card.<card-name> input:mono-fallback
@krzys-h
krzys-h / Hyper-V GPU-PV with Linux guest.md
Last active April 28, 2025 03:55
Ubuntu 21.04 VM with GPU acceleration under Hyper-V...?

Ubuntu 21.04 VM with GPU acceleration under Hyper-V...?

Modern versions of Windows support GPU paravirtualization in Hyper-V with normal consumer graphics cards. This is used e.g. for graphics acceleration in Windows Sandbox, as well as WSLg. In some cases, it may be useful to create a normal VM with GPU acceleration using this feature, but this is not officially supported. People already figured out how to do it with Windows guests though, so why not do the same with Linux? It should be easy given that WSLg is open source and reasonably well documented, right?

Well... not quite. I managed to get it to run... but not well.

How to do it?

  1. Verify driver support
@eNV25
eNV25 / hp-bios-update.md
Last active April 16, 2025 18:44
Instructions to Update the BIOS/UEFI for an HP Laptop on Linux

Instructions to Update the BIOS/UEFI for an HP Laptop on Linux

To update the BIOS/UEFI firmware requires HP-specific files in the EFI System Partition, also referred to as ESP.

On a Linux system, the ESP is typically mounted on /boot/efi or /efi. Whithin you should also find a EFI directory, e.g. /boot/efi/EFI or /efi/EFI. This article assumes that the ESP is mounted on /efi and that the /efi/EFI directory exists. You can replace that with the mount point your system uses.

The HP-specific files are located in /efi/EFI/HP or /efi/EFI/Hewlet-Packard. These files typically come preinstalled in HP Windows PCs. If you have these files you could skip Install HP-specific files.

@thomascellerier
thomascellerier / azure.py
Last active July 21, 2020 11:14
Azure client poc using aiohttp
#!/usr/bin/python3.8
import asyncio
import os
from typing import List
import aiohttp
from dataclasses import dataclass, field
import typedload
@dmelliot
dmelliot / i3wm title bar icons
Last active August 1, 2022 01:22
i3wm window icon alternative using FontAwesome (or other icon based fonts)
# Title bar icons
for_window [class="(?i)firefox"] title_format "<tt></tt><span foreground='#FF6611'>  </span><tt> </tt>%title"
for_window [class="(.*)terminal(.*)"] title_format "<tt></tt><span foreground='#00FF00' background='#000000'>  </span><tt> </tt>%title"
for_window [class="(.*)Chromium-browser(.*)"] title_format "<tt></tt><span foreground='#367dd0' background='#d9e5f4'>  </span><tt> </tt>%title"
for_window [class="Evolution"] title_format "<tt></tt><span foreground='#FFFFFF' >  </span><tt> </tt>%title"
for_window [title=".* Evolution"] title_format "<tt></tt><span foreground='#FFFFFF' >  </span><tt> </tt>%title"
for_window [class="Slack"] title_format "<tt></tt><span foreground='#FFFFFF' >  </span><tt> </tt>%title"
for_window [class="Signal"] title_format "<tt></tt><span background='#2090ea' foreground='#FFFFFF' >  </span><tt> </tt>%title"
for_window [class="VirtualBox Machine"] title_format "<tt></tt><span background='#073624' foreground='#AAAAFF' >  </span><tt> </tt>%title"
for_window [cla
@DimaKoz
DimaKoz / go-executable-build.sh
Last active October 7, 2024 15:06
The Script to Automate Cross-Compilation for Golang(OSX)
#Before we can use the script, we have to make it executable with the chmod command:
#chmod +x ./go-executable-build.sh
#then we can use it ./go-executable-build.sh yourpackage
#!/usr/bin/env bash
package=$1
if [[ -z "$package" ]]; then
echo "usage: $0 <package-name>"
exit 1
fi
@codepo8
codepo8 / ai-for-humans.md
Last active December 23, 2022 07:56
Link collection for the "AI for humans" talk

Slides

Intro and history of ML on the web

  • Autodraw by Google is a tool that allows you to doodle what you want to paint and turns it into a proper icon by detecting the outline and making an ML based assumption what it could be.
  • Quickdraw by Google is a game they created a few years before Autodraw to train the model.
  • ReCaptcha is a CAPTCHA engine that feeds the data back into Google's ML systems. For example, currently being asked to detect street signs or cars is a good indicator that this data will go into the self-driving cars project.
@posener
posener / go-table-driven-tests-parallel.md
Last active April 24, 2025 20:46
Be Careful with Table Driven Tests and t.Parallel()

Be Careful with Table Driven Tests and t.Parallel()

We Gophers, love table-driven-tests, it makes our unittesting structured, and makes it easy to add different test cases with ease.

Let’s create our table driven test, for convenience, I chose to use t.Log as the test function. Notice that we don't have any assertion in this test, it is not needed to for the demonstration.

func TestTLog(t *testing.T) {
	t.Parallel()