Skip to content

Instantly share code, notes, and snippets.

@3lbios
3lbios / bad_image_remover.py
Created March 29, 2020 23:30
Script to remove corrupted image files
import PIL
from PIL import Image as ImageP
import glob
import os
dir_to_scan = "DIR_WITH_TRAILING_SLASH"
allpics = 0
goodpics = 0
@3lbios
3lbios / README
Created January 30, 2020 00:39
Example Go to C communication (cgo FFI)
go build -buildmode=c-archive c_ffi.go &&
gcc -pedantic -Wall -Wextra main.c c_ffi.a -lpthread -o test.elf
./test.elf
output:
x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
@3lbios
3lbios / purifier_control_daemon.pl
Created January 12, 2020 12:09
Xiaomi Mi Purifier automation daemon in Perl
#!/usr/bin/perl
use strict;
use warnings;
# how to install mirobo and discover Mi devices:
# https://python-miio.readthedocs.io/en/latest/index.html
# substitute device IP and token from 'mirobo discover'
my $common_cmd = 'mirobo --ip <PURIFIER_IP> --token <PURIFIER_TOKEN>';
my $aqi_cmd = $common_cmd . ' raw-command get_prop \'["aqi"]\' 2>&1';