Skip to content

Instantly share code, notes, and snippets.

View rikka0w0's full-sized avatar

Rikka0_0小六花 rikka0w0

  • UNSW
  • Sydney
View GitHub Profile
@rikka0w0
rikka0w0 / revert.reg
Last active December 8, 2020 16:15
Add WSL root to Network folder in Win10
Windows Registry Editor Version 5.00
[-HKEY_CLASSES_ROOT\CLSID\{90818ab5-0f00-487c-8570-a16feb94cd61}]
[-HKEY_CLASSES_ROOT\WOW6432Node\CLSID\{90818ab5-0f00-487c-8570-a16feb94cd61}]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\NetworkNeighborhood\NameSpace\{90818ab5-0f00-487c-8570-a16feb94cd61}]
[-HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\NetworkNeighborhood\NameSpace\{90818ab5-0f00-487c-8570-a16feb94cd61}]
@rikka0w0
rikka0w0 / ipv6_fix_lan.md
Last active September 12, 2020 18:07
Fix the IPv6 ULA(LAN) address

Enable IPv6 DHCP client

  1. Edit /etc/network/interfaces, change or append: iface ??? inet6 dhcp where ??? is your interface name, e.g. eth0 or enp12s0, and then reboot.

Find your current DUID

The DUID is used by the router to assign ULA(LAN) ipv6 addresses to clients, similar to how ipv4 DHCP server assign ipv4 addresses based on MAC. To find out your current DUID, follow these steps:

  1. Run cat /var/lib/dhcp/dhclient6.???.leases | grep default-duid, replace ??? with the name of your network interface, e.g. eth0 or enp12s0.
  2. Copy the output from the previous command, remove the default-duid prefix and the tailing ;. Use the remaining string for the next command.
  3. Run printf "???" | hexdump -e '14/1 "%02x " "\n"' | sed 's/ /:/g', the output is your current DUID in human-readable form.

Set your DUID to a fixed or known value

@rikka0w0
rikka0w0 / stm32f030f4_config_store.c
Last active August 3, 2020 17:22
This snippet demonstrates how to change the initail value of a global variable in STM32
#define FLASH_START_ADDR 0x08000000
#define FLASH_PAGE_SIZE 0x400 // stm32f0xx_hal_flash_ex.h may have defined this.
// Warning: Other stm32 device might have difference page size!!!
#define FLASH_PAGE_BUFCNT (FLASH_PAGE_SIZE / sizeof(uint32_t)) // Number of 32bit ints within the buffer
static uint32_t flash_page_buff[FLASH_PAGE_BUFCNT];
// config_addr is a pointer to a 32bit GLOBAL variable, val is the new initial value.
// This function does not change the current value of the variable.
// The initial value will be loaded to the target variable upon next reset.
@rikka0w0
rikka0w0 / forgegradle1.7.10_2020.md
Created August 1, 2020 00:56
Setup MinecraftForge mod development environment in 2020
@rikka0w0
rikka0w0 / MixinModelLoader.java
Last active August 10, 2020 14:13
MixinModelLoader
// 1.14.4 -> 1.16.1
// ISprite -> IModelTransform
// IModelState -> IForgeModelTransform
// ITransformation -> IForgeTransformationMatrix
@Mixin(value = ModelLoader.class)
public abstract class MixinModelLoader implements ForgeModelLoader {
@Inject(method = "bake", at = @At("HEAD"))
public void qwwq(CallbackInfoReturnable ci) {
return;
@rikka0w0
rikka0w0 / vnc_xvfb.sh
Created July 7, 2020 19:33
Start a vnc server on a Termux Debian chroot
# apt install -y Xvfb x11vnc
export DISPLAY=:0
Xvfb $DISPLAY -screen 0 1024x768x16 &
startxfce4 &
x11vnc -display $DISPLAY -nopw -forever -loop -noxdamage -repeat -rfbport 5900 -shared -noshm
@rikka0w0
rikka0w0 / openwrt.ipxe
Created July 7, 2020 17:01
An iPEX menu for openwrt box with extension support
#!ipxe
# dhcp
set advanced-server 192.168.9.9
set advanced-menu tftp://${advanced-server}/main.ipxe
# Some menu defaults
set menu-timeout 10000
set submenu-timeout ${menu-timeout}
set menu-default ubuntu1804_live
@rikka0w0
rikka0w0 / IModelLoader_1144_1161.md
Last active July 2, 2020 17:45
Forge 1.14.4 new IModelLoader vs its 1.16.1 updated version

IModelGeometry:

  1. Collection<ResourceLocation> getTextureDependencies -> Collection<RenderMaterial> getTextures
  2. SRGRenderMaterial = Atlas Id + Texture Location = YRNSpriteIdentifier
  3. SRGTextureAtlasSprite = YRNSprite
  4. SRGISprite in 1.14.4 = YRNModelBakeSettings = SRGIModelTransform in 1.16.1

1.16.1 IModelGeometry:

public interface IModelGeometry<T extends IModelGeometry<T>>
{
@rikka0w0
rikka0w0 / neighbor_ipv6_from_mac.sh
Created June 26, 2020 11:52
[Linux] Get neighbor's IPv6 Address by MAC address
# Replace MACADDRESS with the Mac address of your target:
/sbin/ip neighbor | grep MACADDRESS | grep -v -e "192.168" -e "fe80" | cut -d' ' -f1
@rikka0w0
rikka0w0 / update_iptables.sh
Created May 21, 2020 16:12
Add/Update iptable forwading rule with hostnames
#!/bin/bash
# Usage:
# Add/Update: ./update_iptables.sh <port_listen> (tcp|udp) <hostname>:<port>
# Delete: ./update_iptables.sh <port_listen> (tcp|udp) :<port>
PortListen=$1
Protocol=$2
HostName=${3%:*}
PortTarget=${3#*:}