Skip to content

Instantly share code, notes, and snippets.

View mattsacks's full-sized avatar

Matt Sacks mattsacks

View GitHub Profile
struct STACK_IMPL {
int length;
STACK_VALUE array[5];
};
void stack_push(STACK *stack, STACK_VALUE value) {
stack->length++;
stack->array[stack->length] = value;
}
struct STACK_IMPL {
int length; //current number of entries
int max_size; //size of the currently allocated array
STACK_VALUE *array;
};
void stack_push(STACK *stack, STACK_VALUE value) {
stack->array[stack->length] = value;
stack->length++;
}
@mattsacks
mattsacks / install.rb
Created February 23, 2011 23:42
Script to install Vim 7.3 with ruby support for Mac OS X
# requires root permissions in /usr/bin/
star = String.new
8.times { star += "*" }
Star = "\n#{star * 3}\n"
def newblock string
puts "\n#{Star}#{string}#{Star}\n"
end
@mattsacks
mattsacks / quay.terminal
Created July 22, 2011 11:02
Quay colors for 10.7 OS X Terminal.app
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlackColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAB
TxAnMC4xNjQyMzM1ODAyIDAuMTY0MjMzNTgwMiAwLjE2NDIzMzU4MDIA0hAREhNaJGNs
YXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yohIUWE5TT2JqZWN0XxAPTlNLZXllZEFyY2hp
https = require 'https'
url = require 'url'
querystring = require 'querystring'
credentials = 'sekret'
option '-m', '--message [MESSAGE]', 'message to send'
option '-t', '--title [TITLE]', 'title in the notification'
option '-l', '--longmessage [LONGMESSAGE]', 'longmessage to send'
option '-s', '--subtitle [SUBTITLE]', 'subtitle of the notification'
@mattsacks
mattsacks / easy-markers.vim
Created October 6, 2011 22:40
Easy way to make a fold with {{{,}}} markers in vim
" create a new fold with {{{ }}} markers
function! s:Fold(fold)
let beg = substitute(&commentstring, '%s', a:fold, '')
let end = substitute(&commentstring, '%s', 'END '.a:fold, '')
call setline('.', beg.' {{{')
call append('.', end.' }}}')
endfunction
command! -nargs=1 Fold :call s:Fold(<f-args>)
@mattsacks
mattsacks / synstack.vim
Created December 31, 2011 18:00
Get highlight groups of word under cursor in Vim
function! Syn()
for id in synstack(line("."), col("."))
echo synIDattr(id, "name")
endfor
endfunction
command! -nargs=0 Syn call Syn()
" if the current buffer has a different working directory than the one when
" Vim starts, source the .localvimrc
augroup Localvimrc
autocmd!
autocmd VimEnter * if filereadable('.localvimrc')
\| so .localvimrc
\| endif
\| let g:localvimrc_directory = getcwd()
autocmd BufEnter,BufNewFile * if getcwd() != g:localvimrc_directory && filereadable('.localvimrc')
@mattsacks
mattsacks / easy_todolist.vim
Created January 18, 2012 02:06
Quickfix window of TODO's found
command! -complete=file -nargs=1 TODO :exec "grep -r TODO:" <q-args> | :copen
@mattsacks
mattsacks / gwipe.vim
Created January 24, 2012 01:18
Wipe existing fugitive buffers if you've arrived to diff hell.
" Fugitive
command! -nargs=0 Gwipe bufdo if expand("%") =~ '^fugitive'
\| execute 'bw'
\| endif