Skip to content

Instantly share code, notes, and snippets.

View tommcdo's full-sized avatar

Tom McDonald tommcdo

  • Windsor, ON, Canada
View GitHub Profile
/**
* Create a useful view for browsing the audit logs. MySQL unfortunalte does
* not support subqueries in the FROM clause of a view definition, so I am
* forced to create multiple views with ugly (but hopefully alphabetically
* last) names.
*/
DROP VIEW IF EXISTS zzz_quick_audit_log_1;
CREATE VIEW zzz_quick_audit_log_1 AS
SELECT
@tommcdo
tommcdo / README.md
Last active December 28, 2015 05:49

Say you're checked out on a feature branch, feature/foo. You realize that the feature you're implementing has a dependency that isn't really in the scope of what the feature does; it just needs that. It would be useful for that to exist on develop, too. From your feature branch feature/foo, run the command

git dependency create bar

This will find the common ancestor between, by default, develop and feature/foo. From there it will create a new branch called dependency/bar, and switch to it. There you can implement your dependency and make some commits. When you're done, switch back to your feature branch, then run

git dependency merge bar

This will merge dependency/bar into, by default, develop and feature/foo. It will leave you checked out on feature/foo after it's done.

set cot=menu,menuone
ino <BS> <BS><C-r>=getline('.')[col('.')-4:col('.')-2]=~#'\k\k\k'?!pumvisible()?"\<lt>C-n>\<lt>C-p>":'':pumvisible()?"\<lt>C-y>":''<CR>
ino <CR> <C-r>=pumvisible()?"\<lt>C-y>":""<CR><CR>
ino <Tab> <C-r>=pumvisible()?"\<lt>C-n>":"\<lt>Tab>"<CR>
ino <S-Tab> <C-r>=pumvisible()?"\<lt>C-p>":"\<lt>S-Tab>"<CR>
augroup MyAutoComplete
au!
au InsertCharPre * if
@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
""" 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
""" 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>"
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
@tommcdo
tommcdo / .vimrc
Created January 22, 2014 17:37
Best vimrc for beginners
" Add configuration here
@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
#!/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
#