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
rogersguedes / stm32gpTimerCalc.py
Created Dec 14, 2020
STM32 G.P. Timer Prescaler and Period Calc
View stm32gpTimerCalc.py
#!/usr/bin/env python
timerBusClkFreq=216000000
timerDesiredIntFreq=5000
#counts=43200
counts=timerBusClkFreq/timerDesiredIntFreq
prescaler=0
period=0
#counts = (prescaler + 1)*(period + 1)
View iplogger.sh
#/bin/bash
source ${HOME}/.bashrc_rogers
LOGFILE_NAME=whatismyip.log
GATEWAY_IP=192.168.0.1
IP_PAGE_URL=checkip.dyndns.org
LAST_IP=`whatismyip`
echo "Initial IP: ${LAST_IP}"
@rogersguedes
rogersguedes / README.md
Created Sep 10, 2020 — forked from WiBla/README.md
Add YouTube videos to plug.dj without having to search them.
View README.md

What is this?

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

Why is this necessary?

Plug.dj 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 plug.dj is dealing with YouTube's support to get this issue fixed.

How to use

@rogersguedes
rogersguedes / protobuf-msg-def-checker.sh
Created Aug 12, 2020
check if each protobuf definition file contains only one definition and its name is same on file name.
View protobuf-msg-def-checker.sh
#!/bin/bash
find src/ -type f -name *.proto |
while read filePath; do
# do something with the file
fileName=`basename ${filePath}`
echo -n "### checking ${fileName}: "
msgs=""
enuns=""
foundDefs=`grep "message\s\+[a-zA-Z0-9\-\_]\+.*" ${filePath} | sed "s/\s*message\s\+\([a-zA-Z0-9\-\_]\+\).*/\1/"`
if [ -n "${foundDefs}" ]; then
@rogersguedes
rogersguedes / mysql-docker.sh
Created Jun 22, 2020 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
View mysql-docker.sh
# 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
rogersguedes / inotifywait-do.sh
Created May 7, 2020
sample script that shows how to use `inotifywait` result in a shell script.
View inotifywait-do.sh
#!/bin/sh
# Thanks to https://unix.stackexchange.com/questions/24952/script-to-monitor-folder-for-new-files
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
done
@rogersguedes
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;
break;