Skip to content

Instantly share code, notes, and snippets.

View zenofile's full-sized avatar

zenofile zenofile

View GitHub Profile
@zenofile
zenofile / txq.bt
Created May 22, 2021 02:33 — forked from talawahtech/txq.bt
txq.bt - monitor the length of an AWS ENA device's transmit queue
#include "txq.h"
kprobe:ena_com_prepare_tx
{
// grab/cast the transmit queue param
$io_sq = (struct ena_com_io_sq *) arg0;
// logic copied from from ena_com_free_q_entries
$queuelen = (uint16) $io_sq->tail - (uint16) $io_sq->next_to_comp;
AWSTemplateFormatVersion: '2010-09-09'
Description: Extreme Performance Tuning Benchmark Environment
Parameters:
AmiId:
Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
Default: '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2'
@zenofile
zenofile / systemd_service_hardening.md
Created May 14, 2021 21:32 — forked from ageis/systemd_service_hardening.md
Options for hardening systemd service units

security and hardening options for systemd service units

A common and reliable pattern in service unit files is thus:

NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
DevicePolicy=closed
ProtectSystem=strict
@zenofile
zenofile / script-template.sh
Created December 16, 2020 18:37 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@zenofile
zenofile / wg-netns
Last active May 3, 2024 16:55
wg-quick like script with namespace support
#!/usr/bin/bash
# configuration matches the wg-quick specifications
# manual invocation:
# $ sudo wg-netns vpn-1
# via systemd:
# $ sudo systemctl start [email protected]
# examples:

Foreward

This document was originally written several years ago. At the time I was working as an execution core verification engineer at Arm. The following points are coloured heavily by working in and around the execution cores of various processors. Apply a pinch of salt; points contain varying degrees of opinion.

It is still my opinion that RISC-V could be much better designed; though I will also say that if I was building a 32 or 64-bit CPU today I'd likely implement the architecture to benefit from the existing tooling.

Mostly based upon the RISC-V ISA spec v2.0. Some updates have been made for v2.2

Original Foreword: Some Opinion

The RISC-V ISA has pursued minimalism to a fault. There is a large emphasis on minimizing instruction count, normalizing encoding, etc. This pursuit of minimalism has resulted in false orthogonalities (such as reusing the same instruction for branches, calls and returns) and a requirement for superfluous instructions which impacts code density both in terms of size and

@zenofile
zenofile / opustrackno.sh
Created October 14, 2020 19:44
Write opus track metadata extracted from filename
#!/usr/bin/env bash
trim() {
local var="$*"
# remove leading whitespace characters
var="${var#"${var%%[![:space:]]*}"}"
# remove trailing whitespace characters
var="${var%"${var##*[![:space:]]}"}"
printf '%s' "$var"
}
@zenofile
zenofile / github2Gitea.js
Created October 9, 2020 16:59 — forked from lrecknagel/github2Gitea.js
a small nodejs module to migrate a list of github repos (FROM A ORGANIZATION) to gitea
const fetch = require('node-fetch'),
FormData = require('form-data');
// your gitea domain without trailing slash
const GITEA_DOMAIN = 'https://subdomain.domain.xyz';
// you can find this variables when you visit your gitea installation
// open dev-tools and look in the Cookies section
const i_like_gitea = 'YOUR_I_LIKE_GITEA_STRING';
const gitea_awesome = 'YOUR_GITEA_AWESOME_STRING';
@zenofile
zenofile / mono_gain_compress_audio.js
Created September 30, 2020 00:53
Improve videos with bad audio (too quiet or loud, one channel stereo, ..)
(function() {
let ctx = new AudioContext();
let gain = ctx.createGain();
let cmpr = ctx.createDynamicsCompressor();
let src = ctx.createMediaElementSource(document.getElementsByTagName("video")[0]);
ctx.destination.channelCount = 1;
let ts = ctx.currentTime;
gain.gain.setValueAtTime(6, ts);
@zenofile
zenofile / mix_playlist.js
Created September 30, 2020 00:47
Extract video URLs from YouTube's dynamic mix playlists
var parse = (list) => {
const vp = /(?:youtube\.com.*(?:\?|&)(?:v)=|youtube\.com.*embed\/|youtube\.com.*v\/|youtu\.be\/)((?!videoseries)[a-zA-Z0-9_-]*)/;
const dl = Array.from(document.querySelectorAll(`a[href*="list=${list}"]`), e => e.href.match(vp)[1]);
return dl.filter((v, i, a) => a.indexOf(v) === i).map(e => `https://youtube.com/watch?v=${e}`);
};
var dl = (() => {
let a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";