Skip to content

Instantly share code, notes, and snippets.

View AhmedSamara's full-sized avatar

Ahmed Samara AhmedSamara

View GitHub Profile
@AhmedSamara
AhmedSamara / trace.cc
Last active October 1, 2023 19:33
Python trace calls.
// gcc -finstrument-functions your_file.c -o your_program
void __attribute__((no_instrument_function)) __cyg_profile_func_enter(void *this_fn, void *call_site) {
printf("Entering %p\n", this_fn);
}
void __attribute__((no_instrument_function)) __cyg_profile_func_exit(void *this_fn, void *call_site) {
printf("Exiting %p\n", this_fn);
}
@AhmedSamara
AhmedSamara / UniqueQueu.h
Last active April 5, 2022 18:04
A queu that ensures elements are unique before inserting them.
#include <unordered_set>
#include <queue>
#include <assert.h>
#include <stdexcept>
template <class T>
class UniqueQueu {
public:
@AhmedSamara
AhmedSamara / scatterv.c
Last active October 8, 2021 08:03 — forked from ehamberg/scatterv.c
MPI_Scatterv example
#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define SIZE 4
// mpic++ -o prog.exe hello.cpp
// mprin -np prog.exe
import PyPDF2
import subprocess
pdfIn = open('presentations.pdf', 'rb')
reader = PyPDF2.PdfFileReader(pdfIn)
writer = PyPDF2.PdfFileWriter()
for i in range(reader.numPages):
@AhmedSamara
AhmedSamara / delete_git_submodule.md
Last active May 11, 2018 22:53 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule <name>"
  • Delete the now untracked submodule files rm -rf path_to_submodule
@AhmedSamara
AhmedSamara / C270.sh
Last active March 29, 2016 16:44
UDEV-cameras
[root@localhost ~]# udevadm info -a /dev/video1
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.
looking at device '/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0/video4linux/video1':
KERNEL=="video1"
Bus 001 Device 004: ID 04f2:a149 Chicony Electronics Co., Ltd
Couldn't open device, some information will be missing
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
import numpy as np
import cv2
from matplotlib import pyplot as plt
#http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_matcher/py_matcher.html
def drawMatches(img1, kp1, img2, kp2, matches):
"""
source:
http://stackoverflow.com/questions/20259025/module-object-has-no-attribute-drawmatches-opencv-python
import numpy as np
import cv2
import imutils
cap = cv2.VideoCapture(0)
while True:
# Capture frame-by-frame
ret, frame = cap.read()
import numpy as np
import cv2
import imutils
cap = cv2.VideoCapture(0)
while True:
# Capture frame-by-frame
ret, frame = cap.read()