Skip to content

Instantly share code, notes, and snippets.

View tommcdo's full-sized avatar

Tom McDonald tommcdo

  • Windsor, ON, Canada
View GitHub Profile
{
"application/classes/*.php": {
"command": "class"
},
"application/config/*.php": {
"command": "aconfig"
},
"application/classes/controller/*.php": {
"command": "controller"
},
{
"application/classes/controller/*.php": {
"command": "controller"
},
"modules/prosoftxp_ad/classes/controller/*.php": {
"command": "ADcontroller"
},
"modules/prosoftxp_cs/classes/controller/*.php": {
"command": "CScontroller"
},
" Style 1: Using :execute
nnoremap <Leader>x :execute some_expression().'some_command'<CR>
" Style 2: Using <expr> mapping
nnoremap <expr> <Leader>x ':'.some_expression().'some_command<CR>'
" Style 3: Using the expression register
nnoremap <Leader>x :<C-R>=some_expression()<CR>some_command<CR>
#!/bin/bash
# Show changes that are only on the current branch.
# Useful when working on a feature branch
#
# USAGE:
# git since [COMMAND] [PARENT-BRANCH]
#
# COMMAND defaults to log
#
@tommcdo
tommcdo / add-site.sh
Last active January 18, 2017 07:18
Quick script to add a local site to your Apache server.
#!/bin/bash
SITE_BASE=/home/tommcdo/sites # Base directory into which sites are installed
LOCAL_TLD=local # TLD for local sites, e.g. http://mysite.local
DOC_ROOT=public_html # Subdirectory of main folder for document root
# Ensure root privileges
if [[ $EUID -ne 0 ]]; then
echo >&2 "This script can only be run as root"
exit
@tommcdo
tommcdo / .vimrc
Created January 22, 2014 17:37
Best vimrc for beginners
" Add configuration here
function! s:browser_from_model()
normal gg
call search('Model_DataSource_.', 'e')
normal ye
sp
execute "Ag \"'name' => '".tolower(@@)."'\" modules/browsers/classes"
execute "normal \<CR>"
ccl
endfunction
""" Fuzzy search
function! Fuzzy(text)
call FuzzyClear()
let text = '\c'.substitute(a:text, '.\zs', '.\\{-}', 'g')[:-6]
let b:fuzzy_last = text
call search(text)
call FuzzyHL(a:text)
let @/ = text
execute "nmap n :<C-U>call FuzzyN('n', '".escape(a:text, "'")."')<CR>"
""" Vdebug maps and settings
" I already have most of my usable <F*> keys mapped to other things, and many
" of them aren't usable in my desktop environment (stolen by the window manager
" or the terminal emulator). These mappings are easier to remember, and for
" 'Vdebug mode', they are all borrowed from edit commands which would otherwise
" by of no use while debugging.
" All of the Vdebug commands are always available with mappings beginning with
" <Leader>v. This can get tedious, so I've created 'Vdebug mode' that can be
@tommcdo
tommcdo / trailing-whitespace.vim
Last active December 30, 2015 12:19
Highlight trailing whitespace in files via a toggle.
function! TrailingWhitespaceToggle(...)
let hlgroup = a:0 ? a:0 : 'Search'
if !exists('s:trailing_whitespace_match')
let s:trailing_whitespace_match = matchadd(hlgroup, '\s\+$')
echo 'Trailing whitespace on'
else
call matchdelete(s:trailing_whitespace_match)
unlet s:trailing_whitespace_match
echo 'Trailing whitespace off'
endif