Skip to content

Instantly share code, notes, and snippets.

View supermomonga's full-sized avatar
🏠
Working from home

supermomonga supermomonga

🏠
Working from home
View GitHub Profile
# -*- encoding: utf-8 -*-
require 'nkf'
class Idol
attr_reader :name
def initialize(name)
@name = NKF::nkf('-wxZ4', name) # zenkaku to hankaku
@nicknames = {}
let g:quickrun_config = {
\ '_' : {
\ 'hook/close_unite_quickfix/enable_hook_loaded' : 1,
\ 'hook/unite_quickfix/enable_failure' : 1,
\ 'hook/unite_quickfix/no_focus' : 0,
\ 'hook/unite_quickfix/unite_options' : '-no-quit -direction=botright -winheight=12 -max-multi-lines=32 -no-start-insert',
\ 'hook/close_quickfix/enable_exit' : 1,
\ 'hook/close_buffer/enable_failure' : 1,
\ 'hook/close_buffer/enable_empty_data' : 1,
\ 'outputter' : 'multi:buffer:quickfix',
- pi = request.path_info
%ul.nav.nav-tabs
%li{ class: ['/users/edit'].any? {|p| pi.include? p} ? 'active' : '' }= link_to 'アカウント情報' , :edit_user_registration
%li{ class: ['/creator/new', '/creator/edit'].any? {|p| pi.include? p} ? 'active' : '' }= link_to 'クリエイター情報' , edit_user_creator_path(current_user)
%li{ class: ['/client/new', '/client/edit'].any? {|p| pi.include? p} ? 'active' : '' }= link_to '発注者情報' , edit_user_client_path(current_user)
"=============================================================================
" FILE: suggest.vim
" AUTHOR: supermomonga
" Last Modified: 19 Oct 2013
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
" "Software"), to deal in the Software without restriction, including
" without limitation the rights to use, copy, modify, merge, publish,
" distribute, sublicense, and/or sell copies of the Software, and to
# coding: utf-8
include Java
class DataSet
def random scale
@random_array ||= scale.times.map { rand 1..scale }
@random_array
end

How to detect the missing end using Vim script.

要求

  • smartinput.vimを用い、<CR>を入力した際、状況に応じてendを自動で入力させる

アプローチ

<CR>が入力された際、以下の内容を実装した関数をcallする。

``を入力した際にカーソルが存在する行のインデントの深さを取得。これをl:smartend_indent_levelとする。カーソルが存在する行から一行ずつインデントの深さをチェックして行き、`l:smartend_indent_level`と同じインデントの深さで、インデントの直後に`end`が存在する行に到達した場合、何もせずに処理を終了。`l:smartend_indent_level`より浅いインデントを持つ行、ただし深さ0の場合は除く、に到達した場合はその行に`l:smartend_indent_level`と同じ深さのインデント及び`end`を挿入し処理を終了。

colorscheme desert
augroup MyAutoCmd
autocmd!
augroup END
" NeoBundle initalize
set nocompatible
call smartinput#map_to_trigger('i', '<Space>', '<Space>', '<Space>')
call smartinput#define_rule({
\ 'at': '^\(.*=\)\?\s*\zs\%(module\|class\|def\|if\|unless\|case\|while\|until\|for\|\|begin\)\>\%(.*[^.:@$]\<end\>\)\@!\|\<do\ze\%(\s*|.*|\)\=\s*\%#$',
\ 'char': '<Space>',
\ 'input': '<ESC>oend<ESC><Up>A<Space>',
\ 'filetype': ['ruby'],
\ })
function! g:my_postexec(command, cmdline)
call feedkeys("\<ESC>")
endfunction
autocmd FileType vimshell call vimshell#hook#add('postexec', 'my_postexec', 'g:my_postexec')
# -*- coding: utf-8 -*-
require 'rubygems'
require 'mechanize'
# Settings
email = '[email protected]'
passwd = 'hoge'