Skip to content

Instantly share code, notes, and snippets.

View mllg's full-sized avatar

Michel Lang mllg

View GitHub Profile
@mllg
mllg / Tmpwatch
Last active March 19, 2021 04:16
Utility vim function to clean up vim's undo files (or others).
function Tmpwatch(path, days)
let l:path = expand(a:path)
if isdirectory(l:path)
for file in split(globpath(l:path, "*"), "\n")
if localtime() > getftime(file) + 86400 * a:days && delete(file) != 0
echo "Tmpwatch(): Error deleting '" . file . "'"
endif
endfor
else
echo "Tmpwatch(): Directory '" . l:path . "' not found"
#!/usr/bin/env Rscript
### Toggle debug blocks on and off in a fashion of a pre-processor
# usage: toggle_debug [uri] [on|off]
#
# Argument uri can be a single file or directory.
# In case of a directory, the script processes all ".[rR]$" files inside and
# only writes changes if processing is successful for all files found.
#
# Debug blocks start with the comment "BDEBUG" and end with "EDEBUG"
@mllg
mllg / knit
Created December 12, 2012 14:24
Small R shell script to convert R markdown files into HTML or PDF format using the knitr package
#!/usr/bin/env Rscript
# Small R shebang script (useable from a shell) to convert R markdown files into HTML or PDF format
# using the knitr package.
#
# Place this file in a directory in your $PATH or create an alias to it, e.g. in your '.bashrc':
# alias knit='/path/to/script'
# alias knit2html='/path/to/script --html'
# alias knit2pdf='/path/to/script --pdf'
#