Skip to content

Instantly share code, notes, and snippets.

@vfrico
vfrico / ocrmypdf.PKGBUILD
Created May 15, 2018 17:53
PKGBUILD for ocrmypdf. The current version on the AUR is outdated and does not work
# Maintainer: mutantmonkey <aur@mutantmonkey.in>
# Contributor: Daniel Reuter <daniel.robin.reuter@googlemail.com>
# Contributor: Víctor Fernández Rico <vfrico@gmail.com>
pkgname=ocrmypdf
pkgver=6.1.5
pkgrel=1
pkgdesc="A tool to add an OCR text layer to scanned PDF files, allowing them to be searched"
url="https://github.com/jbarlow83/OCRmyPDF"
arch=('any')
license=('custom')
@vfrico
vfrico / lines.sh
Created May 15, 2018 18:04
Read file line by line on bash
#!/bin/bash
# Usage: ./lines.sh lineas.txt
while IFS='' read -r line || [[ -n "$line" ]]; do
echo "$line"
done < "$1"
@vfrico
vfrico / java_launcher.c
Created May 15, 2018 21:51
Java wrapper in C
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
/**
C program to launch a Java Jar (eg: Minecraft server)
The purpose is to create a binary file that can be set with the SETUID permissions and owned by root.
Using this way, the server can run on the 80 port without be asked the root password.
@vfrico
vfrico / make virtuoso.sh
Created May 29, 2018 10:46
Compilar virtuoso
sudo apt-get install autoconf automake libtool flex bison gperf gawk m4 make libssl1.0-dev
./configure
make
@vfrico
vfrico / unpaper_pdf.sh
Last active May 30, 2018 14:37
Wrapper for unpaper. Input is a double sided pdf book (scanned)
#!/bin/bash
# Usage: ./script.sh file.pdf
# Generate .png for each page on the PDF, assuming that the PDF is a scanned book.
# unpaper will crop and correct inclination and delete artifacts of each page
# Requirements:
# Ghostscript
# Unpaper (on arch repositories and https://github.com/Flameeyes/unpaper)
# basename (Maybe on coreutils package)1
@vfrico
vfrico / virtuoso-local.service
Last active June 5, 2018 18:02
Systemd service to start virtuoso
[Unit]
Description=Virtuoso service
After=network.target
Requires=network.target
[Service]
Type=simple
ExecStart=/usr/local/virtuoso-opensource/bin/virtuoso-t +configfile /usr/local/virtuoso-opensource/var/lib/virtuoso/db/virtuoso.ini +foreground +wait
#!/usr/bin/env python3
import matplotlib.pyplot as plt; plt.rcdefaults()
import numpy as np
import matplotlib.pyplot as plt
f = open("whatsapp.txt", "r")
list_messages = []
list_users = []

Fibonacci recursive with cache in Rust

This sample program aims to show how to pass an array by reference to other function in Rust, by using an array as a cache of the calculus of fibonacci sequence.

Rust can not hold a number greater than fib(185) on a u128 (unsigned integer 128 bits) type, so the program asks first to the user the n number and performs this

@vfrico
vfrico / divisores.py
Created December 6, 2018 12:15
Obtiene los divisores de un número (Versión recursiva)
#!/usr/bin/python3
def divisor_helper(n, i):
if i == 0:
return []
elif n % i == 0:
recursion = [i] + divisor_helper(n, i-1)
return recursion
else:
return divisor_helper(n, i-1)
@vfrico
vfrico / Makefile
Last active March 5, 2019 23:37
Makefile para compilar un projecto en LaTeX
MAIN_LATEX=latex_file
BUILD_DIR=build/
LATEXMK_OPTS="-output-directory=$(BUILD_DIR)"
PDFLATEX_OPTS="--output-directory=$(BUILD_DIR)"
TEX_ENGINE=-pdflatex="pdflatex $(PDFLATEX_OPTS)"
# TEX_ENGINE=-xelatex