Skip to content

Instantly share code, notes, and snippets.

View thegabriele97's full-sized avatar

Salvatore Gabriele La Greca thegabriele97

View GitHub Profile
let n = 0;
let primes: number[] = []; // [1, 2, 3, 5]
while(primes.length < 10) {
++n;
let skip = false;
for (let i = 1; i < primes.length && !skip; i++) {
if (n % primes[i] == 0) {
@thegabriele97
thegabriele97 / convert_all.sh
Last active July 23, 2022 13:53
Script to compress all mp4 files in a folder
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: $0 <input_type> <output_type>"
exit 1
fi
tinput=$1
toutput=$2
#include "FreeRTOS.h"
#include "task.h"
#include "timers.h"
#include "event_groups.h"
#include "queue.h"
#include "semphr.h"
#include "xil_printf.h"
#include "xparameters.h"
#include "FreeRTOS.h"
#include "task.h"
#include "timers.h"
#include "event_groups.h"
#include "xil_printf.h"
#include "xparameters.h"
#define WITH_COMPARE
__global__ void kernel3_char(uint8_t *current, uint8_t *matrix, char *text, int textLen, int N, int matrixWidth, int currWidth, int fullArea) {
int thid = threadIdx.x + blockIdx.x * blockDim.x;
chunk_t cc;
extern __shared__ uint8_t s_matrix[];
if (!thid) {
for (int i = 0; i < (sizeof(CHARS_STR) - 1) * fullArea; i++) {
s_matrix[i] = matrix[i];
}
}
@thegabriele97
thegabriele97 / webcam.cpp
Created December 11, 2021 16:40
open cv webcam
#include <stdio.h>
#include <fcntl.h> /* For O_RDWR */
#include <sys/ioctl.h>
#include <unistd.h> /* For open(), creat() */
#include <netdb.h>
#include <sys/epoll.h>
#include <sys/socket.h>
#include <unistd.h>
#include <signal.h>
@thegabriele97
thegabriele97 / stilparser.py
Created December 2, 2021 20:05
STIL Parser - RISCV PULPV32 ISA
instr2operands = {
'0011000' : ['add', 'add', 'pv.add.h', 'pv.add.b'],
'0011001' : ['sub', 'sub', 'pv.sub.h', 'pv.sub.b'],
'0101111' : ['xor', 'xor', 'pv.xor.sc.h', 'pv.xor.sc.b'],
'0101110' : ['or', 'or', 'pv.or.sc.h', 'pv.or.sc.b'],
'0010101' : ['and', 'and', 'pv.and.sc.h', 'pv.and.sc.b'],
# Shifts
'0100100' : ['sra', 'sra', 'pv.sra.sc.h', 'pv.sra.sc.b'],
uint32_t Flash_Write_Data (uint32_t StartPageAddress, uint32_t *Data, uint16_t numberofwords) {
static FLASH_EraseInitTypeDef EraseInitStruct;
uint32_t PAGEError;
int sofar=0;
/* Unlock the Flash to enable the flash control register access *************/
HAL_FLASH_Unlock();
/* Fill EraseInit structure*/
EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;
@thegabriele97
thegabriele97 / image_diff.c
Created November 11, 2021 22:50
bmp file reader and diff computation pixel by pixel
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdint.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
#define memcpy_lol(_dst, _src, _size, _loc) {\
memcpy(_dst, _src, _size);\
1 2021-07-18 16:32:36,334 - INFO - **** INITIALISING NEW VIMSPECTOR SESSION ****
2 2021-07-18 16:32:36,334 - INFO - API is:
1 2021-07-18 16:32:36,334 - INFO - VIMSPECTOR_HOME = /home/gabri97/.vim/bundle/vimspector
2 2021-07-18 16:32:36,338 - INFO - gadgetDir = /home/gabri97/.vim/bundle/vimspector/gadgets/linux
3 2021-07-18 16:32:36,338 - INFO - User requested start debug session with {}
4 2021-07-18 16:32:36,339 - DEBUG - Reading configurations from: None
5 2021-07-18 16:32:36,339 - DEBUG - Reading configurations from: /home/gabri97/testgit/.vimspector.json
6 2021-07-18 16:32:36,341 - DEBUG - Reading gadget config: /home/gabri97/.vim/bundle/vimspector/gadgets/linux/.gadgets.json
7 2021-07-18 16:32:36,344 - DEBUG - Reading gadget config: None
8 2021-07-18 16:32:37,628 - INFO - Configuration: {"adapter": "vscode-cpptools", "configuration": {"request": "launch", "program": "/home/gabri97/testgit/a.out", "args": [], "cwd": "/hom