Skip to content

Instantly share code, notes, and snippets.

View wookietreiber's full-sized avatar
🎸

♫ Christian Krause ♫ wookietreiber

🎸
View GitHub Profile
@JM1
JM1 / Ansible_Roles_with_OS-specific_Defaults.md
Last active May 30, 2024 12:02
Ansible Roles with OS-specific defaults

Ansible Roles with OS-specific Defaults

This Ansible guide discusses several approaches on how to set different role default variables based / depending on the host operating system aka ansible_distribution / ansible_facts.distribution or other variables. For example, a role variable image_uri should point to the latest cloud image for the host. For CentOS 8 or Red Hat Enterprise Linux (RHEL) 8 the default value should be:

@moonwatcher
moonwatcher / bcl2fastq2_2_20_0_xml_writer_make_settings.patch
Created January 5, 2018 19:21
patch for compiling bcl2fastq on linux with boost 1.58
--- src/cxx/lib/io/Xml.cpp 2018-01-05 14:12:25.000000000 -0500
+++ src/cxx/lib/io/Xml.cpp 2018-01-05 14:12:35.000000000 -0500
@@ -168,19 +168,11 @@
if (!tree.empty())
{
unindex(*tree.begin(), treeWithIndexAttributes);
-#ifndef WIN32
- boost::property_tree::write_xml(os, treeWithIndexAttributes, boost::property_tree::xml_writer_make_settings(' ', 2));
-#else
boost::property_tree::write_xml(os, treeWithIndexAttributes, boost::property_tree::xml_writer_make_settings<std::string>(' ', 2));
@wookietreiber
wookietreiber / README.md
Last active November 17, 2017 16:04
extract git history from only a few files

install git extract

  1. clone this repository

    git clone https://gist.github.com/wookietreiber/290e909a39cf7a02c8e89290e6fc4fed git-extract
    
  2. make git-extract script available to your shell

mkdir -p ~/bin

@wookietreiber
wookietreiber / rng-get-seed.scala
Last active September 29, 2017 11:07
java.util.Random get seed
import java.util.{ Random => JRandom }
import java.util.concurrent.atomic.AtomicLong
import scala.util.Random
val rng = new Random
val seedField = classOf[JRandom].getDeclaredField("seed")
seedField.setAccessible(true)
val seed = seedField.get(rng.self).asInstanceOf[AtomicLong].get
@wookietreiber
wookietreiber / split-with-header.sh
Created August 25, 2017 11:19
split a file into pieces but keep a common header of first n lines
#!/bin/bash
export SPLIT_header_n=$1
target_size=$2
export SPLIT_input_file=$3
target_wo_header=$(( "$target_size" - "$SPLIT_header_n" ))
[[ -n $SPLIT_input_file ]] || {
echo "usage: $(basename "$0") SPLIT_header_n target_n SPLIT_input_file" >&2
@wookietreiber
wookietreiber / git-hook-ansible-lint.sh
Last active March 26, 2018 08:11
git pre-commit hook to check ansible yaml files with ansible-lint
#!/bin/bash
if git rev-parse --verify HEAD &> /dev/null ; then
against=HEAD
else
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
files=$(
git diff-index --cached --name-only $against |
@wookietreiber
wookietreiber / git-hook-lintr.r
Last active April 1, 2019 22:11
git pre-commit hook to check R scripts with lintr via littler
suppressMessages(library(lintr))
files <- commandArgs(trailingOnly = T)
messages <- function(file) {
result <- lint(file)
print(result)
return(length(result))
}
@wookietreiber
wookietreiber / git-hook-shellcheck.sh
Last active April 27, 2021 05:15
git pre-commit hook to check shell scripts with shellcheck
#!/usr/bin/env bash
set -efu -o pipefail
# returns staged files
function staged.files {
if git rev-parse --verify HEAD &> /dev/null
then
against=HEAD
else
@wookietreiber
wookietreiber / git-hook-delegate.sh
Last active July 31, 2017 16:22
git hook delegate
#!/bin/bash
GIT_HOOK_DIR="$0.d"
if [[ -d $GIT_HOOK_DIR ]] ; then
while IFS= read -r -d $'\0' hook ; do
"./$hook" || error="yes"
done < <(find "$GIT_HOOK_DIR" -mindepth 1 -print0)
[[ -n $error ]] && exit 1
@wookietreiber
wookietreiber / README.md
Last active December 20, 2022 14:00
R - Command Line Interface (CLI) and RStudio - template

R - Interactive Sessions and Command Line Interface

This is a template for R projects that should work both on the command line as well as in an interactive session.

Template Files

The template is made up of three files:

  1. foo.r