Skip to content

Instantly share code, notes, and snippets.

@smison
smison / .vimrc
Created August 14, 2014 04:05
set number/nonumberをワンタッチで切替える関数を定義
" set number
let g:setnumber = "on"
function Setnumber(setnumber)
if a:setnumber == "on"
let g:setnumber = "off"
set nonumber
else
let g:setnumber = "on"
set number
endif
@smison
smison / .vimrc
Last active August 29, 2015 14:05
set number/nonumberトグルをリファクタ
" set number
function Setnumber()
if &number
setlocal nonumber
else
setlocal number
endif
endfunction
nnoremap <C-m> :call Setnumber()<CR>
@smison
smison / history_counter.rb
Created August 19, 2014 06:14
history_counter.rb
#! /usr/local/bin/ruby
require 'kconv'
LENGTH = 3
COUNT = 5
ines = File.read('/home/<USERNAME>/.bash_history').toutf8.split("\n")
lines_uq = lines.uniq
rethash = Hash.new
lines_uq.each do |line|
Good Bye!
@smison
smison / tegaki_get.rb
Last active August 29, 2015 14:05
#tegaki_dt が含まれるツイートから画像を取得するスクリプト
#! /usr/local/bin/ruby
#coding: utf-8
### requires ##################################################
require 'twitter'
require 'uri'
require 'open-uri'
require 'open_uri_redirections'
require 'nokogiri'
###############################################################
@smison
smison / combine.bat
Created September 4, 2014 11:58
同じディレクトリのpng画像を縦に結合するbatファイル(http://qiita.com/smison/items/0bff938e6b4e4cc7b6be)
SETLOCAL enabledelayedexpansion
SET command=convert -append
for %%f in (*.png) do (
SET command=!command! %%f
)
SET command=%command% output.png
call %command%
@smison
smison / study.py
Created October 22, 2014 03:00
[python] @: デコレータ
- [python] @: デコレータ
- Python - デコレータ http://www17.atpages.jp/~lambda7/py/decorator.html
- Pythonのデコレータを理解するための12Step http://qiita.com/_rdtr/items/d3bc1a8d4b7eb375c368
デコレータとは「関数を引数に取り, 引き換えに新たな関数を返すcallable(*)」。
より分かりやすく言えば「@wrapperで指定したwrapper(func)な関数で、直下の関数に機能追加できる」機能。
もとの関数funcの引数は「*args, **kwargs」で利用可。
===================================================
import time
require 'fssm'
watch_dir = '~/watch_action'
def create_action(base, file)
puts 'hoge'
end
def update_action(base, file)
puts 'hoge'
@smison
smison / mecab
Created February 27, 2015 02:49
ruby-mecabインストール手順
### mecab, ruby-mecab導入
http://sourceforge.jp/projects/sfnet_mecab/downloads/mecab/0.97/mecab-0.97.tar.gz/
$ sudo rpm -ivh http://packages.groonga.org/centos/groonga-release-1.1.0-1.noarch.rpm
$ sudo yum install mecab
$ sudo yum install mecab-devel
$ sudo rpm -ivh http://packages.groonga.org/centos/groonga-release-1.1.0-1.noarch.rpm
$ sudo yum install -y groonga-tokenizer-mecab
「$ mecab -v」でバージョンを確認して、
同じバージョンのmecab-rubyをダウンロードする(バージョンが違うとmake出来ないので注意)
$ wget http://mecab.googlecode.com/files/mecab-ruby-0.996.tar.gz
@smison
smison / resize.bat
Last active August 29, 2015 14:16
同じディレクトリのpng画像を長辺900pxにリサイズするbatファイル(http://qiita.com/smison/items/d32eb72be807e099dfa0)
setlocal enabledelayedexpansion
for %%f in (*.png) do (
REM 画像の縦幅を取得
for /f "usebackq tokens=*" %%i in (`identify -format '%%h' %%f`) do @set HEIGHT=%%i
REM 画像の横幅を取得
for /f "usebackq tokens=*" %%i in (`identify -format '%%w' %%f`) do @set WIDTH=%%i
if !HEIGHT! GEQ !WIDTH! (