Skip to content

Instantly share code, notes, and snippets.

View tacahiroy's full-sized avatar
🐑

Takahiro YOSHIHARA tacahiroy

🐑
  • Karabiner Software
  • Fukuoka, JAPAN
  • 13:30 (UTC +09:00)
  • X @tacahiroy
View GitHub Profile
@tacahiroy
tacahiroy / move_lines.vim
Created September 26, 2012 14:23
move up/down visualed lines
function! s:move_block(d) range
let cnt = a:lastline - a:firstline
if a:d ==# 'u'
let sign = '-'
let cnt = 2
else
let sign = '+'
let cnt += 1
endif
@tacahiroy
tacahiroy / private.xml
Last active October 11, 2015 16:47
A Configuration file of the KeyRemap4MacBook for Topre Realforce 87U, MBA and MBP
<?xml version="1.0"?>
<root>
<!-- Devices -->
<devicevendordef>
<vendorname>TopreCorporation</vendorname>
<vendorid>0x853</vendorid>
</devicevendordef>
<deviceproductdef>
<productname>Realforce87</productname>
@tacahiroy
tacahiroy / .vimrc
Last active October 12, 2015 02:37
a function to show/hide line number for Vim
" show/hide line number wisely: this needs Vim 7.3 or above
function! s:toggle_line_number()
let NU = 'nu'
let RNU = 'rnu'
if &nu || &rnu
" to be off
let b:prev = { 'nu': &nu, 'rnu': &rnu }
let &nu = 0
let &rnu = 0
@tacahiroy
tacahiroy / .vimrc
Created October 29, 2012 06:07
Vim: open the current file's location using file manager
" open the current editing file's location using file manager
function! s:open_with_filer()
let cmd = s:get_command()
let path = s:convert_path(expand('%:p:h'))
if cmd is# ''
call g:echohl('Error', 'Your system is not supported.')
return
endif
@tacahiroy
tacahiroy / jsonv.rb
Created October 30, 2012 03:57
tiny JSON validator
#! ruby
require "rubygems"
require "yajl"
exit 0 if ARGV.length == 0
begin
lines = ARGF.read
Yajl::Parser.new.parse(lines)
exit 0
@tacahiroy
tacahiroy / .vimrc
Created October 31, 2012 03:40
Vim: toggle quickfix window
" quickfix
function! s:redir(cmd)
redir => res
execute a:cmd
redir END
return res
endfunction
function! s:toggle_qf_list()
@tacahiroy
tacahiroy / midori_no_goo_watir.rb
Created December 22, 2012 15:50
A sample code of the Watir. This automates 緑のgoo's "水をあげる"
#! ruby
# coding: utf-8
require "rubygems"
require "watir-webdriver"
browser = Watir::Browser.new :firefox, :profile => "default"
browser.goto "http://green.goo.ne.jp/"
btn = browser.div(:id => "tree").div(:class => "btn").images[0]
div = browser.div(:id => "tree").ul(:class => "clearfix").li(:class => "count").divs[2]
@tacahiroy
tacahiroy / .vimrc
Last active December 10, 2015 16:18
.vimrc settings for validating a JSON file
" JSON (Chef)
autocmd BufRead,BufNewFile knife-edit-*.js,*.json setlocal filetype=javascript.json
autocmd FileType *json* setlocal makeprg=python\ -mjson.tool\ 2>&1\ %\ >\ /dev/null
\| setlocal errorformat=%m:\ line\ %l\ column\ %c\ %.%#
@tacahiroy
tacahiroy / .vimrc
Created February 15, 2013 17:05
Chef's attribute notation converter
let s:chef = {}
function! s:chef.convert_attr_notation() abort
if !search('\>', 'bcnW')
return
endif
let [bufnbr, lnum, col, offset] = getpos('.')
let line = getline(lnum)
@tacahiroy
tacahiroy / weechat.zsh
Created January 12, 2014 14:37
init function for WeeChat on tmux
function weechat {
if [ -x `which weechat-curses` ]; then
if ! (ps aux | grep '[w]eechat-curses' 2>&1 > /dev/null); then
tmux new-window -t ${WEECHAT_TMUX_WINNUM:-98} weechat-curses
fi
fi
}