Skip to content

Instantly share code, notes, and snippets.

View felipet's full-sized avatar

Felipe Torres González felipet

View GitHub Profile
@felipet
felipet / tracing_for_tests.rs
Created December 30, 2025 09:23
A simple code snippet in Rust to add tracing support for test code.
// Simple code snippet for adding tracing to the tests of a code that already makes use of the
// tracing crate.
// To enable the tracing output, call the test using `RUST_LOG`.
// `RUST_LOG=info cargo test`
// `RUST_LOG=mycrate=info cargo test`
// Required deps:
// tracing = "0.1.41"
// tracing-subscriber = { version = "0.3.20", features = ["env-filter"] }
// once_cell = "1.21.3"
@felipet
felipet / pre-commit
Created February 15, 2024 10:20
Rust pre-commit hook
#!/bin/env bash
# pre-commit hook that checks all the cached modifications are compliant
# with the style rules of a typical Rust repository.
# How to use it:
# Within your repository, cd .git/hooks
# Create a new pre-commit file and paste the content from here.
# You can also use (part of) the sample pre-commit hook, and add this chunk.
# Finally, don't forget to add execution permissions to the file.
activate_rtlmake() {
venv_path=$HOME/.local/venv/rtl-make
# If the environment variable is not defined, set it to the default version.
if [ -z $RTLMAKE ]; then
RTLMAKE="0.5.0"
fi
case $RTLMAKE in
"0.5.0" | "0.3.0")
@felipet
felipet / serialtester.bash
Created March 26, 2019 08:03
How to detect wich serial port has something attached
# First we can see wich serial ports are initializated by the kernel
sudo dmesg | grep ttyS
read -s "Press to continue..." forgetme
# When you connect a serial port, a positive voltage should be detected by the driver
sudo cat /proc/tty/driver/serial> /tmp/1
read -s "Connect the device and press..." forgetme
sudo cat /proc/tty/driver/serial> /tmp/2
diff /tmp/1 /tmp/2
@felipet
felipet / gist:e3d0c3ef0011c6ee7ea051336baad89b
Created November 7, 2018 14:05
Bash function to handle the Vivado environment. Include it in the .bashrc file.
vivado_vars()
{
xil_path=/opt/Xilinx/Vivado # Change that to point to your Vivado installation
export XILINXD_LICENSE_FILE=<put here the path if a floating license is needed, comment out if not>
case $1 in
18)
ver=18.2;;
16)
ver=16.4;;
17)
@felipet
felipet / easysync
Created October 26, 2018 08:39
Rsync script to synchronize files between VHDL projects (local to server) to compile in a server
#!/usr/bin/env bash
user=felipe
server=10.0.4.101
serverpath=/home/felipe/workspace
if [ "x"$1 = "x" ];then
echo -e "Usage: easysync <folder> [<options>]"
return -1
fi