2014-01-01から1年間の記事一覧

Firewall busting(UDP Hole Punching)の例

http://www.rubyinside.com/skype-style-firewall-busting-with-ruby-and-udp-399.html require 'socket' remote_host = ARGV.first # Punches hole in firewall punch = UDPSocket.new punch.bind('', 6311) punch.send('', 0, remote_host, 6311) punch.cl…

wsモジュールでエコーサーバ

http://einaros.github.io/ws/

wsモジュールのクライアント側の例

http://ishiduca.hatenablog.com/entry/2012/04/20/102437

wsモジュールでsocket.ioモジュールのio.json.send()の代替

http://stackoverflow.com/questions/13028604/sending-a-javascript-object-through-websockets-with ストリン”ギ”ファイに注意. ws.send(JSON.stringify(object));

socket.ioサーバでXMLHttpRequest cannot load...Access-Control-Allow-Origin.エラーが出るとき

https://groups.google.com/forum/#!topic/socket_io/Fkq9Pyc8s6E io.set('origins','*:*');を追加する.

wsモジュールとsocket.ioモジュールの違い

クライアントから接続する際の待受け方法 ws(echo.websocket.orgはこっち?) var WebSocket = require('ws') , ws = new WebSocket('ws://echo.websocket.org/'); ws.on('open', function() { ws.send('something'); }); ws.on('message', function(message)…

Websocketのエコーテスト

wscatを使う wscat -c ws://echo.websocket.org connected (press CTRL+C to quit) > hoge < hoge > foobar < foobar >

SDPとICE Candidateの解読

SDP(Session Description Protocol) { "sdp": "v=0 o=- 3906791927516013147 2 IN IP4 127.0.0.1 s=- t=0 0 a=group:BUNDLE audio video a=msid-semantic: WMS TKMM4gYgo2chdd15vH5kcJpr2rE0cP37Lh8R m=audio 1 RTP/SAVPF 111 103 104 0 8 106 105 13 126 c=…

socket.io.jsの読込み

http://stackoverflow.com/questions/8689877/cant-find-socket-io-js <script src="<node.jsが立ち上がっているサーバ:ポート>/socket.io/socket.io.js"></script> のようにする.例えば <script src="http://localhost:9001/socket.io/socket.io.js"></script>

rfc5766-turn-server(STUNサーバ)のインストール

http://html5experts.jp/mganeko/5554/hiredisのインストール wget http://dl.fedoraproject.org/pub/epel/6/x86_64/hiredis-0.10.1-3.el6.x86_64.rpm sudo rpm -Uvh hiredis-0.10.1-3.el6.x86_64.rpm sudo yum install hiredisrfc5766-turn-serverのインス…

Centosにredisのインストール

http://qiita.com/n0bisuke/items/2448010c0dfaf8a20167

UDP Hole Punchingのテスト

http://www.rapapaing.com/blog/?p=24server.c // UDP hole punching example, server code // Base UDP code stolen from http://www.abc.se/~m6695/udp.html // By Oscar Rodriguez // This code is public domain, but you're a complete lunatic // if y…

node.jsでPeerJSを使う

できそう http://stackoverflow.com/questions/23902598/peerjs-connection-opens-but-no-data-is-received http://stackoverflow.com/questions/18872712/node-js-webrtc-client

画像をCanvasの幅に合わせて拡大縮小する

画像の貼り方 http://icondecotter.jp/blog/2013/01/30/html5canvas%E4%B8%8A%E3%81%AB%E8%AA%AD%E3%81%BF%E8%BE%BC%E3%82%93%E3%81%A0%E7%94%BB%E5%83%8F%E3%82%92%E8%B2%BC%E3%82%8A%E4%BB%98%E3%81%91%E3%82%8B/リサイズ http://stackoverflow.com/questi…

Chrome Appのローカルアプリ化

http://qiita.com/sjuny/items/b3493a0a1145b247cd2a http://iti.hatenablog.jp/entry/2013/10/10/115550App一覧の画面で右クリック→ショートカット作成,でできる.

Chromeで特定のURLのみを開くアプリを作る

以下のようにappオプションを付けて起動する /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --app="http://shoheiaoki.com/"アプリケーションバンドルにする方法 https://www.lessannoyingcrm.com/blog/2010/08/149/Create+application+s…

EmscriptenでBlobオブジェクトをファイル入力に渡す

http://stackoverflow.com/questions/15980585/how-to-change-emscripten-browser-input-method-from-window-prompt-to-something-mo

Vimの再インストール

homebrewでPythonを入れたが,vimは依然としてシステムデフォルトのPythonを見に行ってたので Powerlineがエラーを起こしていた. $ brew install vim --enable-interp=python,python3,ruby --with-lua

pyenvの使い方

homebrewでpythonを入れるとなんかおかしくなるので pyenvで入れることにする. http://qiita.com/maosanhioro/items/47a52f96fefba7126f9b rbenvと使い方が似てて使いやすそう. ~/.zshrc #pyenv if which pyenv > /dev/null; then eval "$(pyenv init -)";…

homebrewがupdateできなくなったとき

gitリセットする http://blog.f13.jp/post/20626146392/brew-brew-update cd `brew --prefix` git fetch origin git reset --hard origin/masterエラーが出た. /usr/local以下のフォルダの権限らしい. http://qiita.com/sawa-@github/items/62e2ffc9cdc615…

Pythonでワンライナー

http://jum12.hatenablog.com/entry/2013/10/09/231447 python -c "print 'hello'"

はてなダイアリーのコードを折り返す

長年の疑問が解決した. http://q.hatena.ne.jp/1142749431#a503461管理画面のCSSに以下を指定する. pre { white-space: -moz-pre-wrap; /* Mozilla */ white-space: -pre-wrap; /* Opera 4-6 */ white-space: -o-pre-wrap; /* Opera 7 */ white-space: pre…

powerlineの再インストール

pythonをHomebrewで入れたらPowerlineが起動しなくなったhomebrewのpythonをアンインストールした. pythonはpyenvで管理することにする.

/usr/bin/pythonと/usr/local/bin/pythonの違い

やっぱりsys.pathが違う. $ python -c "import sys;arr=sys.path;ans=[a for a in arr if a.find('usr') > 0];print ans;print len(ans)" # ['/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip…

Macにvirtualenvwrapperをインストール

http://qiita.com/_rdtr/items/5f3a9a9e2cb5a24f284e sudo pip install virtualenvwrapperpython3で試してみる brew install python3 mkvirtualenv --python=/usr/local/bin/python3 testdayo workon testdayo deactivate rmvirtualenv testdayo

Macにvirtualenv-pyenvをインストール

http://qiita.com/maosanhioro/items/47a52f96fefba7126f9b $ brew install pyenv-virtualenv #To enable shims and autocompletion add to your profile: # if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi #To use Homebrew's directories r…

JavaScript File APIでファイルを保存する

http://www.atmarkit.co.jp/ait/articles/1112/16/news135_2.html blobBuilderはdeprecatedとのこと. 新しいblobの書き方 http://qiita.com/mohayonao/items/fa7d33b75a2852d966fcindex.html <html lang="en"> <head> <meta charset="UTF-8"> <title></title> </head> <body> </body></html>

PythonのSimpleHTTPServer起動をシェル化した

表題どおり. /usr/local/bin/phttpd #!/bin/zsh if [ $# -eq 1 ]; then PORT = $@ fi python -m SimpleHTTPServer ${PORT}

uint8arrayを文字列に変換する

http://lowreal.net/2014/07/08/1 String.fromCharCode.apply(null, ARRAY) でできる.

ブラウザからファイル入出力させるpng_pathの生成

https://github.com/ukyo/emscripten-fileio を参考に.まずfab.cのfopenで指定している, 1. input_file_name -> "input"に変更, 2. output_file_name -> "output"に変更する.はまりどころ,考慮する点としては ・fab.cのfopenにおける入力ファイル名と出…