Skip to content

Instantly share code, notes, and snippets.

View toniher's full-sized avatar

Toni Hermoso Pulido toniher

View GitHub Profile
@toniher
toniher / singularity-predownload.sh
Last active March 24, 2023 15:35
Simple script for predownloading Singularity images in order to be convenient to be used by Nextflow. Useful for issues like this: https://github.com/nextflow-io/nextflow/issues/1210
#!/usr/bin/env bash
CONFILE=${1:-nextflow.config}
OUTDIR=${2:-./singularity}
if [ ! -e $CONFILE ]; then
echo "$CONFILE does not exist"
exit
fi
#!/usr/bin/env python
import sys
import json
if len(sys.argv) != 2:
exit()
print("{\"docs\": [")
with open(sys.argv[1]) as infile:
@toniher
toniher / Amazon Linux 2 - Virtualbox - README.md
Last active October 18, 2022 18:13
Cloud init setup for testing Amazon Linux 2 image in a Virtualbox environment
@toniher
toniher / fd-du-sum.sh
Last active November 26, 2021 13:42
Count how much space (in GB) is occupied by FASTA files in a directory from the command-line
echo "scale=2; $(fd --full-path -t f --regex '\.fa+$|\.fasta$' /nfs/db/ensembl -x du {}|datamash sum 1) / (1024^3)" | bc
@toniher
toniher / mail-no-httpcode.sh
Created August 9, 2021 12:52
Detects HTTP code of a server and mail a warning message if none of the expected HTTP codes are found
#!/usr/bin/env bash
# Placed in a different machine than production with a cron
# Server
URL="https://example.com"
HTTP=$(curl --silent --insecure -m 30 -I GET "${URL}"|perl -lane 'if ($_=~/HTTP/) {$_=~/HTTP\S+\s+(\d+)\s+/; print $1;} ')
# Normal situation codes
CODES=(200)
MSG="Something is wrong with ${URL}. CODE: ${HTTP}"
@toniher
toniher / dovecot-custom.conf
Created April 18, 2021 10:22
dovecot-custom.conf for fail2ban
[INCLUDES]
before = common.conf
[Definition]
_auth_worker = (?:dovecot: )?auth(?:-worker)?
_daemon = (?:dovecot(?:-auth)?|auth)
prefregex = ^%(__prefix_line)s(?:%(_auth_worker)s(?:\([^\)]+\))?: )?(?:%(__pam_auth)s(?:\(dovecot:auth\))?: |(?:pop3|imap)-login: )?(?:Error: )?<F-CONTENT>.+</F-CONTENT>$
on:
push:
branches:
# Default branches below
- main
- master
name: renderbook
@toniher
toniher / mediawiki-phpbrew.md
Last active April 18, 2020 11:11
PHP installation via phpbrew for MediaWiki

phpbrew install php-7.2.28 +default +mcrypt +hash +exif +mbstring +zip +fileinfo +ctype +zlib +curl +xml +mysql +xmlrpc +iconv +intl +fpm +sqlite +openssl=shared -- --with-libdir=lib64

phpbrew ext install redis latest

@toniher
toniher / docker2singularity.sh
Last active February 2, 2020 07:52
Bash script wrapper for generating a singularity image from a local Docker image
#!/bin/bash
# Based on https://github.com/sylabs/singularity/issues/1537
# Usage: bash docker2singularity.sh mydockerimg mysingularity.simg
set -ueo pipefail
IMG=$1
FILEOUT=$2
PORT=${3:-5000}
@toniher
toniher / Dockerfile
Created September 3, 2016 07:39
Example of changing uid and gid of a Docker image - MariaDB
FROM mariadb:10.1
# To be changed here
ENV MYSQL_UID 27
ENV MYSQL_GID 27
RUN usermod -u $MYSQL_UID mysql; groupmod -g $MYSQL_GID mysql;
RUN chown -R mysql:mysql /var/lib/mysql /var/run/mysqld