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
@pditommaso
pditommaso / fasta_reader.pl
Created September 24, 2011 15:29
Read a FASTA Formatted file using BioPERL
use strict;
use Bio::SeqIO;
my $in = Bio::SeqIO->new(-file => "input.fa",-format => 'Fasta');
my $seq;
while ( $seq = $in->next_seq() ) {
print $seq->display_id() . " - " . $seq->seq() . "\n";
}
/*
* This is script for the Jenkins email-ext plugin.
* It make it possibile to send a mail for failing downstream jobs to
* source committer. It have to be used for.
*
* Usage: save this script in $JENKINS_HOME/email-templates/committers.groovy
* In the job configuration use the value "${SCRIPT, script="committers.groovy"}"
* in the field "Global Recipient List" for the component "Editable Email Notification"
*
*/
@pditommaso
pditommaso / gist:2265496
Created March 31, 2012 14:26
Read/write input/output stream of interactive process
import java.io.*;
public class TestProcessIO {
public static boolean isAlive(Process p) {
try {
p.exitValue();
return false;
}
catch (IllegalThreadStateException e) {
@pditommaso
pditommaso / gist:2320504
Created April 6, 2012 14:47
Shell script preamble to make a executable JAR self invocable
#!/bin/sh
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
@pditommaso
pditommaso / gist:2419893
Created April 19, 2012 09:12
Return the list of a method parameters names
/**
* Based on Stackoverflow answer http://stackoverflow.com/a/2729907/395921
*
* @author Paolo Di Tommaso
*
*/
public class Names {
/**
@pditommaso
pditommaso / gist:2553480
Created April 29, 2012 22:03
Trap Ctrl+Z key press
#!/bin/bash
trap "echo You\'re trying to Control-z me" SIGTSTP
while :; do
:
done
@pditommaso
pditommaso / MemoryMappedFile.scala
Created June 12, 2012 22:17 — forked from daggerrz/MemoryMappedFile.scala
Memory mapping files larger than Integer.MAX_VALUE
import java.io.RandomAccessFile
import java.nio.channels.FileChannel
import org.jboss.netty.buffer.{ByteBufferBackedChannelBuffer, ChannelBuffer, ChannelBuffers}
/**
* Maps a the filename to a memory mapped random access file across 1 or more buffers.
* Support files up to Long.MAX_VALUE.
*
* @param filename the file to map
* @param maxBufferSize the maximum number of bytes to map per buffer
@pditommaso
pditommaso / gist:3053430
Created July 5, 2012 12:28
clean-folder
#!/bin/env groovy
/*
* Delete all the files which name ends with the suffix '_debug' except the most recent 10
*/
def cli = new CliBuilder(usage:'clean-folder.groovy [-d] <folder to clean>')
cli.d('delete old files')
def options = cli.parse(args)
if( options.arguments().size() != 1 ) {
@pditommaso
pditommaso / gist:4595210
Created January 22, 2013 14:52
Circo cloud cluster boostrap
#!/bin/bash
export AWS_ACCESS_KEY=omissis
export AWS_SECRET_KEY=omissis
export CIRCO_CLUSTER=circotest1
curl http://cbcrg-eu.s3.amazonaws.com/circo-cloud-bootstrap.sh | bash &> circo-boot.log
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Stack;
/**
* An example class for directed graphs. The vertex type can be specified.