Skip to content

Instantly share code, notes, and snippets.

@rogersguedes
rogersguedes / Fail2ban Mosquitto filter
Created October 29, 2024 01:48 — forked from francescor93/Fail2ban Mosquitto filter
Simple fail2ban jail for Mosquitto authentication
Following is a simple fail2ban jail for Mosquitto authentication.
When an authentication attempt fails, Mosquitto writes three lines like these to his log file:
---
<TIMESTAMP>: New connection from <HOST> on port <PORT>.
<TIMESTAMP>: Sending CONNACK to <HOST>
<TIMESTAMP>: Socket error on client <unknown>, disconnecting.
---
This filter looks for these three lines to get the host and allow you to ban it.
@rogersguedes
rogersguedes / gitflow-breakdown.md
Created November 18, 2021 12:28 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
  git commit --allow-empty -m "Initial commit"
  git checkout -b develop master

Connect to the remote repository

@rogersguedes
rogersguedes / CMakeLists.txt
Created October 16, 2021 20:05 — forked from squeek502/CMakeLists.txt
Lua 5.1.x Windows CMake build script
project ( lua C )
cmake_minimum_required ( VERSION 2.8 )
include_directories ( src ${CMAKE_CURRENT_BINARY_DIR} )
set ( SRC_CORE src/lapi.c src/lcode.c src/ldebug.c src/ldo.c src/ldump.c src/lfunc.c src/lgc.c src/llex.c
src/lmem.c src/lobject.c src/lopcodes.c src/lparser.c src/lstate.c src/lstring.c src/ltable.c
src/ltm.c src/lundump.c src/lvm.c src/lzio.c )
set ( SRC_LIB src/lauxlib.c src/lbaselib.c src/ldblib.c src/liolib.c
src/lmathlib.c src/loslib.c src/lstrlib.c src/ltablib.c src/loadlib.c src/linit.c )
@rogersguedes
rogersguedes / stm32gpTimerCalc.py
Created December 14, 2020 20:01
STM32 G.P. Timer Prescaler and Period Calc
#!/usr/bin/env python
timerBusClkFreq=216000000
timerDesiredIntFreq=5000
#counts=43200
counts=timerBusClkFreq/timerDesiredIntFreq
prescaler=0
period=0
#counts = (prescaler + 1)*(period + 1)
#/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 September 10, 2020 20:52 — forked from WiBla/README.md
Add YouTube videos to plug.dj without having to search them.

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 August 12, 2020 13:20
check if each protobuf definition file contains only one definition and its name is same on file name.
#!/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 June 22, 2020 00:14 — forked from spalladino/mysql-docker.sh
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
/* 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>
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;