Skip to content

Instantly share code, notes, and snippets.

View photoszzt's full-sized avatar
💭
I may be slow to respond.

Zhiting Zhu photoszzt

💭
I may be slow to respond.
View GitHub Profile
@mofosyne
mofosyne / circularBuffer_uint8.h
Last active June 12, 2023 16:00
Circular Byte Buffer For Embedded Applications (Index Based)
// # Circular Byte Buffer For Embedded Applications (Index Based)
// Author: Brian Khuu (July 2020) (briankhuu.com) (mofosyne@gmail.com)
// Reason: Malloc free, minimum overhead implementation of a circular buffer.
// Static inlined handlers for speed and ease of usage in various projects.
// Index based implementation diverges from harshkn's version, since it is
// easier for me to grok. However may come at cost of speed and optimisation.
// Also uses byte based rather than item based for easier understability
// when used for simpler byte array circular buffers.
// I have also written an pointer based circular buffer version.
// Based on harshkn's circular buffer: https://gist.github.com/harshkn/909546
@marcov
marcov / qemu-and-kata.md
Last active March 8, 2021 04:17
Running QEMU from CLI with Kata kernel & images

Notes

Memory backend file

  • Question: on x86 qemu is configured to boot the rootfs from nvdimm, with memory backend file the kata rootfs image. What's preventing the image file from being modified, since the file system is mounted rw?
  • Answer: that is because with memory backend file, "share=on/off" qemu option controls the visibility of guest writes. If share=on, then guest writes will be applied to the backend file.
@sonictk
sonictk / CMakeLists.txt
Created August 30, 2018 22:40
cmake target compile options
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# using GCC
set(CMAKE_VERBOSE_MAKEFILE 1)
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_DEFINITIONS "Bits64_;UNIX;_BOOL;LINUX;FUNCPROTO;_GNU_SOURCE;LINUX_64;REQUIRE_IOSTREAM")
set(GCC_COMPILE_OPTIONS "-m64;-fPIC;-fno-strict-aliasing;-Wall;-Wno-multichar;-Wno-comment;-Wno-sign-compare;-funsigned-char;-pthread;-Wno-deprecated;-Wno-reorder;-ftemplate-depth-64;-fno-gnu-keywords;-std=c++0x;-Winline")
set(GCC_COMPILE_DEBUG_OPTIONS "${GCC_COMPILE_OPTIONS};-ggdb;-O0")
@mcastelino
mcastelino / tc mirroring.md
Last active December 11, 2023 02:16
Using tc redirect to connect a virtual machine to a container network

Connecting a veth device to tap

  • veth device from CNI/CNM plugin: eth0
  • tap device that connects to the VM: tap0

Redirecting traffic between the two devices

tc qdisc add dev eth0 ingress
tc filter add dev eth0 parent ffff: protocol all u32 match u8 0 0 action mirred egress redirect dev tap0
@mmellison
mmellison / grpc_asyncio.py
Last active April 3, 2024 15:48
gRPC Servicer with Asyncio (Python 3.6+)
import asyncio
from concurrent import futures
import functools
import inspect
import threading
from grpc import _server
def _loop_mgr(loop: asyncio.AbstractEventLoop):
@yamnikov-oleg
yamnikov-oleg / LICENSE
Last active May 9, 2024 04:56
Shared (interprocess) mutexes on Linux
MIT License
Copyright (c) 2018 Oleg Yamnikov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@PolarNick239
PolarNick239 / rgb_to_hsv_np.py
Last active January 14, 2023 10:48
numpy RGB to HSV
#
# Copyright (c) 2016, Nikolay Polyarnyi
# All rights reserved.
#
import numpy as np
def rgb_to_hsv(rgb):
"""
@iamtekeste
iamtekeste / Download Google Drive files with WGET
Created July 8, 2015 11:00
Download Google Drive files with WGET
Download Google Drive files with WGET
Example Google Drive download link:
https://docs.google.com/open?id=[ID]
To download the file with WGET you need to use this link:
https://googledrive.com/host/[ID]
Example WGET command: