Skip to content

Instantly share code, notes, and snippets.

View kmanalo's full-sized avatar

Kevin Manalo kmanalo

  • Georgia Tech
View GitHub Profile
@kmanalo
kmanalo / folder_tree.gist
Last active January 1, 2016 06:09
Showing the folder tree with Python
# 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)
# 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()
us_states = [
'Alabama',
'Alaska',
'Arizona',
'Arkansas',
'California',
'Colorado',
'Connecticut',
'Delaware',
'Florida',
@kmanalo
kmanalo / twiddlecase.vim
Last active August 29, 2015 14:10
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
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
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)
@kmanalo
kmanalo / check_for_tab.awk
Created July 9, 2015 21:25
Check for Tabs
#!/usr/bin/awk
BEGIN {
FS = "\t"
}
{
if (NF-1 > 0) {
print "has tab"
}
}
{ exit 1 }
@kmanalo
kmanalo / gist:5e98a8b2e7b88adbb892678689fa696f
Created May 11, 2021 12:17
Singularity Recipe for MultiBUGS
bootstrap: docker
from: ubuntu:18.04
%help
This will run MultiBUGS
%environment
export PATH=/opt/multibugs:${PATH}
%post
set ( QWT_INCLUDE_DIRS ${QWT_INCLUDE_DIR} )
# version
set ( _VERSION_FILE ${QWT_INCLUDE_DIR}/qwt_global.h )
if ( EXISTS ${_VERSION_FILE} )
file ( STRINGS ${_VERSION_FILE} _VERSION_LINE REGEX "define[ ]+QWT_VERSION_STR" )
if ( _VERSION_LINE )
string ( REGEX REPLACE ".*define[ ]+QWT_VERSION_STR[ ]+\"([^\"]*)\".*" "\\1" QWT_VERSION_STRING "${_VERSION_LINE}" )
endif ()
endif ()