Skip to content

Instantly share code, notes, and snippets.

@BCadet
BCadet / replace_filename.sh
Last active May 2, 2022 09:58
Bash command to rename files recursively
#/bin/bash
find . -name 'orig*' -type f -exec bash -c 'mv "$1" "${1/\/orig_/\/new_}"' -- {} \;
@BCadet
BCadet / USBRelays.py
Last active February 10, 2024 20:09
simple python driver to communicate with USB relay module. It handles several versions with differents numbers of relays
import serial
import argparse
import logging
class USBRelays():
class Relay():
index = ...
header = 0xA0
def __init__(self, index, log):
self.index = index+1
@BCadet
BCadet / openocd-basics.md
Last active June 13, 2022 14:34
basic openocd infos to debug/flash ARM devices

OPENOCD BASICS

download openocd

windows

You can download openocd from the official github mirror Release page This relase does not require admin access to be used. Everything is already compiled and run from inside the folder.

linux

You can install from APT or from sources. That's a lot easier !

@BCadet
BCadet / cmake-cross-compilation-windows.md
Created June 15, 2022 16:05
cross-compilation with CMake tutorial on Windows

Cross-compile on Windows with CMake

Prerequire

  • PC on Windows 10
  • Basic understanding of CMake

Install of MSYS2

MSYS2 is a collection of tools and libraries providing you with an easy-to-use environment for building, installing and running native Windows software.

@BCadet
BCadet / container-entrypoint
Last active August 1, 2022 13:23
mixed version of the kas-container entrypoint and vscode devcontainer to start bash or execute a random bash command as any user
#!/bin/bash
REMOTE_USER=${REMOTE_USER:="builder"}
NEW_UID=${NEW_UID:=1000}
NEW_GID=${NEW_GID:=1000}
eval "$(sed -n "s/${REMOTE_USER}:[^:]*:\([^:]*\):\([^:]*\):[^:]*:\([^:]*\).*/OLD_UID=\1;OLD_GID=\2;HOME_FOLDER=\3/p" /etc/passwd); "
eval $(sed -n "s/\([^:]*\):[^:]*:${NEW_UID}:.*/EXISTING_USER=\1/p" /etc/passwd);
eval $(sed -n "s/\([^:]*\):[^:]*:${NEW_GID}:.*/EXISTING_GROUP=\1/p" /etc/group);
GOSU=""
@BCadet
BCadet / vscode-devcontaier-on-server.md
Created July 4, 2022 11:50
Make VSCode devcontainer works on a machine with multiple users

github issue

Problem

When multiple users try to user VSCode devcontainer on a remote server, some files are initialized in the /tmp path with the user ownership.
When a second user tries to user VSCode remote server, he's stuck on an ACCESS DENIED error in these folders.

Workaround

Each user shall create a folder with his username in /tmp and export in his .bashrc the variable TMPDIR=/tmp/$USER.

@BCadet
BCadet / getScriptPath.bash
Created August 1, 2022 07:47
get absolute path of a script
#! /bin/bash
SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
@BCadet
BCadet / .udev_rules
Last active July 7, 2023 12:22
U-dev rules
UDEV rules
@BCadet
BCadet / petalinux-accept-eula.sh
Created August 8, 2022 12:55
petalinux eula acceptation script
#!/usr/bin/expect
set installer [lindex $argv 0]
set install_args [lindex $argv 1]
spawn $installer $install_args
set timeout -1
expect {
"Press Enter to display the license agreements" { send "\r"; exp_continue}
"(press RETURN)" {send "\r"; sleep 1; send "q"; exp_continue}
@BCadet
BCadet / xilinx_autoGenToken.sh
Created August 19, 2022 12:33
auto generate xilinx authentication token with expect
#!/usr/bin/expect
set installer [lindex $argv 0]
set email [lindex $argv 1]
set password [lindex $argv 2]
spawn $installer -b AuthTokenGen
set timeout -1
set ret 0
expect {