Skip to content

Instantly share code, notes, and snippets.

View wookietreiber's full-sized avatar
🎸

♫ Christian Krause ♫ wookietreiber

🎸
View GitHub Profile
@wookietreiber
wookietreiber / StringInputStream.scala
Created March 13, 2015 07:28
Scala StringInputStream: have a String and read from it with an InputStream
import java.io.InputStream
class StringInputStream(s: String) extends InputStream {
private val bytes = s.getBytes
private var pos = 0
override def read(): Int = if (pos >= bytes.length) {
-1
} else {
@wookietreiber
wookietreiber / optLast.scala
Created October 19, 2014 10:28
last option for scala scripts
import annotation.tailrec
def optLast[A](opts: String*)(convert: String => Option[A])(implicit args: List[String]): Option[A] = {
val longOpts = opts filter { _ startsWith "--" }
val longOptsRE = longOpts.mkString("^(","|",")=(.+)").r
@tailrec def optLastInternal(current: Option[A], args: List[String]): Option[A] = args match {
case Nil =>
current
@wookietreiber
wookietreiber / qrunnerstats.scala
Last active August 10, 2018 12:52
list short per user waiting job and slots stats of grid engine managed clusters, see full collection: https://github.com/wookietreiber/grid-engine-tools
// this gist has been superseded by
// https://github.com/idiv-biodiversity/grid-engine-tools
@wookietreiber
wookietreiber / qwaiterstats.scala
Last active August 10, 2018 12:53
list short per user running job and slots stats of grid engine managed clusters, see full collection: https://github.com/wookietreiber/grid-engine-tools
// this gist has been superseded by
// https://github.com/idiv-biodiversity/grid-engine-tools
@wookietreiber
wookietreiber / ZipInvert.scala
Created April 5, 2014 13:45
Scala inverted zip extension method
import language.higherKinds
import collection.GenIterable
import collection.generic.CanBuildFrom
implicit class ZipInvert[A,CC[X] <: GenIterable[X]](coll: CC[A]) {
def zipInvert[A1 >: A, B, That](that: GenIterable[B])(implicit bf: CanBuildFrom[CC[A], (B, A1), That]): That = {
val b = bf(coll)
val these = coll.iterator
val those = that.iterator
@wookietreiber
wookietreiber / ffmpeg-convert-animation.sh
Last active August 29, 2015 13:57
ffmpeg-based animation converter, converts from * to high quality x264 and good libvorbis, is quite slow, however
#!/bin/bash
[[ -z $2 ]] && {
echo "usage $0 /path/to/movie/in /path/to/movie/out" > /dev/stderr
exit 1
}
PRESET=veryslow
TUNE=animation
CRF=18
@wookietreiber
wookietreiber / imap-check.scala
Last active August 29, 2015 13:57
Checks your IMAP folders for new and unread messages.
#!/bin/bash
cd "$(dirname "$0")"
[[ ! -d lib ]] &&
mkdir lib
[[ ! -e lib/java-mail.jar ]] &&
wget -q -O lib/java-mail.jar http://search.maven.org/remotecontent?filepath=com/sun/mail/javax.mail/1.5.1/javax.mail-1.5.1.jar
@wookietreiber
wookietreiber / qmemload.scala
Last active August 10, 2018 12:55
compare and list free memory vs consumable memory of compute nodes of SGE managed clusters, see full collection: https://github.com/wookietreiber/grid-engine-tools
// this gist has been superseded by
// https://github.com/idiv-biodiversity/grid-engine-tools
@wookietreiber
wookietreiber / qjutil.scala
Last active August 10, 2018 12:55
list jobs incorrectly using their requested slot amount of SGE managed clusters (compares accumulated cputime with runtime * slots), see full collection: https://github.com/wookietreiber/grid-engine-tools
// this gist has been superseded by
// https://github.com/idiv-biodiversity/grid-engine-tools