Skip to content

Instantly share code, notes, and snippets.

View davidmh's full-sized avatar
🐧

David Mejorado davidmh

🐧
View GitHub Profile
@davidmh
davidmh / discourse.js
Created June 13, 2018 08:19
discourse api
require('isomorphic-fetch')
const { createFetch, base, accept, method, params, parse } = require('http-client')
module.exports = (base_url, api_username, api_key) => {
const auth = params({ api_username, api_key })
const requestFactory = method_name => (pathname, data = {}) => {
const req = createFetch(
base(base_url),
@davidmh
davidmh / init.vim
Last active February 18, 2018 22:54
neovim config
let g:mapleader = "\<SPACE>"
" Show white spaces at the end of a line
set list listchars=tab:▸\ ,eol:¬,trail:·
" edit this nvim config
nnoremap <silent> <leader>ev :vs $HOME/.config/nvim/init.vim<CR>
" auto-reload
augroup VimConfig
au!
@davidmh
davidmh / fzf+ag.vim
Created April 28, 2017 23:55
fzf.vim + ag
" Ag / git grep
function! s:ag_to_qf(line)
let parts = split(a:line, ':')
return { 'filename': parts[0]
\,'lnum': parts[1]
\,'col': parts[2]
\,'text': join(parts[3:], ':')
\ }
endfunction
@davidmh
davidmh / tmux.vim
Created September 26, 2017 21:02
tmux mappings
command! ZoomServer call system('tmux resize-pane -Z -t 2')
command! ZoomClient call system('tmux resize-pane -Z -t 1')
command! RestartClient call system('tmux send-keys -t 1 C-c "npm run dev" Enter')
command! RestartServer call system('tmux send-keys -t 2 C-c "npm run start-dev" Enter')
nnoremap <silent> <leader>zc :ZoomClient<CR>
nnoremap <silent> <leader>zs :ZoomServer<CR>
nnoremap <silent> <leader>rc :RestartClient<CR>
nnoremap <silent> <leader>rs :RestartServer<CR>
@davidmh
davidmh / pre-push
Created September 16, 2017 00:22
Run npm tests before pushing
#!/bin/sh
# Called by "git push" after it has checked the remote status, but before anything has been
# pushed. If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
#
@davidmh
davidmh / !react-sublime-snippets.md
Last active September 6, 2017 17:16 — forked from JawsomeJason/!react-sublime-snippets.md
Sublime Text Completions and Snippets for React
@davidmh
davidmh / custom-post-type-archive-menu-links.php
Last active October 14, 2016 08:11 — forked from helgatheviking/custom-post-type-archive-menu-links.php
Adds Custom Post Type archives to the WordPress-powered menus. Compatible with WP 3.8
<?php
/*
Plugin Name: Custom Post Type Archive Menu Links
Plugin URI: http://codeseekah.com/2012/03/01/custom-post-type-archives-in-wordpress-menus-2/
Description: Easily Add Custom Post Type Archives to the Nav Menus
Version: 1.1
Author: soulseekah
Author URI: http://codeseekah.com
License: GPL2
@davidmh
davidmh / nvim-term-maps.vim
Last active June 22, 2016 16:48
Mappings and basic REPL for Neovim's :term
" Term bindings
"
" Spawns
" open shell on the current window
nnoremap <c-t><c-e> :e term://$SHELL<CR>A
" open vertical shell
nnoremap <c-t><c-v> <c-w><c-v><c-w><c-l>:e term://$SHELL<CR>A
" open horizontal shell
nnoremap <c-t><c-s> <c-w><c-s><c-w><c-j>:e term://$SHELL<CR>A
"
@davidmh
davidmh / fugitive-swoop.vim
Last active May 23, 2016 17:11
vim-fugitive + vim-swoop
function! Cmd2QuickFix(command, prompt, use_swoop)
" use the current word as the default value
let default = expand("<cword>")
call inputsave()
let pattern = input(a:prompt, default)
call inputrestore()
if empty(pattern)
echo a:command . ' needs a pattern, see :h ' . a:command
else
exe 'silent ' . a:command . ' ' . pattern . ' | redraw!'
@davidmh
davidmh / gist:5689418
Last active December 17, 2015 23:29
Fast Next/Prev Post Links for large databases. http://wordpress.stackexchange.com/q/101435/
<?php # -*- coding: utf-8 -*-
namespace WPSE;
/* Plugin Name: Fast Next/Prev Post Links
* Plugin URI: http://wordpress.stackexchange.com/q/101435/
*/
add_action(
'fast_prev_post_link',
__NAMESPACE__ . '\fast_prev_post_link',
10,