Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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'
###############################################################
Good Bye!
@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|
@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 / .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