Skip to content

Instantly share code, notes, and snippets.

View toniher's full-sized avatar

Toni Hermoso Pulido toniher

View GitHub Profile
#!/usr/bin/env python
import sys
import json
if len(sys.argv) != 2:
print("{\"docs\": [")
with open(sys.argv[1]) as infile:
toniher / Amazon Linux 2 - Virtualbox -
Last active October 18, 2022 18:13
Cloud init setup for testing Amazon Linux 2 image in a Virtualbox environment
toniher /
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:
#!/usr/bin/env bash
if [ ! -e $CONFILE ]; then
echo "$CONFILE does not exist"
toniher /
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 /
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
HTTP=$(curl --silent --insecure -m 30 -I GET "${URL}"|perl -lane 'if ($_=~/HTTP/) {$_=~/HTTP\S+\s+(\d+)\s+/; print $1;} ')
# Normal situation codes
MSG="Something is wrong with ${URL}. CODE: ${HTTP}"
toniher / dovecot-custom.conf
Created April 18, 2021 10:22
dovecot-custom.conf for fail2ban
before = common.conf
_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>$
# Default branches below
- main
- master
name: renderbook
toniher /
Created March 7, 2019 12:04
Webservice script for using pergola through the Web
# -*- coding: utf-8 -*-
Pergola webservice client
More details at:
Usage: python myconfig.json
import requests
import json
import sys
toniher /
Created February 14, 2019 11:23
Handy parse of GFF files
#!/usr/bin/env perl
# List of IDs - one per line
my $list = shift;
# File with potential IDs, it can be GFF but also othersH
my $gff = shift;
my @ids;
open( LIST, $list ) || die "Cannot open $list";
toniher /
Last active February 2, 2020 07:52
Bash script wrapper for generating a singularity image from a local Docker image
# Based on
# Usage: bash mydockerimg mysingularity.simg
set -ueo pipefail