Skip to content

Instantly share code, notes, and snippets.

"""
Command line tool for processing of a batch of PDF files stored on gcloud storage with a Document
AI processor.
`pip install python-dotenv google-cloud google-cloud-documentai
google-cloud-documentai-toolbox google-cloud-storage`
Also create a .env file for populating default values, containing following
keys: GCP_PROJECT_ID, PROCESSOR_ID, PROCESSOR_LOCATION, GCS_DOCUMENT_BUCKET and
GCS_DOCUMENT_TEXT corresponding to an OCR
processor created on the Document AI platform of your GCP project. The two last
keys correspond to the name of gcloud storage buckets, first for the stored PDF
@mancap314
mancap314 / single_local_documentai_ocr.py
Last active December 22, 2023 09:58
Single local PDF extraction with Document AI processor
"""
Command line tool to run OCR with a Document AI processor over a single local PDF file
`pip install python-dotenv google-cloud google-cloud-documentai`
Also create a .env file for populating default values, containing following
keys: GCP_PROJECT_ID, PROCESSOR_ID, PROCESSOR_LOCATION corresponding to an OCR
processor created on the Document AI platform of your GCP project.
"""
from google.api_core.client_options import ClientOptions
from google.cloud import documentai
@mancap314
mancap314 / linux-install-hummingbot.sh
Created December 14, 2023 11:06
Install Hummingbot on Linux - g1-small instance
#!/bin/bash
sudo apt -y install git python3-pip
echo "alias python=python3" >> ~/.bashrc
source ~/.bashrc
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh -b
rm Miniconda3-latest-Linux-x86_64.sh
miniconda3/bin/conda init bash
source miniconda3/etc/profile.d/conda.sh
@mancap314
mancap314 / endswith.c
Last active April 23, 2023 16:17
find out if a string ends with a given suffix in C
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
bool endswith(char* str, char* suffix) {
size_t str_length = strlen(str);
size_t suffix_length = strlen(suffix);
if (str_length < suffix_length) return false;
return strncmp(str + str_length - suffix_length, suffix, suffix_length)) == 0;
@mancap314
mancap314 / clean-python.sh
Created April 3, 2022 15:26
Uninstalling all libraries in Python
#!/bin/bash
# shell script for removing all libraries installes
# could be useful for building a clean virtual environment on top of it
input="requirements.txt"
pip freeze > "${input}"
while IFS= read -r line; do
@mancap314
mancap314 / .vimrc
Last active July 13, 2021 14:22
my super duper vim configuration for vim-plug
set nocompatible " be iMproved, required
filetype off " required
syntax enable " syntax highlight
set t_Co=256 " set 256 colors
set number " show line numbers
set ruler
@mancap314
mancap314 / temperature.sh
Created July 11, 2021 14:52
Display highest thermal zone temperature (°C, Linux)
#!/bin/bash
max_temperature=0
for d in /sys/class/thermal/thermal_zone* ; do
temperature=$(cat ${d}/temp)
if [[ $max_temperature -eq 0 || $temperature -gt $max_temperature ]]; then
max_temperature="${temperature}";
fi
done
max_temperature=$(( max_temperature / 1000 ))
import setuptools
with open('README.md', 'r', encoding='utf-8') as fh:
long_description = fh.read()
setuptools.setup(
name='mypackage',
version='0.0.1',
author='My Name',
author_email='my.name@somemail.xyz',
@mancap314
mancap314 / progress-bar.sh
Created June 7, 2019 15:18
bash script for progression bar
#!/usr/bin/env bash
# Default values
OUTPUT_DIR=""
PREFIX=""
N_IMAGES=0
INTERVAL=3
while [[ ! $# -eq 0 ]]; do # looping through the arguments
case "$1" in
@mancap314
mancap314 / rename.py
Created June 7, 2018 18:48
rename files iteratively
from pathlib import Path
import sys
import os
mapping = {'cz': 'czech',
'pl': 'poland'}
start_dir = sys.argv[1]