Skip to content

Instantly share code, notes, and snippets.

View x1unix's full-sized avatar
:shipit:
Work in progress

Denys Sedchenko x1unix

:shipit:
Work in progress
View GitHub Profile
@x1unix
x1unix / docker-compose.yml
Last active April 19, 2024 13:26
pihole+traefik
version: "3"
services:
traefik:
image: traefik:v2.10
container_name: 'traefik'
command:
- '--log.level=DEBUG'
- '--api.insecure=true'
- '--api.dashboard=true'
@x1unix
x1unix / chudnovsky.py
Created April 1, 2024 05:42
y-cruncher
import decimal
def binary_split(a, b):
if b == a + 1:
Pab = -(6*a - 5)*(2*a - 1)*(6*a - 1)
Qab = 10939058860032000 * a**3
Rab = Pab * (545140134*a + 13591409)
else:
m = (a + b) // 2
@x1unix
x1unix / lenovo-legion-5-backlight-fix.md
Last active March 31, 2024 16:53
Lenovo Legion 5 Backlight Fix

Brief explanation

Linux exposes a special interface to control screen brightness via sysfs in /sys/class/backlight (source). The problem is that in Lenovo Legion 5 there are two modules registered to control screen brightness - AMDGPU and ideapad modules:

$ ls /sys/class/backlight
amdgpu_bl0
ideapad
@x1unix
x1unix / chan.go
Created March 23, 2024 20:32
Go - check if a channel is closed without read
package main
import (
"fmt"
"unsafe"
)
// Copy of hchan struct with first necessary fields.
// See: "src/runtime/chan.go"
type hchan struct {
@x1unix
x1unix / vec.js
Last active February 29, 2024 02:14
vec.js
const { log, assert } = console
const { abs, max, sqrt } = Math
const dbg = (v) => console.log(typeof v, v)
const pow2 = v => v * v
const sum = (a,b) => a + b
const sub = (a,b) => a - b
const mul = (a,b) => a * b
const range = (length, fn) => Array.from({length}, (_, i) => fn(i))
@x1unix
x1unix / alloc_bench_test.go
Created February 20, 2024 01:38
[GO] Append vs Copy
package main
import (
"fmt"
"runtime"
"testing"
)
func BenchmarkAppend(b *testing.B) {
for i := 0; i < b.N; i++ {
@x1unix
x1unix / NET-framework-standalone-exe.md
Last active February 18, 2024 17:31
[C#] Embed DLL assemblies onto executable

Summary

This guide tells how to embed CLR assemblies (.dll) onto a single executable. This works for WPF, WinForms and console .NET applications.

Source - original article

Project settings

First, we need to add special section to .csproj file to make MSBuild embed referenced assemblies

@x1unix
x1unix / strdump.go
Created December 16, 2023 03:45
strdump
package main
import (
"bufio"
"fmt"
"io"
"os"
_ "unsafe"
)
@x1unix
x1unix / 55-switch.rules
Created October 20, 2023 20:05
Switch udev rules
# Place in /etc/udev/rules.d
SUBSYSTEM=="usb", ATTRS{idVendor}=="0955", ATTRS{idProduct}=="7321", MODE:="0666", GROUP="plugdev"
@x1unix
x1unix / paint_pixels.py
Created August 11, 2023 20:44
Google collab - render pixel grid library
#@title Canvas drawing library
import json
from typing import List
from IPython.display import HTML, Image
from google.colab.output import eval_js
canvas_html = """
<div style="font: 11pt monospace; color:red; white-space:pre" id="error"></div>
<canvas width="{0}" height="{1}" style="height:{0}px;width:{1}px" id="canvas"></canvas>