最近ブックマークレットでVue.jsを読み込んで既存ページを書き換えるのがマイブーム。
昔ながらの frameset を使っているページでフレームを越えたものを使おうとした時に調べた。
続きを読むJavaScriptでオブジェクトを対象にmapやreduceしたかった。
Object.keys()
でオブジェクトのキーが取り出せるので、それを元にmapやreduceする。
var o = { key1: 'value1', key2: 'value2', key3: 'value3' }; // retuce Object.keys(o).reduce(function (previous, key) { return previous + key + '=' + o[key] + '&'; }, ''); // => "key1=value1&key2=value2&key3=value3&" // map // element means `o`s key (`keys(o)`s element) Object.keys(o).map(function (element, index, array) { return element + '=' + o[element]; }).join('&'); // => "key1=value1&key2=value2&key3=value3"
参考
リバースプロキシとしてnginxを動かしていて、どのnginxやlocationの設定が有効なのか区別したくてヘッダ情報を追加したかった。
この設定で X-Whom: www-node01
とヘッダに追加される。
add_header X-Whom www-node01
この記事ではcurl -I
を使っているけれど、個人的には curl -v
の方が好き。
npmパッケージの依存するパッケージの中にはgit://
で始まるURLが指定されていることがあってプロキシ環境下だとクローンできない。
git://github.com/hogehoge/fugafuga.git
のような。
git://
のみcloneに失敗とか、timeoutのエラー表示ならほぼプロキシを経由できていないからかと思う。
環境変数の設定
HTTP_PROXY, http_proxy, HTTPS_PROXY, https_proxyそれぞれに http://proxy.example.com:8080
のように設定する
続く手段1と2はどちらでも良い。1が簡単。
参考:A simple wrapper around socat to use as a git proxy command
gitプロトコルのアクセスをhttpsでのアクセスに読み替える
~/.gitconfig
の内容(抜粋)[url "https://"] insteadOf = git://
参考:How to use the git protocol through a HTTP CONNECT proxy - Thoughts on Systems socatを利用する
~/bin/gitproxy-socat
という名前で保存したとする
(プロキシのドメインとポートは適宜修正する)#!/bin/sh # Use socat to proxy git through an HTTP CONNECT firewall. # Useful if you are trying to clone git:// from inside a company. # Requires that the proxy allows CONNECT to port 9418. # # Save this file as gitproxy somewhere in your path (e.g., ~/bin) and then run # chmod +x gitproxy # git config --global core.gitproxy gitproxy # # More details at http://tinyurl.com/8xvpny # Configuration. Common proxy ports are 3128, 8123, 8000. _proxy=proxy.example.com _proxyport=8080 exec socat STDIO PROXY:$_proxy:$1:$2,proxyport=$_proxyport
chmod +x ~/bin/gitproxy-socat
~/.gitconfig
の内容(抜粋)[core] gitproxy=gitproxy-socat