Skip to content

Instantly share code, notes, and snippets.

View pcotret's full-sized avatar

Pascal Cotret pcotret

View GitHub Profile
@pcotret
pcotret / pdftopng.sh
Last active January 29, 2026 15:34
Convert a pdf in a 2x2 layout of PNGs
# Slides => PNGs
pdftoppm -png -r 300 main.pdf slide
# PNGs => slides
img2pdf slide-*.png -o new.pdf
# PDF => 2x2 PDF
pdfjam new.pdf --nup 2x2 --landscape --outfile new-2x2.pdf
# Compress if file too big
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=new-2x2-compressed.pdf new-2x2.pdf
# Clean temp files
rm slide-*.png
@pcotret
pcotret / run.tcl
Created October 31, 2025 12:51
TCL run script for CVA6 on Vivado
# Copyright 2018 ETH Zurich and University of Bologna.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
%%
%% This is file `book.cls',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% classes.dtx (with options: `book')
%%
%% This is a generated file.
%%
Hello World!
init SPI
status: 0x0000000000000025
status: 0x0000000000000025
SPI initialized!
initializing SD...
SD command cmd0 response : 01
SD command cmd55 response : 01
SD command cmd41 response : 01
SD command cmd55 response : 01
import os
os.system('ln -s D ../flag.txt .')
#include <stdio.h>
#include <stdint.h>
// Function to enable PMP and set permissions for region 0
void enable_pmp(uintptr_t start, uintptr_t end, uint8_t permissions) {
uint8_t pmpcfg = (permissions << 3) | 0x01;
uintptr_t pmpaddr = ((start >> 2) << 2) | 0x08;
// Calculate the PMP address mask
uintptr_t pmpmask = ((end - start) >> 2) - 1;
@pcotret
pcotret / gtkwave.tcl
Created June 15, 2023 13:33 — forked from carlosedp/gtkwave.tcl
GTKWave TCL script to colorize and group signals for Chisel projects
#
# GTKWave Grouping and colorizing script
#
# Load the trace with `gtkwave -S gtkwave.tcl yourtrace.vcd`
#
# Customize the inserted traces in the TOPlevel section below
# and at the bottom in the add_signals function calls
#
# Customize this section as needed
@pcotret
pcotret / getrid_get_python_lib.py
Last active April 24, 2023 15:32
The idea is to get rid of distutils which is deprecated in Python 3.10 and normally removed in Python 3.12. For instance, it's used in Capstone disassembly engine.
def get_site_packages(): # pragma: no cover
try:
paths = site.getsitepackages()
if site.ENABLE_USER_SITE:
paths.append(site.getusersitepackages())
return paths
except Exception:
try:
from distutils.sysconfig import get_python_lib
git clone https://github.com/chipsalliance/rocket-tools
cd rocket-tools
# Hash given in the rocket-chip repository (1.6 release)
git checkout e2c6d1577a75f506fe992c3eb20a75174504476e
# Replace git repo with https alternative
git submodule set-url fsf-binutils-gdb https://sourceware.org/git/binutils-gdb.git
git submodule sync
# Update GNU toolchain
git submodule update --init riscv-gnu-toolchain
cd riscv-gnu-toolchain
@pcotret
pcotret / centos7-sphinx-latex.sh
Created December 1, 2022 09:28 — forked from brycepg/centos7-sphinx-latex.sh
Install Sphinx latexpdf Dependencies for Centos 7
#!/bin/bash
# source: https://cbs.centos.org/koji/rpminfo?rpmID=45050
set -xeuo pipefail
sudo yum install -y "tex(cmap.sty)" "tex(ecrm1000.tfm)" "tex(fancybox.sty)" "tex(footnote.sty)" "tex(framed.sty)" "tex(multirow.sty)" "tex(parskip.sty)" "tex(threeparttable.sty)" "tex(titlesec.sty)" "tex(upquote.sty)" "tex(wrapfig.sty)" "texlive-collection-fontsrecommended" "texlive-collection-latex" "tex(fncychap.sty)" python-sphinx > /dev/null
# Determine latex search directory
SEARCH_DIRECTORY="$(kpsewhich -var-value=TEXMFHOME)/tex/latex/local"
mkdir -p "$SEARCH_DIRECTORY"
# capt-of.sty has no Centos 7 package