YYYY/MMからYYYYMMにしたい
momentを使っていればformatで変えられるけど、
直前の処理で正しい日付であることが担保されているので単純に正規表現をつかってみたり。
const yyyy_mm = '2017/05' const foo = moment(yyyy_mm).format('YYYYMM'); console.log(foo); // 201705 const hoge = yyyy_mm.replace(/\u002f/g, ''); // スラッシュ=u002f console.log(hoge); // 201705 const hogehoge = yyyy_mm.split('/'); // スラッシュの前後の値が配列としてそれぞれの要素に入る。 console.log(`${hogehoge[0]}${hogehoge[1]}`); // 201705
オブジェクトの判定
Javascriptで中身がないオブジェクトを判定する際のメモ。
const hoge = {};
空でもIFで判定するとtrueになる。
if (hoge) { // true }
中身がないことを判定するにはキーの数がゼロかどうかで見分ける。
if (Object.keys(hoge).length === 0) { }
標準出力&標準エラーどちらもロギングしたい
node + express で作成したアプリを起動時からの標準エラーも含めたログを延々取りたくなったときのコマンド。
npm run dev 2>&1 | tee test.log
openstreetmap + Leaflet.js memo
openstreetmap
https://openstreetmap.jp/
API
http://leafletjs.com/reference.html
レイヤーについて
http://leafletjs.com/examples/layers-control/
プラグイン紹介
http://qiita.com/pokohide/items/6329f1f92253ced23599
ルートの描画
https://github.com/leaflet/Leaflet.Draw#readme
https://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html#l-draw
上のサンプル
https://leaflet.github.io/Leaflet.draw/docs/examples/snapping.html
Using GeoJSON with Leaflet(つかうかな?
http://leafletjs.com/examples/geojson/
http://s.kitazaki.name/docs/geojson-spec-ja.html
カスタマイズ
http://qiita.com/ShingoOikawa/items/41a522c1361e33c3c3dd
CentOS7にzipが入っていなかった件
検証用のCentOSにzipコマンドが含まれているスクリプトを動かしたら
zip: コマンドが見つかりません
え?入ってないんかい。
$ yum list installed | grep zip
bzip2-libs.x86_64 1.0.6-13.el7 @anaconda
gzip.x86_64 1.5-8.el7 @anaconda
ほんとに入ってなかった。
yumでインストールできるかinfoオプションをつけて確認。
$ sudo yum --enablerepo=epel,remi,rpmforge info zip 読み込んだプラグイン:fastestmirror Loading mirror speeds from cached hostfile * base: ftp.iij.ad.jp * epel: ae.mirror.rasanegar.com * extras: ftp.iij.ad.jp * updates: centos.usonyx.net 利用可能なパッケージ 名前 : zip アーキテクチャー : x86_64 バージョン : 3.0 リリース : 11.el7 容量 : 260 k リポジトリー : base/7/x86_64 要約 : A file compression and packaging utility compatible with : PKZIP URL : http://www.info-zip.org/Zip.html ライセンス : BSD 説明 : The zip program is a compression and file packaging : utility. Zip is analogous to a combination of the UNIX : tar and compress commands and is compatible with PKZIP (a : compression and file packaging utility for MS-DOS : systems). : : Install the zip package if you need to compress files : using the zip program.
お、あるある。
じゃあインストール。
$ sudo yum install zip 読み込んだプラグイン:fastestmirror base | 3.6 kB 00:00 extras | 3.4 kB 00:00 updates | 3.4 kB 00:00 updates/7/x86_64/primary_db | 2.2 MB 00:00 Loading mirror speeds from cached hostfile * base: ftp.iij.ad.jp * extras: ftp.iij.ad.jp * updates: centos.usonyx.net 依存性の解決をしています --> トランザクションの確認を実行しています。 ---> パッケージ zip.x86_64 0:3.0-11.el7 を インストール --> 依存性解決を終了しました。 依存性を解決しました ================================================================================ Package アーキテクチャー バージョン リポジトリー 容量 ================================================================================ インストール中: zip x86_64 3.0-11.el7 base 260 k トランザクションの要約 ================================================================================ インストール 1 パッケージ 総ダウンロード容量: 260 k インストール容量: 796 k Is this ok [y/d/N]: y Downloading packages: zip-3.0-11.el7.x86_64.rpm | 260 kB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction インストール中 : zip-3.0-11.el7.x86_64 1/1 検証中 : zip-3.0-11.el7.x86_64 1/1 インストール: zip.x86_64 0:3.0-11.el7 完了しました!
p.s. unzipも入ってなかった。。。
作業メモ - node.js/webpack
d3.jsを触ることになったので
とりあえず勉強中。