Skip to content

Instantly share code, notes, and snippets.

View pditommaso's full-sized avatar
💭
Vita brevis, ars longa

Paolo Di Tommaso pditommaso

💭
Vita brevis, ars longa
View GitHub Profile
{ cat <<EOF
aws s3 ls s3://bucket/prefix1
aws s3 ls s3://bucket/prefix2
aws s3 ls s3://bucket/prefix3
EOF
} | xargs -I{} -P 10 bash -c "{}"
@pditommaso
pditommaso / optional-input.nf
Created March 23, 2018 14:07
Nextflow optional input
params.filter_seqs = 'NO_FILTER'
filter_file = file(params.filter_seqs)
process foo {
input:
file filter_file
script:
def filter_argument = filter_file.name != 'NO_FILTER' ? "--filter ${params.filter_seqs}" : ''
@pditommaso
pditommaso / optional-input.nf
Created March 13, 2018 08:14
Nextflow optional input workaround
params.filter_seqs = 'NO_FILTER'
filter_file = file(params.filter_seqs)
process foo {
input:
file filter_file
script:
def filter_argument = filter_file.name != 'NO_FILTER' ? "--filter ${params.filter_seqs}" : ''
@pditommaso
pditommaso / 00_cmd.sh
Created January 24, 2018 23:14 — forked from lh3/00_cmd.sh
Scripts and command lines to create universal mask for hs37d5
#
# generate 01compositional.bed.gz
#
# low-complexity by mDUST
mdust hs37d5.fa -c -w7 -v28 \
| hs37d5.mdust-w7-v28.txt \
| cut -f1,3,4 \
| gawk -vOFS="\t" '{--$2;print}' \
| bgzip > 01compositional/hs37d5.mdust-w7-v28.bed.gz
@pditommaso
pditommaso / Generics.java
Last active January 16, 2018 09:10
Some generics craziness
public class Generics {
void wildcard() {
List<?> stuff = new ArrayList<>();
stuff.add("xx"); // NOT ok
stuff.add(new Object()); // NOT ok
stuff.size(); // OK
List<?> a = new ArrayList<Object>(); // OK
List<?> b = new ArrayList<String>(); // OK
@pditommaso
pditommaso / raid_ephemeral.sh
Last active December 23, 2017 23:14 — forked from joemiller/raid_ephemeral.sh
detect all ephemeral disks on EC2 then stripe together in a raid-0 vol mounted at /mnt
#!/bin/bash
#
# this script will attempt to detect any ephemeral drives on an EC2 node and create a RAID-0 stripe
# mounted at /mnt. It should be run early on the first boot of the system.
#
# Beware, This script is NOT fully idempotent.
#
METADATA_URL_BASE="http://169.254.169.254/2012-01-12"
yum -y -d0 install mdadm curl
@pditommaso
pditommaso / sync.groovy
Created August 2, 2017 23:18
Prevent multiple JVM to access concurrently the same file
import java.nio.channels.FileLock
final file = new RandomAccessFile(new File("foo.lock"), "rw")
println "<Entering in critical section>"
try {
/*
* wait to acquire a lock
*/
def secs = 0
FileLock lock
@pditommaso
pditommaso / NF_logo.png
Created June 14, 2017 15:53 — forked from ewels/NF_logo.png
NextFlow Multipart HTML Emails
Save NextFlow logo as this file.
@pditommaso
pditommaso / Hello.g4
Created March 26, 2017 13:55 — forked from mattmcd/Hello.g4
Simple ANTLR4 grammar example
// define a grammar called Hello
grammar Hello;
r : 'hello' ID;
ID : [a-z]+ ;
WS : [ \t\r\n]+ -> skip ;
@pditommaso
pditommaso / spinner.sh
Created March 23, 2017 13:40
BASH spinner
spinner()
{
local pid=$1
local delay=0.75
local spinstr='|/-\'
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
local temp=${spinstr#?}
printf " [%c] " "$spinstr"
local spinstr=$temp${spinstr%"$temp"}
sleep $delay