2013年3月24日日曜日

Windowsで生成したcsvファイルをPostgreSQLへインポートしたよ

サーバはLinuxでDBはPostgreSQL…

WindowsでCSVファイルを生成して、\copyコマンドでインポートしたい!

なやましいところ

改行コード
文字コード
BOM(なんだこれ?)

改行コードヘ(^o^)ノ
WindowsはCR+LF
Linux、Mac OS XはLF

僕はC#.NETでアプリ作ってたからControlChars.LFで

文字コード
これはファイル作成時にUTF-8を指定してファイルを作ってあげればよい

それでもできない…なぜ…

それはBOM…
od -c file_path で見てみると…
なにやら先頭に357 273 277←こいつですよ

UTF8Encoding(false)でBOMを無効にできる

コマンドでもできる

めんどくさい…

と、統一しようぜ…Win…do…

( ̄(エ) ̄)彡☆

2013年3月12日火曜日

MBAの環境構築ヘ(^o^)ノ

ヘ(^o^)ノ

Xcode
Command Line Tools
Homebrew

$ brew install wget
$ brew install rbenv
$ brew install ruby-build

.bashrc or .zshrc
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init - zsh)" ← zsh
eval "$(rbenv init -)" ← bash

$ rbenv install 2.0.0-p0
$ rbenv global 2.0.0-p0
$ gem install bundle
$ gem install pry
$ gem install powder
$ rbenv rehash

bashの人
bundler exec
curl -L https://github.com/gma/bundler-exec/raw/master/bundler-exec.sh > ~/.bundler-exec.sh
$ echo "[ -f ~/.bundler-exec.sh ] && source ~/.bundler-exec.sh" >> ~/.bashrc

zshの人
bundler exec 
$ curl -L https://raw.github.com/willnet/bundler-exec/master/bundler-exec.sh > ~/.bundler-exec.sh
$ echo "[ -f ~/.bundler-exec.sh ] && source ~/.bundler-exec.sh" >> ~/.zshrc

Github for Mac
iTerm2
TextMate バイナリはここ
Postgres.app
MacRuby
RubyMotion (有料ですw
R for Mac
RStudio

TextMateでRubyMotionの補完 ここを参考
$ cd ~/Library/Application\ Support/
$ git clone https://github.com/libin/RubyMotion.tmbundle.git Avian/Bundles/RubyMotion.tmbundle

Railsヘ(^o^)ノ
$ mkdir hoge
$ cd hoge
$ vi Gemfile

Gemfile
source 'https://rubygems.org'
gem 'rails', git: 'git://github.com/rails/rails.git'

$ bundle install --path vendor/bundler
$ rails new .  (bundler execがインストールされてないならbundle exec rails new .
$ bundle

こんな感じ