Skip to content

Instantly share code, notes, and snippets.

View nylander's full-sized avatar

Johan Nylander nylander

View GitHub Profile
@nylander
nylander / md2beamer
Created October 30, 2025 12:41
Markdown to beamer presentation in PDF using pandoc
#!/bin/bash
# Convert Markdown to PDF (beamer) using pandoc
# Last modified: mån sep 07, 2020 03:05
# Johan Nylander
for f in "$@"
do
echo -n "Converting $f ..."
g=${f%.md}.pdf
@nylander
nylander / md2pdf
Last active October 30, 2025 12:42
Mardown to PDF conversion using pandoc
#!/bin/bash
# Convert Markdown to PDF using pandoc
# Last modified: tor aug 20, 2020 02:51
# Johan Nylander
# TODO: set mainfont to allow for special characters () -V 'mainfont:xxx xx'
hash pandoc 2>/dev/null || { echo >&2 "Cannot find pandoc. Aborting."; exit 1; }
for f in "$@"
@nylander
nylander / fas2nex.stdinout
Created October 30, 2025 12:17
Simple fasta to nexus converter reading from stdin and writingto stdout

FILE: fas2nex.stdinout

        USAGE: ./fas2nex.stdinout <input>
@nylander
nylander / loops.md
Last active October 13, 2025 08:18

Loops

  • Last modified: Mon Oct 13, 2025
  • Sign: Johan Nylander

Description

Examples of doing the same thing on many input files. Often called "loops" (since after being done with the first file, we return to the binning of our commands and do it all over again).

@nylander
nylander / summary
Last active August 14, 2025 17:24
Summarize integer values from stdin using R
#!/usr/bin/env Rscript
# File: summary
# Description: Summarize data from stdin as min, max, mean, median
# Requirements: R
# Usage example: for i in $(seq 1 100); do echo $RANDOM; done | summary
# 288 32697 14644.19 14256
a <- scan(file("stdin"), c(0), quiet=TRUE);
cat(min(a), max(a), mean(a), median(a), "\n");
@nylander
nylander / blast2fasta.sh
Created October 10, 2023 11:43
Convert blast output with sseq as last column to fasta
#! /bin/bash
# blast2fasta
# Parse output from blast where we have sseq as the last column.
# For example (argument to blastn): "-outfmt '6 qseqid sseq'".
# Reads from file, writes to stdout.
# By Johan Nylander
# 2023-Oct-10
# Usage: blast2fasta.sh file
file=$1
awk '{printf ">%s", $1; for(i=2;i<NF;i++) printf " %s", $i; printf "\n%s\n", $NF}' "$file"
@nylander
nylander / create_sample_sheet.pl
Created June 15, 2023 09:16
Create a sample sheet from NGI (SciLifeLab) sequencing delivery
#!/usr/bin/env perl
=pod
=encoding utf8
=head1 NAME
create_sample_sheet.pl - Create sample sheet from NGI delivery
@nylander
nylander / FortiClientVPN
Last active October 28, 2025 11:09
Start/stop script for FortiClient VPN on Linux
#!/usr/bin/env bash
# Start/stop FortiClient VPN
# Last modified: ons mar 15, 2023 03:47
# Sign: JN
# To disable starting forticlient after reboot:
# 1. Comment out the command (edit and add an `#` in front of the line) in file
# `/opt/forticlient/start-fortitray-launcher.sh`
# 2. `sudo systemctl disable forticlient-scheduler`
# After step 1 and 2 above, forticlient daemon will not start after reboot. To
@nylander
nylander / gist:162791ff4986abf86864a22896fddc14
Last active April 5, 2022 08:08
Fix error in python for installing nf-core on Ubuntu 20.04, python 3.8
Recently, I tried to upgrade [nf-core](https://nf-co.re/) on my Ubuntu Linux but the execution after installation failed with errors from a python module.
Upgrading the python library ["rich"](https://rich.readthedocs.io/en/stable/introduction.html) solved the issue.
Steps below:
```
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
@nylander
nylander / fasta2nexus.pl
Created May 21, 2021 09:51
Fasta to Nexus converter using BioPerl
#! /usr/bin/env perl
#
# Short description for fasta2nexus.pl
#
# Author nylander <[email protected]>
# Version 0.1
# Copyright (C) 2021 nylander <[email protected]>
# Modified On 2021-05-21 10:54
# Created 2021-05-21 10:54
#