Skip to content

Instantly share code, notes, and snippets.

View cosmoscalibur's full-sized avatar
🎯
Focusing

Edward Villegas-Pulgarin cosmoscalibur

🎯
Focusing
View GitHub Profile
@cosmoscalibur
cosmoscalibur / download_directoryindex.py
Created December 15, 2019 01:22
Download files from a DirectoryIndex
""" Download files from a DirectoryIndex.
"""
from requests_html import HTMLSession
from os import path
from urllib import request
import shutil
def download_files(url_repo: str, out_path: str):
"""Download in `out_path` all files of DirectoryIndex in `url_repo`.
@cosmoscalibur
cosmoscalibur / wget_custom.sh
Last active December 17, 2019 01:43
Download files from URL specified in plain text files (one per file) and save with the same name of the origin file. https://askubuntu.com/questions/1196228/wget-from-file-and-save-as-acording-to-file-name
#! /usr/bin/env bash
# usage: bash wget_custom.sh
# Put this file in the same directory of `frm` files with unique URL to download.
# Downloades file has the same name of `frm` file but the extension is `txt`.
# Answer to AskUbuntu question: https://askubuntu.com/questions/1196228/wget-from-file-and-save-as-acording-to-file-name
SAVEIFS=$IFS
IFS=$'\n'
files=$(ls -1 *.frm)
@cosmoscalibur
cosmoscalibur / issue95_RAE
Created June 27, 2019 02:00
RLA ES lemas RAE reporte 95
[+] acérrimo
acérrimo, ma.
Del lat. acerrĭmus.
1. adj. sup. de acre2.
2. adj. Muy fuerte, vigoroso o tenaz.
3. adj. Intransigente, fanático, extremado.
[+] acérrimos
acérrimo, ma.
Del lat. acerrĭmus.
1. adj. sup. de acre2.
@cosmoscalibur
cosmoscalibur / issue15_RAE
Last active June 27, 2019 01:59
Lemas RAE reporte 15
[+] abarrocado
abarrocado, da.
1. adj. Que presenta rasgos barrocos. Estilo, vestido abarrocado.
[+] abarrotamiento
abarrotamiento.
1. m. Acción y efecto de abarrotar (‖ llenar por completo un espacio).
[+] abocardamiento
abocardamiento.
1. m. Acción y efecto de abocardar.
[+] abochornante
@cosmoscalibur
cosmoscalibur / normalize_filename.sh
Created June 24, 2019 00:53
Bash script to normalize filenames (lower case and underlines instead of spaces)
#! /usr/bin/env bash
SAVEIFS=$IFS
IFS=$'\n'
FILES=$(find . -iname "$1")
for FILE in ${FILES[@]}; do
DIRECTORY=$(echo $FILE | sed -n -E 's/^(\.?\/?(.+\/))?(([^\/]+)(\.([^\.\/]+))?)$/\1/p')
FILENAME=$(echo $FILE | sed -n -E 's/^(\.?\/?(.+\/))?(([^\/]+)(\.([^\.\/]+))?)$/\3/p')
FILENAME_NORM=$(echo $FILENAME | sed -E -e 's/./\l\0/g' -e 's/( |_)+/_/g' \
-e 's/^_//' -e 's/(_|-)\./\./g' -e 's/\.\./\._/g')
if ! [[ "$DIRECTORY$FILENAME" = "$DIRECTORY$FILENAME_NORM" ]]; then
@cosmoscalibur
cosmoscalibur / vexrobotics_scraping.py
Last active June 22, 2019 17:40
web scraping example with requests and bs4
#! /usr/bin/env python3
# author: Edward Villegas-Pulgarin (@cosmoscalibur)
# Scraping web site and convert to markdown format.
# Extract product catalog.
# June 28, 2017.
# Last test: June 22, 2019.
import requests
@cosmoscalibur
cosmoscalibur / anaconda_pyinstaller
Last active August 6, 2018 00:38
Minimal example of PyInstaller with Python Anaconda in Linux
conda create -y -n pyinstaller python=3.6
conda activate pyinstaller
pip install pyinstaller
echo 'print("hola mundo")' > hola.py
pyinstaller --onefile hola.py
./dist/hola
@cosmoscalibur
cosmoscalibur / condawrapper.py
Last active August 2, 2018 16:22
This is a convenient way to install packages in all conda environments
"""
This script help you to list your conda environments and install packages in multiples environments.
You need conda package manager installed (Anaconda/Miniconda) and Python Anaconda.
:Authors:
Edward Villegas-Pulgarin <cosmoscalibur at gmail dot com>.
"""
#%%
@cosmoscalibur
cosmoscalibur / download_es_guttenberg.py
Last active May 30, 2018 02:10
Automatic download of Spanish books from Guttenberg project.
"""
This script help you to download the large collection of Spanish books included
in `Guttenberg project <https://www.gutenberg.org/browse/languages/es>`_.
You need to install `requests-html <http://html.python-requests.org/>`_.
:Authors:
Edward Villegas-Pulgarin <cosmoscalibur at gmail dot com>.
"""
from requests_html import HTMLSession
@cosmoscalibur
cosmoscalibur / propioscolombianos_generar.sh
Created August 22, 2017 04:03
Genera lista de lemas asociados a nombres propios a partir de una lista de nombres propios en texto plano. Elimina duplicados respecto a topónimos y nombres propios existentes en el proyecto (RLA-ES).
#!/usr/bin/env bash
# Rutina elaborada por Edward Villegas Pulgarin (@cosmoscalibur en github).
# Genera lista de lemas de nombres propios colombianos para diccionario hunspell
# a partir de una lista de nombres compuestos en archivo de texto plano, comparando
# con los topónimos y nombres propios ya incluidos.
# El archivo debe ubicarse en el directorio de la localización.
# Realizado para la localización es_CO de [RLA-ES](https://github.com/sbosio/rla-es).
# $1: Nombre del archivo de listas de nombres