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:
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 / 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
@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 / pergola-webservice.py
Created March 7, 2019 12:04
Webservice script for using pergola through the Web
# -*- coding: utf-8 -*-
"""
Pergola webservice client
~~~~~~~~~~~~~~~~~~~~~~~~~~~
More details at: https://pergola.crg.eu
Usage: python pergola-webservice.py myconfig.json myoutput.zip
"""
import requests
import json
import sys
@toniher
toniher / parseGff.pl
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
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}