Skip to content

Instantly share code, notes, and snippets.

View stevekm's full-sized avatar

Stephen Kelly stevekm

View GitHub Profile
@stevekm
stevekm / main.go
Created November 1, 2023 16:48
Go program to read and write a .gz file (fastq.gz)
package main
import (
"fmt"
// "compress/gzip"
gzip "github.com/klauspost/pgzip"
"bufio"
"os"
"log"
)
@stevekm
stevekm / gist:637897ececa2b493fd9b5b0ab91590dd
Created November 7, 2022 17:05
Python multiprocessing Pool apply_async example
#!/usr/bin/env python3
# do an action in parallel across multiple threads in Python
# example: get the average of lists of numbers
# references;
# https://stackoverflow.com/questions/8533318/multiprocessing-pool-when-to-use-apply-apply-async-or-map
# https://e2eml.school/multiprocessing.html
# https://docs.python.org/3.7/library/multiprocessing.html#multiprocessing.pool.Pool.apply_async
@stevekm
stevekm / Git-Diff.md
Last active September 9, 2021 14:52
git diff explanation & gdiff shortcut

A visual example for interpretting the output of git diff, along with a helper alias gdiff to make it easier to git diff two files or directories.

Example input files:

$ cat example1.txt
Sample1
Sample2
Sample3
Sample4
@stevekm
stevekm / email.py
Created July 8, 2021 20:25
Python helper module for writing and sending emails
#!/usr/bin/env python
"""
Module to send email messages
https://www.tutorialspoint.com/python/python_sending_email.htm
"""
import getpass
import smtplib
# default global configs
@stevekm
stevekm / mac.md
Last active April 12, 2019 15:46
Mac Guide

Programs to install on your MacBook

Essentials

  • Application manager for OS X
  • some homebrew downloads you might need:
brew tap caskroom/cask
@stevekm
stevekm / squeue2json.py
Created December 5, 2018 22:59
Convert SLURM squeue output to JSON format
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Convert SLURM squeue output to JSON format
"""
import subprocess as sp
import json
process = sp.Popen(['squeue', '-o', '%all'], stdout = sp.PIPE, stderr = sp.PIPE, shell = False, universal_newlines = True)
proc_stdout, proc_stderr = process.communicate()
@stevekm
stevekm / Preferences.sublime_settings
Last active June 28, 2018 15:56
Settings for Sublime Text, Atom editor, iTerm, etc
{
"draw_white_space": "all",
"font_size": 17,
"open_files_in_new_window": false,
"scroll_past_end": true,
"update_check": false
}
@stevekm
stevekm / index.html
Created January 11, 2018 01:03 — forked from pathunstrom/index.html
Dual Movement
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.box {
height: 100px;
width: 100px;
top: 100px;
@stevekm
stevekm / dumb.R
Created December 27, 2017 17:37
stupid R error
> install.packages("ggrepel")
also installing the dependencies ‘viridisLite’, ‘scales’, ‘ggplot2’
trying URL 'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/viridisLite_0.2.0.tgz'
Content type 'application/x-gzip' length 54110 bytes (52 KB)
==================================================
downloaded 52 KB
trying URL 'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/scales_0.5.0.tgz'
Content type 'application/x-gzip' length 336683 bytes (328 KB)
stat_smooth_func <- function(mapping = NULL, data = NULL,
geom = "smooth", position = "identity",
...,
method = "auto",
formula = y ~ x,
se = TRUE,
n = 80,
span = 0.75,
fullrange = FALSE,
level = 0.95,