Skip to content

Instantly share code, notes, and snippets.

View davidmh's full-sized avatar
🐧

David Mejorado davidmh

🐧
View GitHub Profile
@davidmh
davidmh / CtrlP_acceleration
Last active July 12, 2023 16:33 — forked from av-ast/CtrlP_acceleration
Accelerate CtrlP by ignoring certain files and paths. Including node modules and grunt's .tmp
" Ignore some folders and files for CtrlP indexing
let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.yardoc\|node_modules\|log\|tmp$',
\ 'file': '\.so$\|\.dat$|\.DS_Store$'
\ }
@davidmh
davidmh / reducer.ts
Last active September 27, 2022 16:25
Why do we need an explicit return on reducer functions?
interface State {
propA: number;
propB: string;
}
/**
* TypeScript is a structural type system. This means as long as your data
* structure satisfies a contract, TypeScript will allow it. Even if you have
* too many keys declared.
*
@davidmh
davidmh / quickfix-fzf.vim
Last active July 15, 2022 20:00
Filter the quickfix list with fzf
function! s:format_qf_line(line)
let parts = split(a:line, ':')
return { 'filename': parts[0]
\,'lnum': parts[1]
\,'col': parts[2]
\,'text': join(parts[3:], ':')
\ }
endfunction
function! s:qf_to_fzf(key, line) abort
" netrw
let g:netrw_banner = 0 " hide banner
let g:netrw_altv=1 " open splits to the right
let g:netrw_liststyle=3 " tree view
let g:netrw_list_hide=netrw_gitignore#Hide()
function! s:open_netrw()
" Grab the current file name
let file_name = expand("%:t")
" Open a 20-column left-side netrw explorer in the directory for the current
@davidmh
davidmh / config.fish
Last active November 28, 2020 13:37
Showing git branch in fish shell prompt. Put following code at the end of ~/.config/fish/config.fish. It will also highlight in red if branch is dirty. Based on http://zogovic.com/post/37906589287/showing-git-branch-in-fish-shell-prompt
set fish_git_dirty_color red
set fish_git_not_dirty_color green
function parse_git_branch
set -l branch (git branch 2> /dev/null | grep -e '\* ' | sed 's/^..\(.*\)/\1/')
set -l git_status (git status -s)
if test -n "$git_status"
echo (set_color $fish_git_dirty_color)$branch(set_color normal)
else
@davidmh
davidmh / fzf-reverse-i-search.vim
Created September 16, 2015 18:11
reverse-i-search for vim with fzf
" reverse-i-search
function! s:get_history()
redir => history
silent! history
redir END
return map(split(history, '\n'), "strpart(v:val, 9)")
endfunction
function! s:run_cmd(cmd)
execute a:cmd
endfunction
@davidmh
davidmh / presentation.vim
Last active August 3, 2020 13:17
Presentation mode with Goyo + vim-markdown
" https://asciinema.org/a/kE1398clJWRPPhk3lWbtvbanF
" Presentation mode
"
" use <left> and <right> to navigate the slides
"
" https://github.com/plasticboy/vim-markdown Makes folds by sections (among many other things)
" https://github.com/junegunn/goyo.vim Distraction-free writing (and reading) in Vim
function! s:enter_presentation()
@davidmh
davidmh / init.vim
Last active April 16, 2020 18:52
neovim config
let g:mapleader = "\<SPACE>"
" Show white spaces at the end of a line
" set list listchars=tab:▸\ ,eol:¬,trail:·
set list listchars=tab:▸\ ,trail:·
set mouse=a
" edit this nvim config
command! Vimrc tabedit $HOME/.config/nvim/init.vim
@davidmh
davidmh / toggle-selected-trip.diff
Created September 15, 2018 17:37
toggle selected trip
diff --git a/src/App.js b/src/App.js
index b8ec935..04a4045 100644
--- a/src/App.js
+++ b/src/App.js
@@ -30,9 +30,10 @@ class App extends Component {
}
selectTrip = tripId => {
- this.setState({
- selectedTrip: tripId
@davidmh
davidmh / gist:6228319
Last active June 26, 2018 15:57
iTerm Tab & Window Titles with zsh and git. original: http://timbabwe.com/2012/05/iterm_tab_and_window_titles_with_zsh
function precmd() {
if command git rev-parse --git-dir > /dev/null 2>&1; then
window_label=$(git rev-parse --show-toplevel)
tab_label=$(echo $window_label | awk -F\/ '{print "[git] " $NF}')
else
window_label=${PWD/${HOME}/\~}
tab_label=$window_label
fi
echo -ne "\e]2;${window_label}\a"
echo -ne "\e]1;${tab_label: -24}\a"