Windowsでのnode.js環境の作成

2015/02/22
パッケージ管理ソフトChocolateyをインストールする。
Chocolatey Gallery

PowerShellは管理者として実行する。
PS C:\> Set-ExecutionPolicy RemoteSigned
PS C:\> iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
※Windows7だと.net関連を追加でインストールするため結構かかる

ツールをインストールする。
PS C:\> cinst python2
PS C:\> cinst ruby
PS C:\> cinst mongodb
PS C:\> cinst msysgit
PS C:\> cinst poshgit
PS C:\> cinst PhantomJS
PS C:\> cinst Cygwin -o -ia '-q -N -R C:\tools\cygwin -l C:\tools\cygwin\packages --packages wget, tar, openssh, bzip2 -s http://ftp.iij.ad.jp/pub/cygwin'
PS C:\> cinst cyg-get

node.js用にnodistをインストールする。
nodistはChocolateyでもインストールできるが、古い&まだベータ版(インストールしてみたけどがっかりだった)なので、GitHubからとってきて入れる。ここではPowerShellを使ってアーカイブをダウンロードしたが、gitコマンドが使える環境であればgit cloneする。
PS C:\> (New-Object Net.WebClient).DownloadFile('https://github.com/marcelklehr/nodist/zipball/master','C:\tools\nodist.zip');(New-Object -com Shell.Application).NameSpace('C:\tools').CopyHere((New-Object -com Shell.Application).NameSpace('C:\tools\nodist.zip').Items(),16)
フォルダはnodistにリネームしておく。

nodistが使用する環境変数を設定する。
README.mdにあるsetx /M PATH "path\to\nodist\bin;%PATH%"で設定したら、システム環境変数のPATHが消えてえらい目にあった…。
PS C:\> [Environment]::SetEnvironmentVariable('NODIST_PREFIX', 'C:\tools\nodist', 'Machine')
PS C:\> [Environment]::SetEnvironmentVariable('NODIST_X64', '1', 'Machine')
PS C:\> [Environment]::SetEnvironmentVariable('PATH', [Environment]::GetEnvironmentVariable('PATH', 'Machine') + ';' + 'C:\tools\nodist\bin', 'Machine')
PS C:\> [Environment]::SetEnvironmentVariable('NODE_PATH', 'C:\tools\nodist\bin\node_modules', 'Machine')

環境変数を反映させるためPowerShellを再起動して、nodistでnode.jsをインストールする。
PS C:\> nodist selfupdate
PS C:\> npm config set prefix %NODIST_PREFIX%\bin (なくても動くっぽい)
PS C:\> nodist
(x64)
> 0.12.0  (global)

YEOMAN, grunt, その他をインストールする。gemでSSLのエラーが出るのでhttpも追加しておく。
PS C:\> npm install -g yo grunt-cli bower
PS C:\> npm install -g generator-angular-fullstack
PS C:\> gem source -a http://rubygems.org/
PS C:\> gem install compass
Read more ...

Fedora 21にRedmineをインストール

2015/02/16

パッケージのインストール

SELinuxのためにpassengerはパッケージで入れる。libxml2-devel、libxslt-devel、ImageMagick-develは、gemのインストール痔に必要。
# yum groupinstall 'Development Tools' # yum install setroubleshoot-server setools-console # yum install mariadb-server mariadb-devel # yum install ruby-devel rubygem-bundler mod_passenger # yum install libxml2-devel libxslt-devel ImageMagick-devel # yum install ipa-pgothic-fonts

MariaDB(MySQL)の設定

/etc/my.cnf.d/server.cnf
...... # this is only for the mysqld standalone daemon [mysqld] character-set-server=utf8 ......
/etc/my.cnf.d/mysql-clients.cnf
...... [mysql] default-character-set=utf8 ......

MariaDBの起動とユーザ/テーブルの作成

# systemctl start mariadb # systemctl status mariadb # systemctl enable mariadb Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service. # mysql_secure_installation # mysql -u root -p MariaDB [(none)]> create database redmine default character set utf8; MariaDB [(none)]> grant all on redmine.* to redmine@localhost identified by '********'; MariaDB [(none)]> flush privileges; MariaDB [(none)]> exit;

Redmineのインストール

# svn co http://svn.redmine.org/redmine/branches/2.5-stable /usr/share/redmine # cd /usr/share/redmine
config/database.yml
production: adapter: mysql2 database: redmine host: localhost username: redmine password: ******** encoding: utf8
config/configuration.yml
production: email_delivery: delivery_method: :smtp smtp_settings: address: "localhost" port: 25 domain: 'example.com' rmagick_font_path: /usr/share/fonts/ipa-pgothic/ipagp.ttf

Gemのインストール

