Skip to content

Instantly share code, notes, and snippets.

View stevekm's full-sized avatar

Stephen Kelly stevekm

View GitHub Profile
@stevekm
stevekm / pdf_conversions.md
Last active May 3, 2024 19:33
Commands to convert multi-page PDF to/from multiple PNG files with GhostScript & ImageMagick
@stevekm
stevekm / 000-Cheat-Sheets.md
Created May 1, 2024 04:03 — forked from JoshuaEstes/000-Cheat-Sheets.md
Developer Cheat Sheets for bash, git, gpg, irssi, mutt, tmux, and vim. See my dotfiles repository for extra info.
@stevekm
stevekm / gist:e054544fe3849bd7173d4c9124577115
Created April 13, 2016 17:34
bowtie2 samtools stdout stderr stream redirection; print bowtie2 stderr to terminal AND copy it to a file
#!/bin/bash
# PROBLEM: want to preseve the terminal output from bowtie2, but also copy the stderr from bowtie into a separate file
# SOLUTION: use `tee` along with some bash stream redirection to copy the stderr stream to a new file AND print it on the terminal
# set files and places
tmp_fastq1="$HOME/projects/SmithLab_PARCLIP/14Q-sample1_R1_mini.fastq"
tmp_fastq2="$HOME/projects/SmithLab_PARCLIP/14Q-sample1_R2_mini.fastq"
tmp_outdir="$HOME/projects/SmithLab_PARCLIP/test_bowtie2"
@stevekm
stevekm / launchctl_man.md
Last active March 30, 2024 20:02
macOS OS X login items

[source]

This manual page is for Mac OS X version 10.9

If you are running a different version of Mac OS X, view the documentation locally:

    In Terminal, using the man(1) command

Reading manual pages
@stevekm
stevekm / pyshell.md
Last active March 10, 2024 14:49
Start an interactive Python shell session from within a script

from here: http://stackoverflow.com/questions/5597836/embed-create-an-interactive-python-shell-inside-a-python-program

paste this inside your script for debugging, to start a Python interactive terminal shell session at that point in the script, super useful for debugging since it lets you explore the Python environment and access objects and variables as they are at that point in the script.

import readline # optional, will allow Up/Down/History in the console
import code
vars = globals().copy()
vars.update(locals())
@stevekm
stevekm / ssh_server_commands.md
Last active December 4, 2023 15:02
handy ssh, rsync, scp commands

Here are some handy commands for connecting to servers and copying files about. These are all for Linux terminal / bash shell

Do cool things with ssh; log in & run command, find files in dir

# log into server
ssh username@server.edu -Y 
# -X      Enables X11 forwarding. <- use this to enable X11 graphical windows, but this will eventually time out & you'll lose the X11 connection
# -Y      Enables trusted X11 forwarding. <- this one preserves your X11 connection while you're logged in
@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 / igv_test_bat.md
Last active April 28, 2022 06:50
Sample Batch Script for IGV Snapshots
@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()