Skip to content

Instantly share code, notes, and snippets.

Avatar

Martin Grenfell scrooloose

View GitHub Profile
View foo.vim
"stick this in your ~/.vimrc
"could probably do this all on one line in the autocmd declaration but whatever
autocmd vimenter * call s:CheckForForgettingSudo()
function s:CheckForForgettingSudo()
if &readonly
echoerr "Use sudo beyotch!"
exit
endif
endfunction
View hax0r.css
.header-image.cover {
margin: auto;
max-width: 800px;
}
.header-image-wrapper {
height: 500px !important;
}
View foo.html
<div class="schemes_group_parking">
<div style="clear:both;"></div>
<div class="scheme_parking"><a href="traffic-schemes/trees.shtml" class="hyperspan"></a>
<div class="scheme_head">
<div class="scheme_title_parking">Pavement parking ban</div>
<img class="scheme_image_parking" src="images/schemes/vas_s.jpg" alt="Speed cushions">
</div>
</div>
<div class="parking_scheme_text_middle">
<ul id="parking">
@scrooloose
scrooloose / git.vim
Last active Aug 29, 2015
NERDTree demo plugin for git integration
View git.vim
" ============================================================================
" File: git.vim
" Description: Expt. plugin to add git flags to the UI
" Maintainer:
" License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
@scrooloose
scrooloose / nerdtree_custom_open.vim
Last active Aug 29, 2015
nerdtree plugin to override 'o' and make it not reuse windows
View nerdtree_custom_open.vim
"Demo nerdtree plugin to override the default 'o' mapping and make it not
"reuse windows.
"
"Chuck this in
" ~/.vim/nerdtree_plugin/nerdtree_custom_open.vim
"
"or somewhere like
" ~/.vim/bundle/nerdtree_plugin/nerdtree_custom_open.vim
"
"if using pathogen or similar.
View cpu.sh
#!/bin/bash
if [ -f /tmp/tmux-cpu ]; then
cat /tmp/tmux-cpu
else
echo "???"
fi
CPU=`mpstat 1 1` && echo $CPU | awk '{printf("%2.f", $(NF-8) + $(NF-6)) }' > /tmp/tmux-cpu &
View owx_rails_crap.rb
module OpsWorks
module RailsConfiguration
def self.determine_database_adapter(app_name, app_config, app_root_path, options = {})
options = {
:consult_gemfile => true,
:force => false
}.update(options)
if options[:force] || app_config[:database][:adapter].blank?
# a bunch of confusing shit
else
View vimrc
fu! NERDTreeFindPrevBuf()
if g:NERDTree.IsOpen()
NERDTreeClose
elseif (!filereadable(bufname('%')) || (bufname('%') == '__Tag_List__') || (bufname('%') == '__Tagbar__'))
echo "Previous buf not valid or readable file."
NERDTree
else
NERDTreeFind
endif
View nerdtree_ft_checker.vim
"Put this file in ~/.vim/nerdtree_plugin
"
"There are definitely more efficient ways to check a file to see if it
"is a class/interface/etc but this is really just a proof of concept.
if exists("loaded_nerdtree_ft_flags_plugin")
finish
endif
let g:loaded_nerdtree_ft_flags_plugin = 1
@scrooloose
scrooloose / startshell_mapping.vim
Created Oct 7, 2009
nerd tree plugin to add a mapping on S that starts a :shell
View startshell_mapping.vim
"put this in ~/.vim/nerdtree_plugin/startshell_mapping.vim
call NERDTreeAddKeyMap({
\ 'key': 'S',
\ 'callback': 'NERDTreeStartShell',
\ 'quickhelpText': 'start a :shell in this dir' })
function! NERDTreeStartShell()
let n = g:NERDTreeDirNode.GetSelected()
You can’t perform that action at this time.