Skip to content

Instantly share code, notes, and snippets.

View RodolfoFerro's full-sized avatar
🐍
I speak Python.

Rodolfo Ferro RodolfoFerro

🐍
I speak Python.
View GitHub Profile
@RodolfoFerro
RodolfoFerro / joystick_demo.ino
Created January 1, 2019 04:37
Arduino script to connect an analog joystick to an Arduino UNO.
/*
Arduino script to connect an analog joystick
to an Arduino UNO.
Author: Rodolfo Ferro
Site: https://rodolfoferro.xyz/
*/
// Define ports:
int xPin = A1;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# Python 2/3 compatibility
from __future__ import print_function
import numpy as np
import imutils
import cv2
import sys
# Global vars:
@RodolfoFerro
RodolfoFerro / -omdena-impipes-demo.ipynb
Created September 11, 2019 08:46
[Omdena] impipes demo
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@RodolfoFerro
RodolfoFerro / calculate_memory.py
Created October 3, 2019 07:10
Calculate memory percentage of a Python process.
import os
import psutil
# Get current Process ID:
pid = os.getpid()
def get_memory_status(pid):
# Build psutil process from PID:
p = psutil.Process(pid)
@RodolfoFerro
RodolfoFerro / README.md
Created November 1, 2019 01:03
Python script to consume OSM changesets API.

This is a Python script to consume OSM changesets API.

Requirements

Installation

@RodolfoFerro
RodolfoFerro / piedra_papel_tijeras.c
Created November 9, 2019 20:16
Código en C para jugar piedra, papel o tijeras. C
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
// Declaracion de funciones:
void genera_juego();
void imprime_instrucciones();
int genera_mano_random();
int juega_manos(int mano_usuario, int mano_compu);
@RodolfoFerro
RodolfoFerro / pikachu_bounce.pyde
Created November 25, 2019 04:45
Gist for the second part of the workshop "Introduction to Python and Processing" in the She++ event, November 2019.
global x, y
global vx, vy
w, h = 700, 500
x, y = random(0, w), random(0, h)
vx, vy = 5, 3
def draw_pikachu(cx, cy, s):
# Yellow part of the face:
fill(229, 183, 61)
ellipse(cx, cy, 150*s, 150*s)
@RodolfoFerro
RodolfoFerro / larvae.py
Last active November 30, 2019 11:53
A simple larvae detector using computer vision.
import cv2
import numpy as np
# Loadimage and convert to grayscale for posterior processing:
img = cv2.imread('demo.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Buils a kernel for dilation:
kernel = np.ones((3, 3), np.uint8)
@RodolfoFerro
RodolfoFerro / hasher.py
Created January 15, 2020 07:47
Script to hash passwords.
from hashlib import sha256
def hash_password(password):
"""Hash a password using SHA256."""
return sha256(str.encode(password)).hexdigest()
def verify_password_hash(password, hash):