Skip to content

Instantly share code, notes, and snippets.

View gutierrezps's full-sized avatar

Gabriel Gutierrez gutierrezps

View GitHub Profile
@gutierrezps
gutierrezps / cv2_noise.py
Last active December 3, 2022 16:55 — forked from lucaswiman/cv2_noise.py
Add Salt and Pepper noise to OpenCV Image
# Add Salt and Pepper noise to OpenCV image, vectorized approach.
# https://stackoverflow.com/questions/22937589/how-to-add-noise-gaussian-salt-and-pepper-etc-to-image-in-python-with-opencv
# Forked and fixed from https://gist.github.com/lucaswiman/1e877a164a69f78694f845eab45c381a
# Fixed: replaced 'image' with 'output'
import numpy as np
import cv2
def sp_noise(image, prob):
#include <stdio.h>
#include <stdint.h>
// separa cada conjunto de bits do byte de status
struct MotorStatusBits
{
unsigned motorIndex : 4;
unsigned currentPosition : 3;
unsigned isMoving : 1;
};
@gutierrezps
gutierrezps / caio-padder.py
Created July 31, 2019 13:28
Zero-padder implementation in Python using math functions
import math
def main():
while True:
inputStr = input('Type a number: ')
if inputStr == '':
break
inputNumber = int(inputStr)
@gutierrezps
gutierrezps / index_to_letters.py
Created July 21, 2019 04:16
Converts a list index into letter(s)
"""
The code below was used to print the letters of each item on
an ordered list. So index 0 becomes 'a', 1 becomes 'b', and
so on.
It also use multiple letters when the list length is greater
than 26, so index 26 becomes 'aa', index 27 becomes 'ab',
and so on.
Author: Gutierrez PS
@gutierrezps
gutierrezps / convencoes-codificação.cpp
Last active March 24, 2019 03:23
Convenções de codificação para C/C++/Arduino
/************************************************************
* Convenções de codificação para Arduino
* Autor: Gutierrez PS
*
* Outros padrões mais completos:
* http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
* http://geosoft.no/development/cppstyle.html
* http://www.possibility.com/Cpp/CppCodingStandard.html
************************************************************/
@gutierrezps
gutierrezps / eeprom-test.ino
Created April 26, 2017 16:45
Arduino EEPROM test
/******************************************************
Arduino EEPROM Test
by Gutierrez PS 2017
http://github.com/gutierrezps
Based on John Boxall's idea of testing the lifespan
of Arduino's internal EEPROM:
http://tronixstuff.com/2011/05/11/discovering-arduinos-internal-eeprom-lifespan/
EEPROM is tested by writing a certain value to
@gutierrezps
gutierrezps / parseIpAddress.java
Last active December 20, 2015 17:39 — forked from ryantenney/parseIpAddress.java
Method to parse IP addresses on format x.x.x.x. Useful for sockets etc.
public static boolean parseIpAddress(String ip) throws IllegalArgumentException { // IPv4, format x.x.x.x
StringTokenizer tok = new StringTokenizer(ip, ".");
if (tok.countTokens() != 4) {
throw new IllegalArgumentException("IP address must be in the format 'xxx.xxx.xxx.xxx'");
}
int i = 0;
while (tok.hasMoreTokens()) {
String strVal = tok.nextToken();