Skip to content

Instantly share code, notes, and snippets.

View mcagriaksoy's full-sized avatar
homo_sapiens.py

Mehmet C. Aksoy mcagriaksoy

homo_sapiens.py
View GitHub Profile
@giuliano-macedo
giuliano-macedo / hu_moments.tex
Last active June 25, 2022 07:32
Hu moments in Latex
$
M_{ij}=\sum\limits_{x}\sum\limits_{y}x^iy^iI(x,y)\\
\eta_{pq}=\sum\limits_{x}\sum\limits_{y}(x-\bar x)^p(y- \bar y)^qI(x,y)\\
\bar x=\frac{M_{10}}{M_{00}}, \bar y=\frac{M_{01}}{M_{00}}\\
\mu_{pq}=\frac{\eta_{pq}}{\eta_{00}^\gamma},\gamma=\frac{p+q}{2}\\
H_{1} = \mu_{20} + \mu_{02}\\
H_{2} = (\mu_{20} - \mu_{02})^2 + 4(\mu_{11})^2\\
H_{3} = (\mu_{30} - 3\mu_{12})^2 + (\mu_{03} - 3\mu_{21})^2\\
H_{4} = (\mu_{30} + \mu_{12})^2 + (\mu_{03} + \mu_{21})^2\\
H_{5} = (\mu_{30} - 3\mu_{12})(\mu_{30} + \mu_{12})((\mu_{30} + \mu_{12})^2 - 3(\mu_{21} + \mu_{03})^2) + (3\mu_{21} - \mu_{03})(\mu_{21} + \mu_{03})(3(\mu_{30} + \mu_{12})^2 - (\mu_{03} + \mu_{21})^2)\\
@Marzogh
Marzogh / arduino_serial.py
Last active January 25, 2023 16:32 — forked from ttmarek/arduino_serial.py
Python script to read serial data from the Arduino. Second file from (https://electronics.stackexchange.com/questions/54/saving-arduino-sensor-data-to-a-text-file)
import serial
import csv
import re
import matplotlib.pyplot as plt
import pandas as pd
portPath = "/dev/ttyACM0" # Must match value shown on Arduino IDE
baud = 115200 # Must match Arduino baud rate
timeout = 5 # Seconds
filename = "data.csv"
@r00tdaemon
r00tdaemon / Install PyQt5 on Ubuntu with python3 .md
Last active May 4, 2024 04:08
Install PyQt5 on Ubuntu with python3. Steps to set up PyQt5 (ubuntu). With python code generation

Installation

pip3 install --user pyqt5  
sudo apt-get install python3-pyqt5  
sudo apt-get install pyqt5-dev-tools
sudo apt-get install qttools5-dev-tools

Configuring to run from terminal

anonymous
anonymous / esp8266_mqtt_humtemp
Created November 7, 2015 17:01
ESP8266 + MQTT + DHT11 Humidity and Temperature Sensor
/* ESP8266 + MQTT Humidity and Temperature Node
* Can also receive commands; adjust messageReceived() function
* See MakeUseOf.com for full build guide and instructions
* Author: James Bruce, 2015
*/
#include <MQTTClient.h>
#include <ESP8266WiFi.h>
#include <DHT.h>
@rustyconover
rustyconover / collatz-sequence.c
Created May 5, 2015 21:33
Collatz sequence in C
#include <stdio.h>
int collatz_count_until_1(unsigned int n) {
int count = 0;
while(n != 1) {
if(n % 2 == 0) {
n /= 2;
} else {
n = (3 * n) + 1;
}
@NearLinHere
NearLinHere / I2C_sample.c
Last active December 22, 2023 23:32
I2C sample code
#define SCL TRISB4 // I2C bus
#define SDA TRISB1 //
#define SCL_IN RB4 //
#define SDA_IN RB1 //
// initialize
SDA = SCL = 1 ;
SCL_IN = SDA_IN = 0 ;
// make master wait
@cdiener
cdiener / asciinator.py
Last active January 5, 2023 17:24
Convert image to ascii art
import sys; from PIL import Image; import numpy as np
chars = np.asarray(list(' .,:;irsXA253hMHGS#9B&@'))
if len(sys.argv) != 4: print( 'Usage: ./asciinator.py image scale factor' ); sys.exit()
f, SC, GCF, WCF = sys.argv[1], float(sys.argv[2]), float(sys.argv[3]), 7/4
img = Image.open(f)
S = ( round(img.size[0]*SC*WCF), round(img.size[1]*SC) )
img = np.sum( np.asarray( img.resize(S) ), axis=2)
@vo
vo / gist:9331349
Last active February 13, 2023 13:22
Simple Mavlink Reader in Python using pymavlink
#!/usr/bin/env python
import sys, os
from optparse import OptionParser
# tell python where to find mavlink so we can import it
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../mavlink'))
from pymavlink import mavutil
def handle_heartbeat(msg):