Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin Manalo kmanalo

  • Georgia Tech
View GitHub Profile
@kmanalo
kmanalo / gist:5e98a8b2e7b88adbb892678689fa696f
Created May 11, 2021
Singularity Recipe for MultiBUGS
View gist:5e98a8b2e7b88adbb892678689fa696f
bootstrap: docker
from: ubuntu:18.04
%help
This will run MultiBUGS
%environment
export PATH=/opt/multibugs:${PATH}
%post
View check_for_tab.awk
#!/usr/bin/awk
BEGIN {
FS = "\t"
}
{
if (NF-1 > 0) {
print "has tab"
}
}
{ exit 1 }
View conditional_argparse.py
import argparse
import sys
parser = argparse.ArgumentParser()
action1 = parser.add_argument('--user', help="username")
action2 = parser.add_argument('--bar',
help="Only use this if --user is set")
action3 = parser.add_argument('--bar2',
help="Only use this if --user is set")
argv = set(sys.argv)
View itertools-range.py
import operator
import itertools
def contiguous_range(data):
""" determine continguous ranges of integer data """
cr_data = []
for k, g in itertools.groupby(enumerate(data), lambda (i,x):i-x):
cr_data.append(map(operator.itemgetter(1), g))
return cr_data
@kmanalo
kmanalo / twiddlecase.vim
Last active Aug 29, 2015
twiddlecase.vim
View twiddlecase.vim
" https://github.com/tangledhelix/dotfiles/blob/master/vim/plugin/twiddlecase.vim
" Toggles between uppercase, lowercase, titlecase. Bind to a mapping, then
" select something and keep hitting the map until you get what you want.
function! TwiddleCase(str)
if a:str ==# toupper(a:str)
let result = tolower(a:str)
elseif a:str ==# tolower(a:str)
let result = substitute(a:str,'\(\<\w\+\>\)', '\u\1', 'g')
else
View states.py
us_states = [
'Alabama',
'Alaska',
'Arizona',
'Arkansas',
'California',
'Colorado',
'Connecticut',
'Delaware',
'Florida',
View argparse.gist
# argparse section
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--email", help="send to specific email")
parser.add_argument("--console", action="store_true", default=False, help="push results to stdout")
# grab the options here from the command line, console overrides email
args = parser.parse_args()
@kmanalo
kmanalo / folder_tree.gist
Last active Jan 1, 2016
Showing the folder tree with Python
View folder_tree.gist
# reference http://stackoverflow.com/a/9728478/992834
import os
def list_files(startpath):
for root, dirs, files in os.walk(startpath):
level = root.replace(startpath, '').count(os.sep)
indent = ' ' * 4 * (level)
print('{}{}/'.format(indent, os.path.basename(root)))
subindent = ' ' * 4 * (level + 1)