Skip to content

Instantly share code, notes, and snippets.

View ReimuNotMoe's full-sized avatar
🔥
l'épuisement professionnel

Reimu NotMoe ReimuNotMoe

🔥
l'épuisement professionnel
  • The Big Scary Country
  • 13:57 (UTC +08:00)
View GitHub Profile
rp2350-arm-s
2K performance run parameters for coremark.
CoreMark Size : 666
Total ticks : 13479687
Total time (secs): 13.479687
Iterations/Sec : 445.114193
Iterations : 6000
Compiler version : GCC13.2.1 20231009
Compiler flags : -O3 -Wall -Wextra
Memory location : STACK
@KoneLinx
KoneLinx / rng.cpp
Created August 21, 2021 11:31
A simple compile time random number generator for C++. (uses std::rotl (C++20), but can be easily replaced if needed)
constexpr uint32_t hash(uint32_t in)
{
constexpr uint32_t r[]{
0xdf15236c, 0x16d16793, 0x3a697614, 0xe0fe08e4,
0xa3a53275, 0xccc10ff9, 0xb92fae55, 0xecf491de,
0x36e86773, 0x0ed24a6a, 0xd7153d80, 0x84adf386,
0x17110e76, 0x6d411a6a, 0xcbd41fed, 0x4b1d6b30
};
uint32_t out{ in ^ r[in & 0xF] };
out ^= std::rotl(in, 020) ^ r[(in >> 010) & 0xF];
@xiongyihui
xiongyihui / usb-composite.sh
Last active December 11, 2024 09:43
Linux USB Gadget - UAC & HID
#!/bin/bash
modprobe libcomposite
mkdir -p /sys/kernel/config/usb_gadget/g
echo 0x1d6b > /sys/kernel/config/usb_gadget/g/idVendor # Linux Foundation
echo 0x0104 > /sys/kernel/config/usb_gadget/g/idProduct # Multifunction Composite Gadget
echo 0x0100 > /sys/kernel/config/usb_gadget/g/bcdDevice # v1.0.0
echo 0x0200 > /sys/kernel/config/usb_gadget/g/bcdUSB # USB 2.0
echo 0xef > /sys/kernel/config/usb_gadget/g/bDeviceClass # USB 2.0
echo 0x02 > /sys/kernel/config/usb_gadget/g/bDeviceSubClass # USB 2.0
@MawKKe
MawKKe / cryptsetup-with-luks2-and-integrity-demo.sh
Last active May 9, 2025 14:16
dm-crypt + dm-integrity + dm-raid = awesome!
#!/usr/bin/env bash
#
# Author: Markus (MawKKe) [email protected]
# Date: 2018-03-19
#
#
# What?
#
# Linux dm-crypt + dm-integrity + dm-raid (RAID1)
#
size_t memcount_avx2(const void *s, int c, size_t n) {
__m256i cv = _mm256_set1_epi8(c), zv = _mm256_setzero_si256(), sum = zv, acr0,acr1,acr2,acr3;
const char *p,*pe;
for(p = s; p != (char *)s+(n- (n % (252*32)));) {
for(acr0 = acr1 = acr2 = acr3 = zv,pe = p+252*32; p != pe; p += 128) {
acr0 = _mm256_add_epi8(acr0, _mm256_cmpeq_epi8(cv, _mm256_lddqu_si256((const __m256i *)p)));
acr1 = _mm256_add_epi8(acr1, _mm256_cmpeq_epi8(cv, _mm256_lddqu_si256((const __m256i *)(p+32))));
acr2 = _mm256_add_epi8(acr2, _mm256_cmpeq_epi8(cv, _mm256_lddqu_si256((const __m256i *)(p+64))));
acr3 = _mm256_add_epi8(acr3, _mm256_cmpeq_epi8(cv, _mm256_lddqu_si256((const __m256i *)(p+96)))); __builtin_prefetch(p+1024);
}
@Changaco
Changaco / btrfs-undelete
Last active May 27, 2025 03:19
btrfs-undelete
#!/bin/bash
# btrfs-undelete
# Copyright (C) 2013 Jörg Walter <[email protected]>
# This program is free software; you can redistribute it and/or modify it under
# the term of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or any later version.
if [ ! -b "$1" -o -z "$2" -o -z "$3" ]; then
echo "Usage: $0 <dev> <file/dir> <dest>" 1>&2
echo
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>URL</key>
<string>http://init.ess.apple.com/WebObjects/VCInit.woa/wa/getBag?ix=4</string>
<key>CachedBag</key>
<dict>
<key>gk-p2p-post-connectivity-check</key>
<true />
@toroidal-code
toroidal-code / pacat.c
Created February 4, 2014 05:54
PulseAudio example with callbacks
/***
This file is part of PulseAudio.
Copyright 2004-2006 Lennart Poettering
Copyright 2006 Pierre Ossman <[email protected]> for Cendio AB
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License,
or (at your option) any later version.