Skip to content

Instantly share code, notes, and snippets.

View EHfive's full-sized avatar

Bao, Huang-Huang EHfive

  • Suzhou, China
View GitHub Profile
@EHfive
EHfive / container_of.rs
Last active August 28, 2023 17:59
Rust offset_of!() and container_of!() macros utilizing core::ptr::addr_of!()
/**
* Macros
*/
macro_rules! offset_of {
($Container:ty, $($fields:tt).+) => {{
// avoid dereferencing null pointer
let container = ::core::mem::align_of::<$Container>() as *const $Container;
let member = ::core::ptr::addr_of!((*container).$($fields).+);
member.cast::<u8>().offset_from(container.cast::<u8>()) as usize
}};
@EHfive
EHfive / pw-conf-diff.sh
Last active February 3, 2023 01:56
PipeWire config diff, a helper script for syncing PipeWire config changes from '/usr/share/pipewire' to '/etc/pipewire' or "$XDG_CONFIG_HOME/pipewire"
#!/usr/bin/env bash
DIFFPROG="${DIFFPROG:-vimdiff}"
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-"$HOME/.config"}"
pw_datadir=/usr/share/pipewire
pw_confdir="/etc/pipewire"
#pw_confdir="$XDG_CONFIG_HOME/pipewire"
@EHfive
EHfive / mastodon-emoji-scaling.css
Last active September 4, 2020 11:30
Custom CSS for EHfive's Mastodon instance (https://mstdn.eh5.me)
/* START mastodon emoji scaling by @[email protected] */
.account__header__content,
.reply-indicator__content,
.status__content:not(.status__content--collapsed) {
overflow: unset;
}
.account__header__content .emojione,
.reply-indicator__content .emojione,
.status__content:not(.status__content--collapsed) .emojione {

Keybase proof

I hereby claim:

  • I am ehfive on github.
  • I am eh5 (https://keybase.io/eh5) on keybase.
  • I have a public key ASAUyeUtjxJDMzKXgcgAI5L_h2VdZ1INC1oCPD-P4UqDYwo

To claim this, I am signing this object:

@EHfive
EHfive / Blogment_CLA.md
Last active May 20, 2020 15:20 — forked from CLAassistant/SAP_CLA
Blogment Individual Contributor License Agreement

Blogment Individual Contributor License Agreement

Thank you for your interest in contributing to open source software projects (“Blogment”) made available by Blogment IO or its affiliates (“Blogment IO”). This Individual Contributor License Agreement (“Agreement”) sets out the terms governing any source code, object code, bug fixes, configuration changes, tools, specifications, documentation, data, materials, feedback, information or other works of authorship that you submit or have submitted, in any form and in any manner, to Blogment IO in respect of any of the Projects (collectively “Contributions”). If you have any questions respecting this Agreement, please contact [email protected].

You agree that the following terms apply to all of your past, present and future Contributions. Except for the licenses granted in this Agreement, you retain all of your right, title and interest in and to your Contributions.

Copyright License. You hereby grant, and agree to grant, to Blogment IO a non-exclusive

@EHfive
EHfive / PKGBUILD
Last active November 8, 2021 05:40
给VLC打补丁, 使flac网络文件/流的Content-Type始终为"audio/flac", 以"修复"网易云音乐获取的flac网络文件Content-Type为"audio/mpeg"而导致VLC不能正确识别文件而播放失败的问题
_pkgname=vlc
pkgname=vlc-ncm
_vlcver=3.0.12
# optional fixup version including hyphen
_vlcfixupver=
pkgver=${_vlcver}${_vlcfixupver//-/.r}
pkgrel=1
pkgdesc='Multi-platform MPEG, VCD/DVD, and DivX player'
url='https://www.videolan.org/vlc/'
arch=('x86_64')
#!/usr/bin/env python2
## From bluez (GPL2)
import dbus
SERVICE_NAME = "org.bluez"
ADAPTER_INTERFACE = SERVICE_NAME + ".Adapter1"
DEVICE_INTERFACE = SERVICE_NAME + ".Device1"
# /etc/udev/rules.d/20-bt-auto-enable-a2dp.rules
# hxss
SUBSYSTEM=="bluetooth", ACTION=="add", RUN+="/home/replace-it/bt-auto-enable-a2dp.sh"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Get user_json from LLproxy</title>
</head>
<body>
<script>
function Jump2MainPage() {
location = "https://llsifteambuilder.herokuapp.com/build_team/"