Skip to content

Instantly share code, notes, and snippets.

View muhamadazmy's full-sized avatar

Muhamad Awad muhamadazmy

View GitHub Profile
@muhamadazmy
muhamadazmy / customer_encoder.rs
Last active May 12, 2025 14:03
Bilrost Custom Encoder
use std::ops::RangeInclusive;
use bilrost::{Message, OwnedMessage};
use bytes::Bytes;
#[derive(bilrost::Message)]
struct Container {
inner: Inner,
}
@muhamadazmy
muhamadazmy / bilrost_foreign_type.rs
Created May 12, 2025 10:12
Implement a custom encoder for a foreign type
use std::ops::RangeInclusive;
use bilrost::{
buf::ReverseBuf,
encoding::{
Capped, DecodeContext, Decoder, EmptyState, Encoder, ForOverwrite, General, TagMeasurer,
TagRevWriter, TagWriter, WireType, Wiretyped,
},
DecodeError, Message, OwnedMessage,
};
@muhamadazmy
muhamadazmy / docker-compose.yml
Created January 28, 2025 12:59
Restate test env compose file
x-environment: &default-env
RESTATE_ALLOW_BOOTSTRAP: "false"
RESTATE_CLUSTER_NAME: "test-cluster"
RESTATE_ROLES: '["admin","worker","log-server","metadata-store"]'
RESTATE_METADATA_STORE__TYPE: "raft"
RESTATE_METADATA_STORE_CLIENT__ADDRESSES: '["http://node-1:5122","http://node-2:5122","http://node-3:5122"]'
x-variables:
common_settings: &common_settings
image: localhost/restatedev/restate:unknown
@muhamadazmy
muhamadazmy / volstat.sh
Created April 4, 2024 08:39
Script to print size and available space on a subvol quota
#!/bin/sh
# this script is called as `volstat.sh <path/to/subvol>`
set -e
vol=$1
id=$(btrfs subvol show $vol | grep 'Subvolume ID:'| cut -f 4)
output=$(btrfs qgroup show --raw -r $vol| grep "^0/$id")
size=$(echo $output | cut -d ' ' -f 4)
@muhamadazmy
muhamadazmy / debug-image.sh
Last active March 11, 2024 13:40
Test a bootable tarball with cloud-hypervisor
#!env bash
socket="/tmp/virtiofs.sock"
# override this as well if u wanna change
# the vm entry point
init=/sbin/init
# pass to extracted tarball
dir=$1
@muhamadazmy
muhamadazmy / extract-image.sh
Created February 23, 2023 15:56
Extract a docker image into a directory, does not require a container
set -e
# you need to run `docker save <image> -o <file>.tar
# then run this script like `extrat-image.sh <file>.tar`
# it will create a directoyr `<file>.tar-root` which containers
# all files from the image extracted
input=$1
if [ ! -f "${input}" ]; then
echo "file does not exist"
use std::collections::HashMap;
struct Module;
struct Data {
modules: HashMap<String, Module>,
}
impl Data {
fn module<S: AsRef<str>>(&mut self, name: S) -> &mut Module {
if let Some(m) = self.modules.get_mut(name.as_ref()) {
@muhamadazmy
muhamadazmy / bluetoosh.sh
Created December 10, 2019 10:19
Fix bluetooth annoying issue on linux
#!env sh
set -e
sudo systemctl stop bluetooth
sudo modprobe -r btusb btrtl btbcm btintel
sudo modprobe btusb
sudo systemctl start bluetooth
pulseaudio -k
sleep 1s
bluetoothctl power on
@muhamadazmy
muhamadazmy / updatemirrors.sh
Created August 27, 2019 08:38
Update arch linux mirrors
#!env sh
# this file depends on rankmirrors package
tmp=$(mktemp)
trap "rm -f ${tmp}" EXIT
curl "https://www.archlinux.org/mirrorlist/?country=BE&country=FR&country=DE&country=IL&protocol=http&protocol=https&ip_version=4&use_mirror_status=on" | sed "s/#Server/Server/g" > $tmp
rankmirrors ${tmp} | sudo tee /etc/pacman.d/mirrorlist
@muhamadazmy
muhamadazmy / msgpack-go-rust-compatibility.md
Created August 7, 2019 13:04
Test msgpack compatibility accross go and rust.

Quick test for msgpack compatibility

The code below (data encoded in Go) and then decoded in Rust. works fine.

Rust decoder

extern crate rmp_serde as rmps;
extern crate serde;

#[macro_use]
extern crate serde_derive;