Skip to content

Instantly share code, notes, and snippets.

View Mohamedemad4's full-sized avatar

Mohamed Emad Mohamedemad4

View GitHub Profile
@Mohamedemad4
Mohamedemad4 / usbswithcing.py
Created June 18, 2019 08:16
switch usbs in a chosen order ,can help if u have multipule USB devices with no uniq features .use lsusb -t ,to view the USB ports and their numbers ,made for the rpi
#based on:https://github.com/mvp/uhubctl
import os
import time
def turnthemAlloff():
os.system("./uhubctl -a off -p 4")
os.system("./uhubctl -a off -p 3")
os.system("./uhubctl -a off -p 5")
time.sleep(3)
@Mohamedemad4
Mohamedemad4 / MRSMontoCarloSim.py
Created July 4, 2019 12:34
a Monto Carlo Simulation to determine the needed time of motion for an MRS supervisor in minesweepers competition see: landminefree.org
import random
import numpy as np
import math
from pprint import pprint as p
LinearSpeed=0.5#linear speed of the Supervisor in m/s
class Arena:
def __init__(self):
self.mine_locs=np.zeros(shape=(20,20))
self.d_loc=[0,0] # x,y ,right hand vector system z is towards you x to the left y to the top of the screen
self.s_loc=[1,0]
<style id="jsbin-css">
@import url(https://fonts.googleapis.com/css?family=Roboto);
body {
font-family: Roboto, sans-serif;
}
#chart {
max-width: 650px;
@Mohamedemad4
Mohamedemad4 / storeinPROGMEM.py
Created January 8, 2020 11:20
Stores all strings from println and print commands in PROGMEM. to minimaize the .data section.surprised GCC didn't already have this. put this script outside your code directory and run: python3 putStrInPROGMEM.py yourcodedir
#!/usr/bin/python3
#this but for arduino https://www.avrfreaks.net/forum/tut-c-gcc-and-progmem-attribute?page=all
import os
import re
import sys
import pprint
p=re.compile("println\(([^\)]+)\)|print\(([^\)]+)\)")
strings_vars=""
p2v_dict={}
@Mohamedemad4
Mohamedemad4 / download_kitti.py
Last active May 26, 2020 20:35
Downloads and Unzips the Entire KITTI dataset for the selected categories
import requests as req
from bs4 import BeautifulSoup
import pprint
import os
b_url="http://www.cvlibs.net/datasets/kitti/raw_data.php?type={0}"
cats=["city","residential","campus","road"]
all_data_files=[]
@Mohamedemad4
Mohamedemad4 / session_pool.py
Last active March 15, 2021 19:08
a usefull little class for running long running shell commands in the background and manging them in a python program or service
import os
import subprocess as sp
from multiprocessing import Process
class session_pool():
"""
Session_pool is used to run long running processes in the background
Usage:
sess_pool=session_pool()
@Mohamedemad4
Mohamedemad4 / mpjpeg_streaming.conf
Created January 18, 2021 00:20
Low latency webcam streaming with ffmpeg
# ffmpeg -f v4l2 -i /dev/video0 http://localhost:8090/feed1.ffm
# and run the server with ffserver -c mpjpeg_streaming.conf
# go to your browser in http://localhost:8090/feed.mpjpg
HTTPPort 8090
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 1000
CustomLog -