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 / vim_cs.md
Last active February 24, 2021 12:37
VIM Cheatsheet
@x1unix
x1unix / prog.go
Created January 6, 2021 20:27
Golang - detect bitness
package main
import (
"fmt"
"unsafe"
)
func main() {
// way 1
const is64Bit = uint64(^uintptr(0)) == ^uint64(0)
@x1unix
x1unix / counter.js
Last active January 5, 2021 20:57
Browser FPS Counter
class FpsCounter {
constructor(callbackFn) {
if (typeof callbackFn !== 'function') {
throw new ReferenceError(`Function argument required (got ${typeof callbackFn})`);
}
this.enabled = false;
this.fps = 0;
this.callback = callbackFn;
}
@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 / keybase.md
Created January 3, 2021 20:25
keybase.md

Keybase proof

I hereby claim:

  • I am x1unix on github.
  • I am x1unix (https://keybase.io/x1unix) on keybase.
  • I have a public key ASDhUxHxR9krTdi_xwqHg9lgsZ1nDptYNLdFnIDyCAWbGAo

To claim this, I am signing this object:

@x1unix
x1unix / parsefloat.go
Created August 10, 2020 15:23
Go: precise float parse
package main
import (
"fmt"
)
// ParseFloatPrecisely parses floating point from string as strconv.ParseFloat
// but avoids float point precision issue (ex: "0.21" parsed as 0.209999)
func ParseFloatPrecisely(str string, bitSize int) (num float64, err error) {
if str == "" || str == "0" {
@x1unix
x1unix / vim.md
Last active May 29, 2020 17:21
The VIM Cheatsheet
@x1unix
x1unix / cidr.go
Last active April 16, 2020 14:10
Go - CIDR to IPs
package main
func IPsFromCIDR(cidr string) ([]net.IP, error) {
_, ipNet, err := net.ParseCIDR(cidr)
if err != nil {
return nil, err
}
ones, bits := ipNet.Mask.Size()
addrCount := 1 << (bits - ones)
@x1unix
x1unix / Xiaomi YI.md
Created February 8, 2020 18:33 — forked from franga2000/Xiaomi YI.md
Xiaomi Yi

Xiaomi Yi camera

General info

  • OS: Buildroot
  • CPU: ARMv6-compatible processor rev 5 (v6l)
  • BogoMIPS: 524.28
  • Memory: 37MB

The root filesystem is rootfs, which is stored in memory and therefore wiped on reboot. The Micro SD card is mounted at /tmp/fuse_d/. Something is also mounted at /tmp/fuse_a and /tmp/fuse_z.

@x1unix
x1unix / site.conf
Created January 22, 2020 13:49
ProxyPass LetsEncrypt Apache
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName goplay2.x1unix.com
ServerAlias www.goplay2.x1unix.com