Skip to content

Instantly share code, notes, and snippets.

/*
* Round robin algorithm.
*
* It got rid of the disadvantages of the greedy algorithm,
* so each process gets an equal amount of CPU time, that makes round-robin the most efficient on big numbers of processes.
* But for little numbers it could be less efficient (depending on the quantum factor).
*/
#include <stdio.h>
#include <limits.h>
# USAGE:
# Get creds on https://stepik.org/oauth2/applications/
# s = Stepik('client_id',
# 'client_secret')
# link = s.upload_file(path_to file, stepik_filename, course=102606)
from os import PathLike
from typing import Union
@bart02
bart02 / junior.py
Last active January 27, 2022 05:59
Innopolis Open Robotics iUAV 2021
# -*- coding: utf-8 -*-
from __future__ import print_function
import math
# Clover imports
import rospy
from clover import srv
from std_srvs.srv import Trigger
# Computer vision imports
from PyQt5 import QtGui
from PyQt5.QtWidgets import QApplication, QDialog, QProgressBar, QPushButton, QVBoxLayout
import sys
from PyQt5.QtCore import Qt, QThread, pyqtSignal
import time
class MyThread(QThread):
# Create a counter thread
change_value = pyqtSignal(int)
@bart02
bart02 / search.py
Created October 13, 2019 13:10
Function for searching the arduino port
import serial
def search():
found = False
for j in range(3):
for i in range(64):
try:
if j == 0:
port = "/dev/ttyACM" + str(i)
elif j == 1:
#include "mavlink.h"
// Launch the serial port in setup
void setup() {
// MAVLink interface start
Serial.begin(57600);
Serial3.begin(57600);
Mav_Request_Data();
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
import logging
from uncv import classificate
# Enable logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
logger = logging.getLogger(__name__)
@bart02
bart02 / uncv.py
Last active March 28, 2019 18:09
import cv2 as cv
import numpy as np
def check(frame, mask):
contours = cv.findContours(mask, cv.RETR_TREE, cv.CHAIN_APPROX_NONE)
contours = contours[1]
if contours:
contours = sorted(contours, key=cv.contourArea, reverse=True)