Skip to content

Instantly share code, notes, and snippets.

Andrew Radev AndrewRadev

Block or report user

Report or block AndrewRadev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@AndrewRadev
AndrewRadev / utl_mapping.vim
Created Oct 10, 2009
NERDTree integration with Utl
View utl_mapping.vim
" Requires: Utl
call NERDTreeAddKeyMap({
\ 'key': 'gu',
\ 'callback': 'OpenCurrentNodeWithUtl',
\ 'quickhelpText': 'open current node with the Utl plugin' })
function! OpenCurrentNodeWithUtl()
" Get the path of the item under the cursor if possible:
let currentDir = g:NERDTreeFileNode.GetSelected()
View gist:513976
" Remap the 'Enter' key to process the command line before executing
cnoremap <cr> <c-r>=<SID>DoSomeChecks()<cr><cr>
function! s:DoSomeChecks()
let g:debug = getcmdline()
" and some more stuff...
" :doautocmd with a custom event maybe?
return ''
endfunction
View mappings.vim
" <space>x -> :X
" For easier typing of custom commands
noremap <space> :call <SID>SpaceMapping()<cr>
function! s:SpaceMapping()
echo
let c = nr2char(getchar())
call feedkeys(':'.toupper(c))
endfunction
View monads.rb
require 'pp'
class Monad
class Wrapper
def initialize(monad)
@monad = monad
@lets = {}
end
def let(name, value)
View map_toggle.vim
" Toggle settings:
command! -nargs=+ MapToggle call s:MapToggle(<f-args>)
function! s:MapToggle(key, opt)
let cmd = ':set '.a:opt.'! \| set '.a:opt."?\<CR>"
exec 'nnoremap '.a:key.' '.cmd
endfunction
" To toggle search highlighting on and off with <F9>, just do:
"
" MapToggle <F9> hlsearch
View generate-rails-gem-tags
#! /usr/bin/env ruby
# Generate all tags for all gems included by bundler in gems.tags
#
# Basically does the same as "bundle show gemname", except for all gems.
# Interestingly enough, "bundle show" without any arguments falls back to
# "bundle list", otherwise the whole thing could have been a bash one-liner.
require 'bundler'
@AndrewRadev
AndrewRadev / fs_buffer_menu.vim
Created Apr 23, 2011
NERDTree plugin for filesystem manipulation using a temporary buffer for its input
View fs_buffer_menu.vim
" vim: foldmethod=marker
"
" This NERDTree plugin adds a filesystem manipulation menu almost exactly like
" the default one. The difference is that operations that require entering a
" file path, namely "add", "move" and "copy", use a separate one-line buffer
" to receive the input, instead of the default vim dialog. This allows you to
" use vim keybindings to move around the file path.
"
" Most of the code here is taken directly from Marty Grenfell's original
" fs_menu plugin, which can be found here:
@AndrewRadev
AndrewRadev / not.rb
Created May 25, 2011
object.not.predicate?
View not.rb
if not defined? BasicObject
class BasicObject
m = %w"__id__ __send__ instance_eval == equal?"
(instance_methods - m).each{|m| undef_method(m)}
end
end
class NotDelegator < BasicObject
def initialize(obj)
@_object = obj
@AndrewRadev
AndrewRadev / ordered_hash_wtf.rb
Created May 27, 2011
Odd behaviour for pp with ActiveSupport::OrderedHash
View ordered_hash_wtf.rb
# Ruby 1.8.7-p330
# ActiveSupport 3.0.7
require 'rubygems'
require 'active_support/ordered_hash'
require 'pp'
test = ActiveSupport::OrderedHash.new
test[:one] = 1
@AndrewRadev
AndrewRadev / inconsistency.rb
Created May 27, 2011
ActiveSupport::OrderedHash inconsistency
View inconsistency.rb
# Ruby 1.8.7
# ActiveSupport 3.0.7
require 'rubygems'
require 'active_support/ordered_hash'
require 'pp'
ordered = ActiveSupport::OrderedHash.new
standard = Hash.new
You can’t perform that action at this time.