# bundle config build.nokogiri --use-system-libraries# bundle install Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine. Fetching gem metadata from https://rubygems.org/......... Resolving dependencies... Installing rake 10.4.2 Installing i18n 0.6.11 Installing multi_json 1.10.1 Installing activesupport 3.2.21 Installing builder 3.0.4 Installing activemodel 3.2.21 Installing erubis 2.7.0 Installing journey 1.0.4 Installing rack 1.4.5 Installing rack-cache 1.2 Installing rack-test 0.6.3 Installing hike 1.2.3 Installing tilt 1.4.1 Installing sprockets 2.2.3 Installing actionpack 3.2.21 Installing mime-types 1.25.1 Installing polyglot 0.3.5 Installing treetop 1.4.15 Installing mail 2.5.4 Installing actionmailer 3.2.21 Installing arel 3.0.3 Installing tzinfo 0.3.43 Installing activerecord 3.2.21 Installing activeresource 3.2.21 Using bundler 1.7.6 Installing mini_portile 0.6.2 Installing nokogiri 1.6.6.2 Installing xpath 2.0.0 Installing capybara 2.4.4 Installing ffi 1.9.6 Installing childprocess 0.5.5 Installing coderay 1.1.0 Installing rack-ssl 1.3.4 Installing json 1.8.2 Installing rdoc 3.12.2 Installing thor 0.19.1 Installing railties 3.2.21 Installing jquery-rails 3.1.2 Installing metaclass 0.0.4 Installing mocha 1.0.0 Installing mysql2 0.3.17 Installing net-ldap 0.3.1 Installing ruby-openid 2.3.0 Installing rack-openid 1.4.2 Installing rails 3.2.21 Installing rbpdf 1.18.5 Installing redcarpet 2.3.0 Installing request_store 1.0.5 Installing rmagick 2.13.4 Installing rubyzip 1.1.7 Installing websocket 1.2.1 Installing selenium-webdriver 2.44.0 Installing shoulda-context 1.0.2 Installing shoulda-matchers 1.4.1 Installing shoulda 3.3.2 Installing yard 0.8.7.6 Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed. Post-install message from rmagick: Please report any bugs. See https://github.com/gemhome/rmagick/compare/RMagick_2-13-2...master and https://github.com/rmagick/rmagick/issues/18

Redmineの初期設定とデータベースのテーブル作成

# bundle exec rake generate_secret_token # RAILS_ENV=production bundle exec rake db:migrate

SELinuxまわりの設定

RedmineをSELinuxが有効なCentOS上で動かすには - C#などの技術メモ
http://d.hatena.ne.jp/myoshino2011/20131230/1388416394
# setsebool httpd_run_stickshift 1 # getsebool httpd_run_stickshift httpd_run_stickshift --> on # semanage fcontext -a -s system_u -t httpd_sys_content_t "/usr/share/redmine(.*/)?(.*)" # restorecon -R -F /usr/share/redmine/ # chown -R apache:apache /usr/share/redmine

httpd設定

/etc/httpd/conf.d/redmine.conf
# # Redmine is flexible project management web application. # <virtualhost *:80> ServerName redmine.example.com DocumentRoot /usr/share/redmine/public <directory /usr/share/redmine/public/> <ifmodule mod_authz_core.c> # Apache 2.4 Require ip 192.168.1.0/24 Require ip 127.0.0.1 </IfModule> <ifmodule !mod_authz_core.c> # Apache 2.2 Order Deny,Allow Allow from 192.168.1.0/24 Allow from 127.0.0.1 </IfModule> #Uncomment the next line if using with SSL/TLS #php_flag session.cookie_secure on AllowOverride All </Directory> </VirtualHost> # systemctl start httpd.service # systemctl status httpd.service # systemctl enable httpd.service Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. # firewall-cmd --add-service=http --zone=FedoraServer # firewall-cmd --add-service=http --zone=FedoraServer --permanent
さて、これで起動できるわけだが、[管理]メニューにアクセスするとエラーになる。しかし、1度setenforce 0してからアクセスすると、エラーがでなくなる。SELinuxが関係しているのは間違いなさそうだが、ざっと見動いてるのでもういいや(゚∀゚)
Read more ...

複数のGoProの画像を一括で補正する

2015/02/14
GIMPを使います。

[ファイル]-[Batch Image Manipulation Plugin]を選択。
[Add]をクリックして[Other GIMP procedure]を選択。

 [plug-in-lens-distortion]を選択。これは[フィルター]-[変形]-[レンズ補正]に相当する処理です。変形パラメータを入力して[OK]。

さらにPNG->JPEGのフォーマット変換もかけるため、[Change format and compression]を追加。

JPEG設定。

最後に[Add images]ボタンから変換するファイルを選択し、[Output folder]で出力先を指定して、[Apply]で変換開始。

下記はffmpegを使用して、動画から1秒毎に1枚画像を切り出す処理。しかし画質がイマイチだったため、VLCのSS機能を使用した。
C:\Program Files\WinFF>ffmpeg.exe -i "D:\Desktop\GOPR0032.MP4" -f image2 -vf fps=fps=1 D:\out\shot%05d.jpg

動画をフレームにバラして変換をかけてから再度結合すれば、動画の補正もいけるかも?
Read more ...