Skip to content

Instantly share code, notes, and snippets.

View hlapp's full-sized avatar

Hilmar Lapp hlapp

View GitHub Profile
#!/bin/bash
# Reboots if there is no network device for the global route.
#
# Hilmar Lapp <hlapp@drycafe.net>
#
# To the extent possible under law, I have waived all copyright and related
# or neighboring rights to this work under the CC0 1.0 Universal Public Domai
# Dedication. See https://creativecommons.org/publicdomain/zero/1.0
@hlapp
hlapp / respool-at-pace.sh
Last active January 2, 2018 17:45
Moves files from a source directory to a destination directory, one at a time, with a delay, which extends when the destination directory accumulates files. One use-case is feeding a large number of files into a spool directory where they get processed.
#!/bin/bash
set -e
src=${1:-.}
dest=$2
if [ -z "$dest" ] ; then
dest="$1"
fi
@hlapp
hlapp / network-watch.sh
Last active May 19, 2018 19:45
Test whether the network connection to the local gateway is up, and if not, reset the network interface, and if necessary also avahi
#!/bin/bash
# Tests whether the network connection to the local router is up. If not,
# resets the network interface that was supposed to be connected. After
# that tests whether multicast DNS resolution of the localdomain hostname
# is still working, and if not, resets the avahi daemon as well.
#
# Hilmar Lapp <hlapp@drycafe.net>
#
# To the extent possible under law, I have waived all copyright and related

Keybase proof

I hereby claim:

  • I am hlapp on github.
  • I am hlapp (https://keybase.io/hlapp) on keybase.
  • I have a public key whose fingerprint is 259A 0B06 CA2A 2BDC 9068 AFE8 E78C 88C1 5115 9122

To claim this, I am signing this object:

library(whisker)
library(knitr)
responses <- read.csv(file="applicants.csv", stringsAsFactors=FALSE)
# names(responses)[ncol(responses)] <- "attendance"
responses_lst <- apply(responses, 1, function(x) as.list(x))
template <- "
--------------------
allenday = Allen Day <allenday@allenday.com>
bobular = Bob MacCallum <r.maccallum@imperial.ac.uk> ?
boconnor = Brian O'Connor <briandoconnor@gmail.com>
briano = briano <briano>
cmungall = Chris Mungall <cmungall@gmail.com>
cpommier_gmod = cpommier_gmod <cpommier_gmod>
cwiel = cwiel <cwiel>
daveclements = Dave Clements <clements@galaxyproject.org>
dongilbert = dongilbert <dongilbert>
e-just = e-just <e-just>
@hlapp
hlapp / benchmarking_java
Created October 24, 2012 15:41 — forked from dongyemeng/benchmarking_java
Test the performance of java on regex. There are 5 cases. I put the running time of each on my machine as comment. You can remove the "/*" and "*/" of any case to run on it.
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class benchmarking_java {
public static void main(String[] args) {
// regular expression
//Pattern pattern = Pattern.compile("^.*(.*?)<i>\\s*([^<]*)\\s*<\\/i>(.*).*$");
Pattern pattern = Pattern.compile("^(.*?)<i>\\s*([^<]*)\\s*<\\/i>(.*)$");
long startTime = 0;
<?xml version="1.0" encoding="ISO-8859-1"?>
<nex:nexml
version="0.9"
xsi:schemaLocation="http://www.nexml.org/2009 http://www.nexml.org/2009/nexml.xsd"
xmlns:phen="http://www.bioontologies.org/obd/schema/pheno"
xmlns:gml="http://www.opengis.net/gml"
xmlns:dwc="http://rs.tdwg.org/dwc/terms/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns="http://www.nexml.org/2009"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@hlapp
hlapp / gist:2629846
Created May 7, 2012 19:28
TreEvo for-loop optimization example 1: before and after
##
# before for-loop optimization
##
getSimulationSplits<-function(phy) {
phy$node.label<-NULL
branchingTimes<-sort(branching.times(phy), decreasing=TRUE)
branchingTimesNames<-names(branchingTimes)
ancestorVector<-c()
descendant1Vector<-c()
descendant2Vector<-c()
@hlapp
hlapp / toward-babelphyish-test.pl
Created March 8, 2012 20:04
Test-driven development example for BabelPhysh PhyloSoC project idea
#!/usr/bin/perl
use strict;
use warnings;
use Bio::NEXUS;
use Bio::TreeIO;
use Bio::AlignIO;
use Bio::Phylo::IO;
use Bio::Phylo::Factory;
use Bio::Phylo::Forest::Tree;