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 / FocusFollowsMouse.ps1
Created April 25, 2024 02:38
Windows - Focus Follows Mouse
$signature = @"
[DllImport("user32.dll")]
public static extern bool SystemParametersInfo(int uAction, int uParam, ref
int lpvParam, int flags );
"@
$systemParamInfo = Add-Type -memberDefinition $signature -Name SloppyFocusMouse -passThru
[Int32]$newVal = 1
$systemParamInfo::SystemParametersInfo(0x1001, 0, [REF]$newVal, 2)
@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 / 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 / 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>
@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 / churl.sh
Created September 20, 2022 15:13
CURL using Google Chrome
./Google\ Chrome --headless --disable-gpu --disable-logging --dump-dom http://google.com