Skip to content

Instantly share code, notes, and snippets.

View damascenodiego's full-sized avatar
🎯
Focusing

CDN (Diego) Damasceno damascenodiego

🎯
Focusing
View GitHub Profile
@damascenodiego
damascenodiego / flattening_pdf.sh
Created September 8, 2021 06:28
Command to flatten PDF files and retain the image quality
#!/bin/sh
mkdir out
pdf2ps $1 - | ps2pdf - $1.tmp
mv $1.tmp out/$1
# References:
## https://unix.stackexchange.com/a/162925
@damascenodiego
damascenodiego / commands.txt
Created September 3, 2021 14:37
Example of how to create a pool of bash commands using xargs
# That's commands.txt file
echo Hello world
echo How are you?
echo EleNaum
echo Almost finished...
@damascenodiego
damascenodiego / tree_to_hformat.py
Last active August 19, 2021 07:52
Python code to parse a (sub)tree starting from a node nid to the horizontal format. None elements
# Python code to parse a (sub)tree starting from a node nid to the horizontal format.
# Returns a python list with node IDs. None elements indicates backtracking
def tree_to_hformat(tree, nid = 0, list_hformat=None):
if list_hformat is None:
list_hformat = []
list_hformat.append(nid)
for child in tree.successors(nid):
tree_to_hformat(tree, child, list_hformat)
list_hformat.append(None)
return(list_hformat)
#!/bin/python
from z3 import *
# we have that
s = Solver()
## mu0_px is the initial marking for place px;
mu_p1, mu_p2, mu_p3 = 0, 0, 1
## pi_tj is the pre-condition from place pi to transition tj
@damascenodiego
damascenodiego / itdoesnotwork.py
Last active February 15, 2020 12:55
Z3Py codes showing different results for the "same" thing ?
#!/bin/python
from z3 import *
# we have that
s = Solver()
## mu0_px is the initial marking for place px;
mu_p1, mu_p2, mu_p3 = 0, 0, 1
## pi_tj is the pre-condition from place pi to transition tj
damasceno@princeton-lnx:~/git/fault-identification-in-petri-nets$ ./find_fault.sh
[f_p1 >= 0,
f_p2 >= 0,
f_p3 >= 0,
p1_f >= 0,
p2_f >= 0,
p3_f >= 0,
l0 >= 0,
Exists(l0,
And(0 + l0*(f_p1 - p1_f) >= 0,
id finalScore finalScore_sort scenario timeElapsed routeCompleted collisions wrongLane offRoute redLights
1 1608110491599 1608110491599 In 79 11 8 501 703 1
2 1659092618299 1659092618299 tincidunt 43 41 5 609 447 10
3 1685071296499 1685071296499 velit 64 2 6 263 302 9
4 1684051589699 1684051589699 nec 47 98 2 69 899 1
5 1644052309799 1644052309799 tempor, 84 98 5 229 379 9
6 1656050688199 1656050688199 nascetur 22 83 7 272 610 10
7 1604040618199 1604040618199 ac 30 42 9 613 940 9
8 1665040816299 1665040816299 sit 3 31 10 422 312 7
9 1603070413999 1603070413999 Nunc 81 87 5 425 42 1
from escposprinter import printer
import qrcode
import math
from PIL import Image
def make_custom_qr(data):
# Create qr code instance
qr = qrcode.QRCode(
version=1,
@damascenodiego
damascenodiego / capture.py
Created May 22, 2019 15:58
Capture video data from screen in Python
import cv2
import numpy as np
import os
import pyautogui
# Capture video data from screen in Python
# https://stackoverflow.com/questions/35097837/capture-video-data-from-screen-in-python
output = "video.avi"
img = pyautogui.screenshot()
@damascenodiego
damascenodiego / camerastream.py
Created May 22, 2019 15:32 — forked from snim2/camerastream.py
Display the output of a webcam using Python and Pygame
import pygame
import pygame.camera
from pygame.locals import *
DEVICE = '/dev/video0'
SIZE = (640, 480)
FILENAME = 'capture.png'
def camstream():
pygame.init()