Skip to content

Instantly share code, notes, and snippets.

View cathay4t's full-sized avatar
🏡

Gris Ge cathay4t

🏡
View GitHub Profile
[logging]
level=TRACE
domains=ALL
Finished dev [unoptimized + debuginfo] target(s) in 0.11s
Running `sudo -E target/debug/npc -vvvv`
[2022-03-19T01:34:11Z DEBUG netlink_proto::handle] handle: forwarding new request to connection
[2022-03-19T01:34:11Z DEBUG netlink_proto::connection] reading incoming messages
[2022-03-19T01:34:11Z DEBUG netlink_proto::codecs] NetlinkCodec: decoding next message
[2022-03-19T01:34:11Z DEBUG netlink_proto::connection] forwarding unsolicited messages to the connection handle
[2022-03-19T01:34:11Z DEBUG netlink_proto::connection] forwaring responses to previous requests to the connection handle
[2022-03-19T01:34:11Z DEBUG netlink_proto::connection] handling requests
[2022-03-19T01:34:11Z DEBUG netlink_proto::connection] sending messages
[2022-03-19T01:34:11Z DEBUG netlink_proto::connection] reading incoming messages
#!/usr/bin/python3
"""
To use this script, you create ~/.config/token.conf with stuff like:
[default]
# comments
key = "SOME_32_CHARS"
[github]
#!/bin/bash
ip link add blue type vrf table 10
ip link add red type vrf table 20
ip netns add ns_pod1
ip netns add ns_pod2
ip link add veth_pod1 type veth peer net1
ip link add veth_pod2 type veth peer net2
#!/bin/bash
# Enable wayland in firefox
export MOZ_ENABLE_WAYLAND=1
export XDG_SESSION_TYPE=wayland
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS="@im=fcitx"
export EDITOR="vim"
@cathay4t
cathay4t / interview_rust.rs
Created March 24, 2021 06:54
interview_rust.rs
struct VlanInfo {
base_iface: String,
vlan_id: u16,
}
struct Iface {
name: String,
vlan_info: Option<VlanInfo>,
}
@cathay4t
cathay4t / vrf_test_report.md
Created November 30, 2020 05:52
Test report on VRF

Network Layout

     ns_pod1                                              ns_srv1
    veth_pod1    veth_pod1_ep            veth_srv1_ep    veth_srv1
                    |----------- vrf1 --------|
 192.168.0.1/24  192.168.0.2/24           10.0.0.2/24     10.0.0.1/24


 ns_pod2 ns_srv2
@cathay4t
cathay4t / query_dns_nameserver.py
Last active August 19, 2020 08:35
Using glibc `res_ninit()` to query DNS name servers and searches
#!/usr/bin/python3
# Copyright 2020 Red Hat
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#!/usr/bin/python3
NSEC_PER_SEC = 10 ** 9
MAX_U64 = 2 ** 64
def jiffies_to_clock_t(user_hz, hz, jiffies):
tick_nsec = (NSEC_PER_SEC + hz / 2) / hz
if (tick_nsec % (NSEC_PER_SEC / user_hz)) == 0:
if hz < user_hz: