Skip to content

Instantly share code, notes, and snippets.

View takeshy's full-sized avatar

takeshy takeshy

  • Sun Asterisk
  • Yokohama
View GitHub Profile
@takeshy
takeshy / app.js
Last active August 29, 2015 14:02
socket.ioでiPhone,Androidでローディングが続く問題
var static = require('node-static');
var file = new static.Server('.');
server = require('http').createServer(function (request, response) {
request.addListener('end', function () {
file.serve(request, response);
}).resume();
})
server.listen(60000);
var io = require('socket.io').listen(60001);
io.sockets.on('connection', function(socket){
@takeshy
takeshy / js_loader.js
Created January 1, 2015 03:58
on demand loading js
JsLoader = function(srcMap){
this.srcMap = {};
for(key in srcMap){
this.srcMap[key] = {state: "unload",src: srcMap[key],cb: []}
}
};
JsLoader.prototype = {
load: function(m,cb){
var that = this;
if(!this.srcMap[m]){
@takeshy
takeshy / hex2bin.rb
Created April 22, 2015 09:01
HEX文字列をbinaryに変換する
#!/bin/env ruby
$HEX = false
if ARGV[0] == "-x"
$HEX = true
ARGV.shift
end
if ARGV.length != 1
puts "#{$0} outputfile"
exit -1
#!/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]]
(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)
@takeshy
takeshy / gist:831301
Created February 17, 2011 08:26
.zshrc
# 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 February 22, 2011 02:07
OAuth Consumer Request(2-legged OAuth)
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 March 29, 2011 07:50
rackベースのoauth signatureチェック
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
@takeshy
takeshy / gist:895706
Created March 31, 2011 02:16
vim scp
" 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
@takeshy
takeshy / gist:895709
Created March 31, 2011 02:21
emacs scp
(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")