Skip to content

Instantly share code, notes, and snippets.

View stevekm's full-sized avatar

Stephen Kelly stevekm

View GitHub Profile
@stevekm
stevekm / glob_examples.sh
Last active February 7, 2016 18:14
How to glob for filenames and iterate over them with a for loop
#!/bin/bash
#~~~ Shell Options ~~~~#
# use some extra shell glob features; turn them on here
# remember whether extglob was originally set, so we know whether to unset it
shopt -q extglob; extglob_set=$?
# set extglob if it wasn't originally set.
((extglob_set)) && shopt -s extglob
# Note, 0 (true) from shopt -q is "false" in a math context.
@stevekm
stevekm / unrar_passwords2.sh
Created February 7, 2016 18:18
On Mac OS X, unrar a bunch of files
#!/bin/bash
PassList="password1 password2 password3" && OldDir="$(pwd)"
for i in $PassList; do
for q in $(find . -name "*.rar"); do
echo "$q"
NewDir=$(dirname "$q")
echo -e "\t$NewDir"
cd "$NewDir"
~/Downloads/rar/unrar e -p${i} *.rar
@stevekm
stevekm / gist:c8b2545bc867202499e9
Last active February 22, 2016 18:06
How to remove large entries or files from git repository history and push the changes to update GitHub
First method (the hard way)
http://naleid.com/blog/2012/01/17/finding-and-purging-big-files-from-git-history
Second method (easier)
https://help.github.com/articles/removing-files-from-a-repository-s-history/
https://rtyley.github.io/bfg-repo-cleaner/
also see: http://stackoverflow.com/questions/2100907/how-to-remove-delete-a-large-file-from-commit-history-in-git-repository
https://help.github.com/articles/duplicating-a-repository/
https://help.github.com/articles/what-happens-to-forks-when-a-repository-is-deleted-or-changes-visibility/
http://stackoverflow.com/questions/16052477/delete-fork-dependency-of-a-github-repository
@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 / gist:cba096812b9b9e8106cb0ee128d72592
Created July 11, 2016 15:29
GitHub repository advanced search page, search multiple respositories, multiple users
I dunno why this is not readily visible from the main pages:
https://github.com/search/advanced
http://stackoverflow.com/questions/32119877/searching-in-multiple-github-repositories
@stevekm
stevekm / convert_FLAC_to_mp3.sh
Created August 11, 2016 20:05
Use FFMPEG to convert FLAC to MP3
#!/bin/bash
# on OS X, need to install ffmpeg
# so that we can convert FLAC music files
# into mp3 files
# install ffmpeg
brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-libvorbis --with-libvpx --with-opus --with-x265
brew update && brew upgrade ffmpeg
@stevekm
stevekm / virtualenv_madness
Created August 16, 2016 18:19
trying to get virtualenv installed on my MacBook Pro, running OS X El Capitan..
Its already installed:
$ pip install virtualenv
Requirement already satisfied (use --upgrade to upgrade): virtualenv in ./Library/Python/2.7/lib/python/site-packages
But it doesn't work
$ virtualenv
-bash: virtualenv: command not found
@stevekm
stevekm / gist:3d5db084bb868c9bdfb4fcb4d27f7aa7
Last active September 29, 2016 23:22
python bin paths on OS X
Anaconda python:
/Users/$USER/anaconda/bin/python
system python
/usr/local/bin/python
/Library/Python/2.7/site-packages/
@stevekm
stevekm / gist:45a76ed129e4da7e39f2f1c1c85e61fa
Created September 4, 2016 15:58
md5 checksum of all your files
sudo find /media/steve/Orchard/home/steve/ -type f -exec md5sum {} \; > /home/steve/Orchard_files.txt