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 / compose.yml
Last active October 11, 2024 06:47
Jaeger + CORS Proxy
services:
nginx:
image: nginx:latest
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- "16686:16686" # Both Jaeger UI and exporter are on the same port.
depends_on:
- jaeger
@x1unix
x1unix / reset-permissions.md
Created October 6, 2024 11:08
macos-app-reset-permissions
@x1unix
x1unix / service-worker.js
Created July 15, 2024 13:29
self-destruct SW
// Self-destructible service worker stub
self.addEventListener('install', function(e) {
self.skipWaiting();
})
self.addEventListener('activate', function(e) {
self.registration.unregister()
.then(function () {
return self.clients.matchAll();
})
@x1unix
x1unix / theme.ts
Created June 6, 2024 21:33
CodeMirror VSCode Light Theme
import { tags as t } from '@lezer/highlight'
import { createTheme } from '@uiw/codemirror-themes'
export { vscodeDark } from '@uiw/codemirror-theme-vscode'
// VSCode light theme based on dark theme from '@uiw/codemirror-theme-vscode'.
// See: https://github.com/uiwjs/react-codemirror/blob/master/themes/vscode/src/index.ts
export const vscodeLight = createTheme({
theme: 'light',
settings: {
@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"
)