Skip to content

Instantly share code, notes, and snippets.

View AndrewRadev's full-sized avatar

Andrew Radev AndrewRadev

View GitHub Profile
@AndrewRadev
AndrewRadev / Coffeescript ctags
Created February 28, 2012 13:51 — forked from wereHamster/Coffeescript ctags
ctags definitions for coffeescript
# Detects classes, static/class methods, plain functions and variables.
# To use, place it in a ~/.ctags file.
--langdef=coffee
--langmap=coffee:.coffee
--regex-coffee=/(^|=[ \t])*class ([A-Za-z.]+)( extends [A-Za-z.]+)?$/\2/c,class/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?@?([A-Za-z.]+):.*[-=]>.*$/\3/f,function/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?([A-Za-z.]+)[ \t]+=.*[-=]>.*$/\3/f,function/
--regex-coffee=/^[ \t]*([A-Za-z.]+)[ \t]+=[^->\n]*$/\1/v,variable/
@AndrewRadev
AndrewRadev / qf.vim
Created March 5, 2012 10:34
Mapping to toggle the quickfix window on and off
nnoremap <Plug>ToggleQf :call <SID>ToggleQf()<cr>
function! s:ToggleQf()
for buffer in tabpagebuflist()
if bufname(buffer) == ''
" then it should be the quickfix window
cclose
return
endif
endfor
@AndrewRadev
AndrewRadev / diffsplit.vim
Last active May 22, 2018 14:45
Split a git diff in separate files to mirror the original repo layout
" Put this in plugin/diffsplit.vim.
"
" Executing :Diffsplit on a file, containing a git diff would open up a new
" tab, cd to a temporary directory, and distribute the changes into separate
" files, mirroring the repo layout. You can then use NERDTree or whatever you
" like to browse through the changes.
"
" Using it straight from the command-line is fairly simple and aliasable:
"
" git diff whatever | vim - -R +Diffsplit
@AndrewRadev
AndrewRadev / lebab.vim
Last active April 17, 2018 18:58
Use the "lebab" tool through Vim
" Invoke the `lebab` tool on the current buffer (https://github.com/lebab/lebab)
"
" Usage:
"
" :Lebab <transform1> <transform2> [...]
"
" This will run all the transforms specified and replace the buffer with the
" results. The available transforms tab-complete.
"
command! -nargs=+ -complete=custom,s:LebabComplete
extern crate solution;
use solution::*;
use std::io::{self, Write};
fn main() {
let mut game = Game::new("aardvark", 10).unwrap();
let stdin = io::stdin();
println!("Let's play hangman!");
@AndrewRadev
AndrewRadev / websearch-prompt.py
Last active June 17, 2017 12:15
Simple websearch -- prompt + mini-browser
#! /usr/bin/env python3
"""
Usage:
websearch-prompt 'http://en.wikipedia.org/wiki/{0}'
websearch-prompt 'http://youtube.com/results?search_query={0}'
"""
import sys
@AndrewRadev
AndrewRadev / jsx.vim
Last active May 30, 2017 07:15
gf for react
set includeexpr=<SID>Includeexpr()
augroup jsx_autocommands
autocmd!
" Override gf if rails sets it after
autocmd User Rails cmap <buffer><expr> <Plug><cfile> <SID>Includeexpr()
augroup END
function! s:Includeexpr()
@AndrewRadev
AndrewRadev / ascii_image.rs
Last active March 21, 2017 14:52
Convert an image to simple ASCII-art
extern crate image;
use std::io::File;
use image::GenericImage;
fn main() {
let path = Path::new("examples/test_image.png");
let file = File::open(&path);
match image::load(file, image::ImageFormat::PNG) {
" Define what color the private area will be
hi rubyPrivateArea ctermbg=darkgray
function! s:MarkPrivateArea()
" Clear out any previous matches
call clearmatches()
" Store the current view, in order to restore it later
let saved_view = winsaveview()
class AroundEverything
class Nested
def example
some_chain.continued_on.
next_line.method do |one, two|
<<-EOF
Body of method
EOF
end