Skip to content

Instantly share code, notes, and snippets.

View nay-kang's full-sized avatar
🏠
Working from home

nay-kang

🏠
Working from home
View GitHub Profile
@nay-kang
nay-kang / qemu_guest_ipv6_retrieve.md
Created August 15, 2024 08:54
qemu guest ipv6 retrieve

I used ubuntu as Host OS for my virtual machines.and One of them is my openwrt router server. One day after I update the system and rebooted.I can not obtian publc IPv6 address In my router.

  • first I suspect ISP made some changes to my modem, so I try different settings of the modem,but nothing changed except I barely lost connect to the modem.
  • during try the modem I used another computer instead of my server,the later computer can get IPv6 address.
  • then I give up try to tweak settings and using backup plan. use a physical AP as main router instead the virtual soft router.
  • other devices outside the server can get IPv6 successfully. but the vms still can not obtian IPv6 address.
  • after change to physical router the server left a spare ethernet port.I use that ethernet port as physical port to one vm instead of bridge network. that vm can successfully obtian IPv6 address.
  • so the problem become more clear.something between libvirt and vm prevent guest obtian IPv6 address.so I googled about "libvirt
@nay-kang
nay-kang / LM75A.cpp
Last active March 19, 2026 08:35
esphome temperature code LM75A
#include "esphome.h"
#include "esphome/core/log.h"
#include "LM75A.h"
#define INVALID_LM75A_TEMPERATURE 1000
namespace esphome {
namespace sensor {
static const char *TAG = "LM75A";
@nay-kang
nay-kang / remote_disk_combinnation.md
Created July 19, 2023 02:31
Merge Multi Linux spare disk

Linux server A to share disk

  • install nbd-server. sudo apt install nbd-server. nbd means network block device.
  • maybe you need sudo modprobe nbd
  • sudo dd if=/dev/zero of=/mnt/nbd.share.img bs=128M count=80.create a file for nbd to export to other machine.partition can be used here,but for lowend VPS partition not awalys available.
  • sudo chown nbd:nbd /mnt/nbd.share.img
  • create file under /etc/nbd-server/conf.d/export.conf
[export-share]
        exportname = /mnt/nbd.share.img
 readonly = false
@nay-kang
nay-kang / compile-libsimple-tokenizer-into-sqlite3.dart.md
Last active July 25, 2023 08:21
dart web fulltext search trying

The snote project need full text search in client-side and cross platform(Web,iOS,Android). after a research the sqlite3 with fts5 become the most likely option.
but the fts5 bultin tokenizer(unicode61,ascii,porter,trigram) do not fit the needs.as my experience when I want to find a note in hand, I can't remember too much about the note(the hand notes also short every word in the note is important). So I can only search the note base on one word or a token in chinese.
for example "出门记得买菜,药,清洁剂", then I only remember "菜" then I want to search the note become diffcult or unavilable on fts5 bultin tokenizer.
after search I found libsimple tokenizer could suit my needs.

first I try build it into a cli dart environment for test only. but I failed in macos. because it only provide desktop and android prebuild shared library. I decide try to solve the most diffcult suitation,then other env could be easy. that is running on web.

I wanna try load shared library on

I want expose my libvirt VMs under NAT to my other computer in the same LAN.

For example I had VMs which ip range 192.168.100.0/24 and my router LAN range is 192.168.1.0/24. I want connect the VMs not only from the host, also from other computers in the LAN under 192.168.1.0/24.

First I create a static router in my router which is Openwrt. Interface select lan,Target input '192.168.100.0/24', mask input '255.255.255.0', and the gateway input the host machine LAN ip eg:'192.168.1.101'. now I can only ping 192.168.100.1 from the router.I can't ping 192.168.100.2 and others.

I had to add the iptables rule in the host machine:sudo iptables -I LIBVIRT_FWI 1 -d 192.168.100.0/24 -o virbr0 -j ACCEPT.

Background

Some resource need store in private enviroment. maybe there is no public ip assigned or the resource need protected. ASAP private NAS. typically we use openvpn to make tunnel back to home or office, but openvpn is more complex so I choose wireguard this time.
we can regard wireguard as ssh. communicate each point(peer) with public and private key.

Endpoints

  • pointA:relay server has public IP eg:1.2.3.4
  • pointB:home openwrt router
  • pointC:laptop outside home

Background

After purchased a new laptop, the old one leave unused. I want to put some of my development environment in the old laptop that can let me save some resource for other development. I also want to put openwrt on the old laptop, the openwrt in physical router has resouce limit eg storage,RAM or CPU. the physical router play as AP only.

as I want deploy development on it, so I need an ubuntu server both live with openwrt on the same laptop. I had two solution

  • Openwrt as host and qemu ubuntu as guest
  • Ubuntu as host and qemu openwrt as guest

due openwrt is more lightweight and not every development component can run in docker. So I decide the second solution run openwrt in qemu.

@nay-kang
nay-kang / mysql_repl_mixed.jpg
Last active April 23, 2022 14:56
MySQL replication lag in poor network
mysql_repl_mixed.jpg
@nay-kang
nay-kang / init_R9000P.md
Last active June 3, 2021 07:09
init r9000p ASAP Legion 5pro with ubuntu

__next time during install set swap for larger

install ubuntu 21.04(newest release of ubuntu) instead of ubuntu 20.04LTS.
because Linux alwasy lack support of new hardware such as graphic card or wireless or card reader

but none LTS ubuntu desktop also has lots of bugs.

after system installed.install nvidia driver from addiontional drivers.at this moment Nouveau only support GTX10X0 series.
you shoudl also disable UEFI security boot.because while install proprietary software UEFI need MOK.but In 21.04 the MOK can't response the keyboard.