Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Hey!

Víctor Fernández vfrico

:octocat:
Hey!
View GitHub Profile
View monty_hall.py
#!/bin/env python3
import random
def get_random_exclude(*n):
while True:
ran = random.randint(0,2)
if ran not in n:
return ran
def montyhall(first_behaviour, second_behaviour):
@vfrico
vfrico / divisores.py
Created Dec 6, 2018
Obtiene los divisores de un número (Versión recursiva)
View divisores.py
#!/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)
View Recursive_rust_cache-article.md

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

View whatsapp_stats.py
#!/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 = []
@vfrico
vfrico / Makefile
Last active Mar 5, 2019
Makefile para compilar un projecto en LaTeX
View Makefile
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
@vfrico
vfrico / virtuoso-local.service
Last active Jun 5, 2018
Systemd service to start virtuoso
View virtuoso-local.service
[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
@vfrico
vfrico / make virtuoso.sh
Created May 29, 2018
Compilar virtuoso
View make virtuoso.sh
sudo apt-get install autoconf automake libtool flex bison gperf gawk m4 make libssl1.0-dev
./configure
make
@vfrico
vfrico / java_launcher.c
Created May 15, 2018
Java wrapper in C
View java_launcher.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 / lines.sh
Created May 15, 2018
Read file line by line on bash
View lines.sh
#!/bin/bash
# Usage: ./lines.sh lineas.txt
while IFS='' read -r line || [[ -n "$line" ]]; do
echo "$line"
done < "$1"
@vfrico
vfrico / ocrmypdf.PKGBUILD
Created May 15, 2018
PKGBUILD for ocrmypdf. The current version on the AUR is outdated and does not work
View ocrmypdf.PKGBUILD
# 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')
You can’t perform that action at this time.