Skip to content

Instantly share code, notes, and snippets.

@elowy01
elowy01 / BCFtools cheat sheet
Last active May 21, 2024 10:59
BCFtools cheat sheet
*bcftools filter
*Filter variants per region (in this example, print out only variants mapped to chr1 and chr2)
qbcftools filter -r1,2 ALL.chip.omni_broad_sanger_combined.20140818.snps.genotypes.hg38.vcf.gz
*printing out info for only 2 samples:
bcftools view -s NA20818,NA20819 filename.vcf.gz
*printing stats only for variants passing the filter:
bcftools view -f PASS filename.vcf.gz
@holyjak
holyjak / monitor-usage.sh
Last active February 14, 2023 14:03
Script to monitor the usage of CPU, memory by a process via `top`
#!/bin/sh
##
## BEWARE: Check with your impl. of top what exactly it returns, it migth differ from mine
##
# Usage: ./monitor-usage.sh <PID of the process>
# Output: top.dat with lines such as `1539689171 305m 2.0`, i.e. unix time - memory with m suffix - CPU load in %
# To plot the output, see https://gist.github.com/holyjak/1b58dedae3207b4a56c9abcde5f3fdb5
export PID=$1
rm top.dat
while true; do top -p $PID -bn 1 -em | egrep '^ *[0-9]+' | awk -v now=$(date +%s.%N) '{print now,$6,$9}' >> top.dat; done
@ericnormand
ericnormand / 00_script.clj
Last active May 18, 2024 08:30
Boilerplate for running Clojure as a shebang script
#!/bin/sh
#_(
#_DEPS is same format as deps.edn. Multiline is okay.
DEPS='
{:deps {clj-time {:mvn/version "0.14.2"}}}
'
#_You can put other options here
OPTS='
@pjstadig
pjstadig / transducers.md
Last active June 8, 2021 13:22
The secret feature of transducers that no one talks about!

The Pledge

One thing that always made me a little sad about transducers was how map lost its ability to iterate multiple collections in parallel. This is actually my favorite feature of map. For example:

(map + (range 5) (range 5 10))
=> (5 7 9 11 13)

One somewhat practical use of this is if you want to compare two sequences, pairwise, using a comparator. Though I wish that every? took multiple collections, this is an adequate substitute:

import matplotlib.pyplot as plt
from PyQt5 import QtCore
import numpy as np
import time
import math
class VisualiseFrequency(QtCore.QThread):
def __init__(self, song, canvas, player):
@Efimero
Efimero / project.clj
Created May 8, 2019 12:09
LWJGL3 example implemented in Clojure (linux)
(defproject test-3d "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.10.0"]
[org.lwjgl/lwjgl "3.2.2"]
[org.lwjgl/lwjgl "3.2.2" :classifier "natives-linux"]
[org.lwjgl/lwjgl-opengl "3.2.2"]
[org.lwjgl/lwjgl-opengl "3.2.2" :classifier "natives-linux"]
@andy-thomason
andy-thomason / Genomics_A_Programmers_Guide.md
Created May 14, 2019 13:32
Genomics a programmers introduction

Genomics - A programmer's guide.

Andy Thomason is a Senior Programmer at Genomics PLC. He has been witing graphics systems, games and compilers since the '70s and specialises in code performance.

https://www.genomicsplc.com

@m-radzikowski
m-radzikowski / script-template.sh
Last active May 4, 2024 04:13
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@borkdude
borkdude / partial.md
Last active September 11, 2023 14:24
partial.md

Here's a list of things I collected a conversation on partial. Personally I think using partial almost never has a benefit, while there are some downsides to using it. There are exceptional cases where partial has a benefit, e.g. if you want to "wrap" a multi-arity function or a function with an unknown amount of arguments.

Some reasons not to use partial: