Skip to content

Instantly share code, notes, and snippets.

View tommcdo's full-sized avatar

Tom McDonald tommcdo

  • Windsor, ON, Canada
View GitHub Profile
public class Random {
public static void randomlyThrow() throws Exception {
if (Math.random() < 0.25) {
throw new Exception("Random!");
}
}
public static void main(String[] args) {
int failures = 0;
function! s:start_delete(key)
let l:result = a:key
if !s:deleting
let l:result = "\<C-G>u".l:result
endif
let s:deleting = 1
return l:result
endfunction
function! s:check_undo_break(char)
if (!window.getComputedStyle) {
window.getComputedStyle = (function() {
var // partially grabbed from jQuery and Dean's hack
notpixel = /^(?:[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|))(?!px)[a-z%]+$/,
position = /^(top|right|bottom|left)$/,
re = /\-([a-z])/g,
place = function (match, $1) {
return $1.toUpperCase();
@tommcdo
tommcdo / .vimrc
Last active August 29, 2015 14:08
Minimal .vimrc file
syntax on
set background=dark
set incsearch
set nohlsearch
set hidden
<?php
try
{
include './index.php';
}
catch (Exception $e)
{
}
#!/bin/bash
num=${1:-1}
git reset HEAD^${num}
function! s:express(type)
let expression = input('=', '', 'expression')
let a_reg = @a
let selection = &selection
set selection=inclusive
let selectcmd = "`[v`]"
if a:type == 'line'
let selectcmd = "'[V']"
endif
execute 'normal!'.selectcmd.'"ay'
function! s:sargs()
execute 'arglocal! '.join(map(tabpagebuflist(), 'bufname(v:val)'), ' ')
execute winnr().'argument'
execute 'only'
endfunction
command! Sargs call s:sargs()
# Description:
# Issue various Git commands on remote servers
#
# Commands:
# Hubot create <type> repository <nickname> = <user>/<repository> - Define a repository for linking
# Hubot create server <nickname> - Define a new server
# Hubot set <property> on server <nickname> to <value> - Set a server's user, address, directory, or repo
# Hubot alias server <nickname> to <alias> - Create an alias to a server
# Hubot describe server <nickname> - Show details of a server
# Hubot delete server <nickname> - Delete server details
@tommcdo
tommcdo / min.vim
Last active August 29, 2015 13:56
function! MinCommandPrefix(command)
for i in range(len(a:command) - 1, 0, -1)
if exists(':' . strpart(a:command, 0, i)) != 1
return i + 1
endif
endfor
return -1
endfunction