Archive for: 𔃹月 2015’

Capistrano3.x の覚え書き。

2015年9月22日 Posted by PURGE

以前といっても既に、3年程前に、Capstranoを設定していたが、既にCapstrano3.xの時代。
久しぶりに設定する機会があったので覚え書き。

Railsの設定
Gemfile にデフォルトでコメントアウトされている下記の記述を有効にして、bundle update 。

# Use Capistrano for deployment
gem 'capistrano-rails', group: :development
$ bundle update
$ capify .
--------------------------------------------------------------------------------
Capistrano 3.x is incompatible with Capistrano 2.x. 

This command has become `cap install` in Capistrano 3.x

For more information see http://www.capistranorb.com/
--------------------------------------------------------------------------------

capify . にて設定ファイルを作成しようとしたが、怒られたので、cap install を実行する。

$ cap install
mkdir -p config/deploy
create config/deploy.rb
create config/deploy/staging.rb
create config/deploy/production.rb
mkdir -p lib/capistrano/tasks
create Capfile
Capified

すると、Capfile と、config/deploy.rb、config/deploy/staging.rb、config/deploy/production.rb が作成される。

Gitのサーバ設定

Gitのインストール。

$ yum install git

Git共有リポジトリの作成。

$ mkdir /var/lib/git/public_git/sample.git
$ cd /var/lib/git/public_git/sample.git
$ git init --bare --share 

Gitのクライアント設定

$ git init
$ git add .
$ git commit -m "First commit"
$ git remote add sample ssh://User名@Host名:SSHポート番号/var/lib/git/public_git/sample.git
$ git push sample

mount時に正常なブロックデバイスではありませんエラー

2015年9月14日 Posted by PURGE

CentOSからWindowsサーバへバックアップを取る為にマウントする必要がある。

$ mount -t cifs -o username=hoge,password=xxxx "//192.168.0.5/Backup/" /mnt/win

mount時に正常なブロックデバイスではありませんエラーが発生。
samba-clientが必要らしくインストール。

$ yum install samba-client

それでもまだ同じエラーが起きていたので、cifs-utilsのインストール。
CIFS-UTILs

$ tar jxvf cifs-utils-6.3.tar.bz2
$ cd cifs-utils-6.3
$ ./configure --prefix=/usr
$ make
$ make install

マウント可能となった。

ちなみに、rootユーザ以外がmountする必要がある場合、visudoにて下記を追記する。

$ sudo visudo

%ユーザ名  ALL=(ALL) /bin/mount, /bin/umount

D3でネットワーク図やマップ描画の覚え書き

2015年9月11日 Posted by PURGE

ネットワーク図描画

<html>
<head>
<title>取引ネットワーク図</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js" charset="utf-8"></script>
<style>
  svg{width: 640px; height: 640px; border: 1px solid black; background-color: #fff;}
  .forceLine{stroke:blue; stroke-width:2;}
</style>

</head>
<body>
  <h2>取引ネットワーク図</h2>
  <svg id="myNetwork"></svg>
  <script src="js/network.js"></script>
</body>
</html>
var dataSet = {nodes : [{name : "Apple"}, {name : "Orange"}, {name : "Banana"}, {name : "Melon"},],
                        links : [{ source : 0, target : 1}, {source : 1, target : 0}, {source : 2, target : 0},{source : 3, target : 0}]
                      }

var force = d3.layout.force()
    .nodes(dataSet.nodes)
    .links(dataSet.links)
    .size([320, 320])
    .linkDistance(100)
    .linkStrength(5)
    .gravity(0.0001)
    .start()

var link = d3.select("#myNetwork")
  .selectAll("line")
  .data(dataSet.links)
  .enter()
  .append("line")
  .attr("class", "forceLine" )

var node = d3.select("#myNetwork")
  .selectAll("circle")
  .data(dataSet.nodes)
  .enter()
  .append("circle")
  .attr("r", 10 )
  .call(force.drag)

force.on("tick", function(){
  link
  .attr("x1", function(d) { return d.source.x;})
  .attr("y1", function(d) { return d.source.y;})
  .attr("x2", function(d) { return d.target.x;})
  .attr("y2", function(d) { return d.target.y;})
  node
  .attr("cx", function(d) { return d.x;})
  .attr("cy", function(d) { return d.y;})
})

地図描画

<html>
<head>
<title>群馬県</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js" charset="utf-8"></script>
<script src="http://d3js.org/d3.geo.projection.v0.min.js" charset="utf-8"></script>
<style>
  svg{width: 640px; height: 640px; border: 1px solid black; background-color: #fff;}
</style>
</head>
<body>
  <h2>群馬県</h2>
  <svg id="myMap"></svg>
  <script src="js/map.js"></script>
</body>
</html>
var svgWidth = 640;
var svgHeight = 640;
var path = d3.geo.path()
                .projection(d3.geo.mercator()
                                          .center([138.700, 36.5000])
                                          .scale(24000)
                                          .translate([200,300])
                                        )
                                        d3.json("js/Gumma.json",
                                                    function(error, pref) {
                                                      d3.select("#myMap")
                                                          .selectAll("path")
                                                          .data(pref.features)
                                                          .enter()
                                                          .append("path")
                                                          .attr("d", path)
                                                          .style("fill", "#cceeee")
                                                    })