Skip to content

Instantly share code, notes, and snippets.

View danielecook's full-sized avatar
😀
Things are going good

Daniel E Cook danielecook

😀
Things are going good
View GitHub Profile
@danielecook
danielecook / GIF-Screencast-OSX.md
Created February 11, 2020 23:13 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@danielecook
danielecook / srun_camp.sh
Last active February 15, 2020 16:09
interactive job #camp #hpc
srun --ntasks=1 --cpus-per-task=3 --mem=4G --pty bash
@danielecook
danielecook / list_bams_missing_index.sh
Last active February 11, 2020 11:06
List bams with missing indices / index
function check_file {
if [ ! -s "$1" ]
then
echo "$1 not found"
fi
}
export -f check_file
# List bams with a missing bai index
ls -1 *.bam | parallel check_file {}.bai
$(patsubst %.vcf,%.vcf.gz,$(wildcard */*.vcf)) \
$(patsubst %.vcf.gz,%.vcf.gz.csi,$(wildcard */*.vcf.gz))
# Gzip VCFs and index if not present
%.vcf.gz: %.vcf
# gzipping $<
bcftools view --output-type z $< > $@
%.vcf.gz.csi: %.vcf.gz
bcftools index $<
@danielecook
danielecook / slugify.R
Created February 3, 2020 09:07
Slugify
slugify <- function(str) {
# Function for cleaning up column names
str %>%
stringr::str_replace_all("[^a-zA-Z0-9-]", "_") %>%
stringr::str_replace_all("-+", "_") %>%
stringr::str_replace("[_]{2,50}", "_") %>%
stringr::str_replace("_$", "") %>%
tolower()
}
@danielecook
danielecook / row_iterator.R
Last active April 19, 2020 15:02
R row iterator
rows <- function(tab, idx=TRUE) {
# Set idx to attach an index column
if (is.na(tab) || is.null(tab) || nrow(tab) == 0) {
return(list())
}
lapply(seq_len(nrow(tab)),
function(i) {
row <- unclass(tab[i,,drop=F])
if (idx) {
row$idx <- i
@danielecook
danielecook / Scientific-Readme-Template.md
Last active June 30, 2025 22:15 — forked from PurpleBooth/README-Template.md
A template to make good README.md for a scientific or data analysis project

Project Title

One Paragraph+ describing the project goes here. For example: This is a README template you would use to describe a scientific or data analysis project. Provide an overview of the goals of the project, how data was obtained, and other important details others or you in 6 months should be aware of.

Data

Describe the dataset in more detail here if necessary

Data Contact

@danielecook
danielecook / scontrol_info.sh
Created December 16, 2019 20:50
Get detailed info for slurm job #slurm
scontrol show job 7705252
@danielecook
danielecook / merge_files.sh
Created November 25, 2019 18:41
merge files, skip header after first
# https://stackoverflow.com/questions/10103619/unix-merge-many-files-while-deleting-first-line-of-all-files#10103758
tail -q -n +2 file1 file2 file3
@danielecook
danielecook / bash-cheatsheet.sh
Created November 22, 2019 09:50 — forked from LeCoupa/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04