Skip to content

Instantly share code, notes, and snippets.

takeshy takeshy

View GitHub Profile
View gist:357258
#!/usr/bin/ruby
SHUNTSU_PATTERN = [
[1,2,3],[2,3,4],[3,4,5],[4,5,6],[5,6,7],[6,7,8],[7,8,9],
[1,2,3],[2,3,4],[3,4,5],[4,5,6],[5,6,7],[6,7,8],[7,8,9],
[1,2,3],[2,3,4],[3,4,5],[4,5,6],[5,6,7],[6,7,8],[7,8,9],
[1,2,3],[2,3,4],[3,4,5],[4,5,6],[5,6,7],[6,7,8],[7,8,9]
]
KOUTSU_PATTERN = [[1,1,1],[2,2,2],[3,3,3],[4,4,4],[5,5,5],[6,6,6],[7,7,7],[8,8,8],[9,9,9]]
ATAMA_PATTERN = [[1,1],[2,2],[3,3],[4,4],[5,5],[6,6],[7,7],[8,8],[9,9]]
View init.el
(setq inhibit-startup-screen t)
(progn (set-language-environment "Japanese")
(set-default-coding-systems 'utf-8-unix)
(set-keyboard-coding-system 'utf-8-unix)
(if (not window-system) (set-terminal-coding-system 'utf-8-unix))
)
(setq default-input-method "W32-IME") ;標準IMEの設定
(setq w32-ime-buffer-switch-p nil) ;バッファ切り替え時にIME状態を引き継ぐ
(tool-bar-mode 0)
(scroll-bar-mode 0)
View gist:831301
# Created by newuser for 4.3.6
# 文字コードの設定
export EDITOR=vim
export LANG=ja_JP.UTF-8
bindkey -e
# パスの設定
export PATH=/usr/local/bin:$PATH:$HOME/bin:$HOME/bin/scala-2.8.1.final/bin:$HOME/bin/apache-ant-1.8.2/bin
export MANPATH=/usr/local/share/man:/usr/local/man:/usr/share/man
@takeshy
takeshy / gist:838095
Created Feb 22, 2011
OAuth Consumer Request(2-legged OAuth)
View gist:838095
import java.net.URI
import org.apache.http._
import org.apache.http.client._
import org.apache.http.impl.client._
import org.apache.http.entity.InputStreamEntity
import org.apache.http.client.methods._
import scala.util.parsing.json.JSON._
import java.io.StringBufferInputStream
import org.apache.commons.codec.binary.Base64.encodeBase64
import javax.crypto
@takeshy
takeshy / gist:891964
Created Mar 29, 2011
rackベースのoauth signatureチェック
View gist:891964
module Rack
class SignatureCheck
def initialize(app)
@app = app
end
def call(env)
return [ 401,{ 'Content-Type' => 'text/plain','Content-Length' => '0'},[]] unless ::OauthSignature.valid?(env)
@app.call(env)
end
end
View gist:895706
" You should execute pagent before you call those command.
function PutScp()
let s:nowDir = substitute(expand("%:p:h"),"[cC]:\\(.*\\)$","\\1","")
let s:nowFile = expand("%:t")
let s:fn = "c:\\tmp\\scpcmd.txt"
if filereadable(s:fn)
let s:ret = delete(s:fn)
endif
View gist:895709
(defun post-ftp()
"Post current file to Server."
(interactive )
(setq nowfile (buffer-file-name))
(setq before_buffer (buffer-name))
(setq dir_pos (string-match "/[^/]*$" nowfile))
(setq dir_name (substring nowfile 0 dir_pos))
(setq remote_dir_name (substring nowfile (length "c:/") dir_pos))
(setq file_name (substring nowfile (+ 1 dir_pos) (length nowfile)))
(find-file "c:\\tmp\\scpcmd.txt")
@takeshy
takeshy / gist:1096367
Created Jul 21, 2011
url unescape for vim
View gist:1096367
function GetCode(pos,str)
let s:pos = a:pos
let s:n_code = str2nr(strpart(a:str,s:pos,2),16)
let s:pos = s:pos + 2
"in a certain sns
"if s:n_code == 37
" let s:n_code = str2nr(strpart(s:line,s:pos,2),16)
" let s:pos = s:pos + 2
"endif
return [s:pos,s:n_code]
@takeshy
takeshy / gist:1277528
Created Oct 11, 2011
encodeがわからないファイルをcp932統一する
View gist:1277528
require 'nkf'
Dir.glob("c:/howm/2011/*/*.howm"){|g|
d = File.read(g)
File.open(g,"w"){|f|
f.write(d.force_encoding(NKF.guess(d)).encode("cp932"))
}
}
@takeshy
takeshy / hash_with_value_indifferent_access.rb
Created Nov 12, 2011
hashの値の比較にsymbolでも文字列でも同値とする
View hash_with_value_indifferent_access.rb
require 'forwardable'
class HashWithValueIndifferentAccess
extend Forwardable
attr_accessor :hash
def_delegators(:@hash,*({}.public_methods - Object.new.public_methods - ["[]","[]=","values","==","to_s"]))
def initialize(hash={})
@hash={}
hash.each do|k,v|
if v.is_a?(Symbol)
You can’t perform that action at this time.