Skip to content

Instantly share code, notes, and snippets.

@baruch
baruch / DK61SE.md
Created August 2, 2025 13:23
Dierya DK61SE notes

The board is accessible from the top, remove the keycaps and find six screws, open them and carefully slide the board out. Note the USB-C port sticks out a bit and is in the way for the board to go out, you'll need to tilt it.

The board has a BYK903 marked chip which I have yet to identify.

There is an ISP port nearby with 6 pins that can be used to read and write the firmware with https://github.com/gashtaan/sinowealth-8051-dumper I haven't tried but looking at other boards on the net with a similar configuration it's a safe assumption.

I didn't identify any way to reset the board by pins so the only way to do it is with the USB protocol, this can be done with https://github.com/carlossless/sinowealth-kb-tool with which I successfully read the firmware but didn't

@baruch
baruch / d-scanner-lsp.lua
Last active July 20, 2025 15:42
Use D-Scanner as a diagnostics LSP in Neovim LazyVim with none-ls
Put the following in your ~/.config/nvim/init.lua (after the config.lazy init)
-- Setup dscanner as an nvim-lint command
-- use pattern, get severity and better code handling
local dscanner_pattern = "{filepath}:{line}:{column}:{endColumn}:{type}:{name}:{message}"
local pattern = "([^:]+):(%d+):(%d+):(%d+):([^:]+):([^:]+):(.*)"
local groups = { "file", "lnum", "col", "endcol", "severity", "code", "message" }
local severity_map = {
warn = vim.diagnostic.severity.WARN,
@baruch
baruch / defer.h
Created May 27, 2018 19:09
Defer cleanup for C (gcc and llvm)
#define DEFER_MERGE(a,b) a##b
#define DEFER_VARNAME(a) DEFER_MERGE(defer_scopevar_, a)
#define DEFER_FUNCNAME(a) DEFER_MERGE(defer_scopefunc_, a)
#define DEFER(BLOCK) void DEFER_FUNCNAME(__LINE__)(int *a) BLOCK; __attribute__((cleanup(DEFER_FUNCNAME(__LINE__)))) int DEFER_VARNAME(__LINE__)
// Usage:
/*
void dosomething()
{
char* data = malloc(100);
@baruch
baruch / scsi_sense.stp
Last active April 21, 2018 20:12
Get SCSI Sense buffers in Linux with systemtap
probe module("scsi_mod").function("scsi_command_normalize_sense") {
printf("CDB:");
for (i = 0; i < $cmd->cmd_len; i++) {
printf(" %02X", $cmd->cmnd[i]);
}
printf(" | SENSE:");
for (i = 0; i < 32; i++) {
printf(" %02X", $cmd->sense_buffer[i]);
}
printf("\n");
@baruch
baruch / pi-nrf24le1.sh
Last active April 28, 2022 12:11
Setup Raspberry Pi for nRF24LE1 development
# Install sdcc to build nRF24LE1 code
# Install python-dev and python-setuptools to build python code for hacking
# Install minicom for UART communication
# Install screen to avoid network disconnect interruptions
sudo apt-get update && sudo apt-get install sdcc python-dev python-setuptools minicom screen
sudo apt-get dist-upgrade
# Install bcm2835 library
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.38.tar.gz && tar xvf bcm2835/bcm2835-1.38.tar.gz && cd bcm2835-1.38 && ./configure && make && sudo make install
cd ~
@baruch
baruch / gist:106a3da12187b284830e
Created July 20, 2014 06:12
Optimal tar compression
find $d -type f | rev | sort | rev | tar -c -T /dev/stdin -f - | pv -pterb -B 10m -s $(du -ms $d | cut -f1)m -W -i 10 | bzip2 -6 > $d.tar.bz2;
@baruch
baruch / scsi_sense.stp
Created May 15, 2014 19:08
Get full SCSI Sense out of any command failure
probe module("scsi_mod").function("scsi_command_normalize_sense") {
printf("CDB:");
for (i = 0; i < $cmd->cmd_len; i++) {
printf(" %02X", $cmd->cmnd[i]);
}
printf(" | SENSE:");
for (i = 0; i < 32; i++) {
printf(" %02X", $cmd->sense_buffer[i]);
}
printf("\n");
@baruch
baruch / gist:8584442
Created January 23, 2014 18:47
ReQL: For a field get in one query the count, min, max and sample entries
r.db('mydb').table('disk').withFields('glist').groupedMapReduce(
function(x) { return x },
function(x) { return 1 },
function(x,y) { return 1 }
)
.map(function (x) { return x('group')('glist') })
.reduce(function(x,y) { return
{
count: x('count').add(1),
val: x('val').union([y]).sample(10),
@baruch
baruch / libev_async_dns.c
Created May 5, 2013 19:02
Asynchronous dns resolving with libev and the gethostbyname_r function.
#include <ev.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <netdb.h>
#include <memory.h>
typedef struct net_client_t {
ev_signal resolv_watcher;
char hostname[64];