Skip to content

Instantly share code, notes, and snippets.

Andrew Radev AndrewRadev

View GitHub Profile
View indent_test_active_record.rb
module ActiveRecord
class Attribute # :nodoc:
class << self
def from_database(name, value, type)
FromDatabase.new(name, value, type)
end
def from_user(name, value, type)
FromUser.new(name, value, type)
end
@AndrewRadev
AndrewRadev / benchmark.vim
Created Jan 5, 2017
A simple benchmark for vim-ruby indentation
View benchmark.vim
function! s:Stats(list)
let sum = 0
for item in a:list
let sum += item
endfor
let mean = sum / len(a:list)
let sum_deviations = 0
for item in a:list
@AndrewRadev
AndrewRadev / convert_dict.vim
Created Dec 28, 2016
Convert a python dict into a tuple of pairs
View convert_dict.vim
command! ConvertDict call s:ConvertDict()
function! s:ConvertDict()
" Save view for restoring later
let saved_view = winsaveview()
" If we're not in a dict, do nothing
if searchpair('{', '', '}', 'bcW', '', line('.')) <= 0
return
endif
View cfile.vim
" The filename used for the cfile
let s:cfile_filename = ''
" The last mtime of the filename
let s:cfile_mtime = -1
" Define a command that can be called like:
"
" Cfile errors.txt
"
" Apart from loading the error file in the quickfix window, it also
@AndrewRadev
AndrewRadev / custom_ember_gf.vim
Last active May 22, 2016
An example for a custom ember_tools gf callback
View custom_ember_gf.vim
" This is a project-specific Vim file that boosts ember_tools' gf mapping to
" follow translation keys to their yaml files.
let g:ember_tools_custom_gf_callbacks = [
\ 'EmberGfTranslations'
\ ]
function! EmberGfTranslations()
" only emblem files in this project
if &filetype != 'emblem'
View rails_gf_translation.vim
let g:rails_gf_callbacks = [
\ 'RailsGfTranslation'
\ ]
function! RailsGfTranslation()
let saved_iskeyword = &iskeyword
set iskeyword+=.
if !ember_tools#search#UnderCursor('\%(I18n\.\)\=t(\=[''"]\zs\k\+[''"]')
let &iskeyword = saved_iskeyword
@AndrewRadev
AndrewRadev / ember-projections.json
Last active Oct 28, 2019
A `.projections.json` file that can be used with vim-projectionist for navigating ember.js projects
View ember-projections.json
{
"app/initializers/*.js": {
"type": "initializer"
},
"app/models/*.js": {
"type": "model",
"alternate": "app/adapters/{}.js",
},
"app/adapters/*.js": {
"type": "adapter",
@AndrewRadev
AndrewRadev / dsf.vim
Last active Nov 5, 2018
Delete surrounding function call
View dsf.vim
" Delete surrounding function call
" Relies on surround.vim
"
" function_call(cursor_here) => dsf => cursor_here
"
" Try `dsf` with more complicated structures:
"
" nested(function_call(cursor_here))
" nested(cursor_here(chewy_center))
" One::Two.new([cursor_here])
View phasors.rb
require 'rational'
require 'complex'
class Phasor
attr_reader :magnitude, :angle
class << self
def from_polar(magnitude, angle)
new(magnitude, angle)
end
View nerdtree_talk
- Standard netrw: https://twitter.com/PascalPrecht/status/489328558700249088
- vim-vinegar: https://github.com/tpope/vim-vinegar
- NERDTree: https://github.com/scrooloose/nerdtree
- Basic usage: navigating, opening a file, opening a directory
- What makes it good:
- powerful navigation
- filesystem manipulation
- customizations
You can’t perform that action at this time.