Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
Work in progress

Denis Sedchenko x1unix

:shipit:
Work in progress
View GitHub Profile
@x1unix
x1unix / parsefloat.go
Created Aug 10, 2020
Go: precise float parse
View parsefloat.go
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
The VIM Cheatsheet
View vim.md
@x1unix
x1unix / cidr.go
Last active Apr 16, 2020
Go - CIDR to IPs
View cidr.go
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)
View Xiaomi YI.md

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 Jan 22, 2020
ProxyPass LetsEncrypt Apache
View site.conf
<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
@x1unix
x1unix / batch_iterator.go
Created Jan 10, 2020
Go - Batch Iterator
View batch_iterator.go
package util
type IteratorCallback = func(start int, v []interface{}) error
type BatchIterator struct {
batchSize int
}
func NewBatchIterator(batchSize uint) BatchIterator {
return BatchIterator{
View yet another radare2 cheatsheet.md

radare2

load without any analysis (file header at offset 0x0): r2 -n /path/to/file

  • analyze all: aa
  • show sections: iS
  • list functions: afl
  • list imports: ii
  • list entrypoints: ie
  • seek to function: s sym.main
View bootloader.s
; Infinite loop (e9 fd ff)
jmp start
message db 'Hello yoba' ; 10 bytes
start:
mov ah, 0x0e ; tty mode
mov cx, 0
mov bx, message
@x1unix
x1unix / main.go
Created Sep 13, 2019
Go - RegNotifyChangeKeyValue
View main.go
package main
import (
"context"
"fmt"
"os"
"os/signal"
"sync"
"syscall"
View main.go
package main
import (
"fmt"
"unsafe"
)
func main() {
var mem [16*32]byte
You can’t perform that action at this time.