Skip to content

Instantly share code, notes, and snippets.

View sdizier's full-sized avatar

Slan Dizier sdizier

View GitHub Profile
@sdizier
sdizier / gist:726a1b10123f45b03cd8
Created November 6, 2014 19:39
Turn an object into an array of accessor strings
function flatten(x, result, prefix) {
if(_.isObject(x) && !_.isArray(x)) {
_.each(x, function(v, k) {
result = flatten(v, result, prefix ? prefix + '.' + k : k)
})
} else {
result[prefix] = x
}
return result
}
" Strip trailing whitespace
function! <SID>StripTrailingWhitespaces()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history, and cursor position
let @/=_s