Skip to content

Instantly share code, notes, and snippets.

View xmacro-example.c
#include <stdint.h>
#include <stdbool.h>
#define OSC_DETECT_INDEX_L11 0
#define OSC_DETECT_INDEX_L13 1
#define OSC_DETECT_INDEX_L21 2
#define OSC_DETECT_INDEX_L23 3
#define OSC_DETECT_INDEX_L31 4
#define OSC_DETECT_INDEX_L33 5
#define OSC_DETECT_INDEX_L41 6
rogersguedes /
Created Dec 14, 2020
STM32 G.P. Timer Prescaler and Period Calc
#!/usr/bin/env python
#counts = (prescaler + 1)*(period + 1)
source ${HOME}/.bashrc_rogers
echo "Initial IP: ${LAST_IP}"
rogersguedes /
Created Sep 10, 2020 — forked from WiBla/
Add YouTube videos to without having to search them.

What is this?

It's a script (think of it as mod) for which will allow you to add YT (YouTube) videos to your playlists with one button.

Why is this necessary? is having some trouble with their YT API Key (the thing that allows you to make YT related actions throughout the site, like searching for a song and adding the results to your playlists). Using this script, you will be able to add YT videos to your playlists again, even while is dealing with YouTube's support to get this issue fixed.

How to use

rogersguedes /
Created Aug 12, 2020
check if each protobuf definition file contains only one definition and its name is same on file name.
find src/ -type f -name *.proto |
while read filePath; do
# do something with the file
fileName=`basename ${filePath}`
echo -n "### checking ${fileName}: "
foundDefs=`grep "message\s\+[a-zA-Z0-9\-\_]\+.*" ${filePath} | sed "s/\s*message\s\+\([a-zA-Z0-9\-\_]\+\).*/\1/"`
if [ -n "${foundDefs}" ]; then
rogersguedes /
Created Jun 22, 2020 — forked from spalladino/
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
View usbreset.c
/* usbreset -- send a USB port reset to a USB device */
* usage `./usbreset /dev/bus/usb/<bus-number>/<device-number>`
* use `lsusb` to get <bus-number> and <device-number>.
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
View ACS712-example.ino
float watt_average = 0;
float measuredvalue = 0;
float measuredvalue1 = 0;
float measuredvalue2 = 0;
float digstepV = 0.0080566; // IS MULTIPLIED BY 10
float voltage = 230; // the net voltage
int tel = 1;
char var;
float longaverage = 0;
rogersguedes /
Created May 7, 2020
sample script that shows how to use `inotifywait` result in a shell script.
# Thanks to
inotifywait -m . -e create -e moved_to |
while read dir action file; do
echo "The file '$file' appeared in directory '$dir' via '$action'"
# do something with the file
rogersguedes / memcmp_idx.c
Created Apr 17, 2020
memcmp with unmatched index.
View memcmp_idx.c
uint8_t memcmp_idx(uint8_t *arr1, uint8_t *arr2, size_t len, size_t *diff_idx){
size_t i = 0;
uint8_t ret = 0;
while(i < len)
if(arr1[i] > arr2[i])
ret = 1;