2013年1月23日水曜日

【MySQL】AUTO番号を初期化する



ALTER TABLE employees AUTO_INCREMENT =1;

【MySQL】SQLのWariningを表示する

・Warning発生直後に詳細を確認する

 SHOW WARNINGS;

2013年1月22日火曜日

黒猫 SQL Studio で文字化け(utf8)

黒猫 SQL Studio で、文字コードがutf8 のDBにODBC接続すると文字化けする
(ODBC設定でcharacter set = utf8 にしてもダメ)

【対策】
黒猫 SQL Studio でDBに接続時、最初に毎回

SET NAMES SJIS;

を実行する

(参考)
http://takami98.sakura.ne.jp/memocho/index.php?%B3%AB%C8%AF%CD%D1%A3%C4%A3%C2%A4%CB%C0%DC%C2%B3%A4%B9%A4%EB

※)ODBC設定の「Connect Option」 -「Initial Statement」にもいれたが、そちらは
  効かない様子。。。

2013年1月21日月曜日

【Rails】バージョン確認コマンド


■Rubyのバージョンを確認するコマンド
 ruby --version

■Railsのバージョンを確認するコマンド
 rails --version

■RubyGemsのバージョンを確認するコマンド
 gem -v

2013年1月15日火曜日

【git】コミット間の変更差異を調べる

・git log で、差異をとりたいコミットIDを調べて、diff を取る

 git diff [コミットID_1] [コミットID_2]

・変更されたファイル名だけ取りたい場合は

 git diff --stat [コミットID_1] [コミットID_2]

2013年1月10日木曜日

【Rake】ymlでテストデータを作成・読出し


テストデータフォルダ:test/fixtures


■DBからymlへデータをsave
rake db:fixtures:extract [FIXTURES=ファイル名]

 ファイル名に拡張子(.yml)はつけない
   例)
  rake db:fixtures:extract FIXTURES=employees

(参考)
  http://techracho.bpsinc.jp/baba/2012_05_14/5456


■ymlからDBへデータをload
rake db:fixtures:load [FIXTURES=ファイル名]


2012年12月18日火曜日

【GitHub】CentOS5.5でgitHubのリポジトリにpushした時、SSL認証エラー発生



<★現象1>
SSH公開鍵作成、リポジトリ作成して、CentOS5.5の環境から
「git push origin master」しようとすると、SSL認証エラー発生

 error: error setting certificate verify locations:
   CAfile: /bin/curl-ca-bundle.crt
   CApath: none

--------------------
【対応】
 (1)CentOSのca-bundle.crt を最新のものに置き換える

   $ sudo cp -p /etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/ca-bundle.crt.bak
   $ sudo curl http://curl.haxx.se/ca/cacert.pem -o /etc/pki/tls/certs/ca-bundle.crt

 (2)git config --global で、ca-bundle.crt の参照先を指定する

   $ sudo git config --global http.sslcainfo /etc/pki/tls/certs/ca-bundle.crt

(参考)
http://d.hatena.ne.jp/takayuki_goto/20110622/p1
http://www.goodpic.com/mt/archives2/2011/02/github_clonessl.html


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<★現象2>
上記1の対応後、「git push origin master」でgithHubのログイン、パスワード入力すると、
今度はHTTPリクエストエラーが発生

 error: The requested URL returned error: 403 while accessing  
 https://github.com/yadamada/test_yadamada.git/info/refs
 fatal: HTTP request failed

--------------------
【対応】


SSHの公開キー未設定の場合は設定する

  (参考)
  http://yachi-googleblogyachiyo.blogspot.jp/2012/12/githubssh.html



/git/cconfig のurl を、https → ssh に書き換える(httpではなく、SSHで送信するよう設定)

  # vi .git/config

  (変更前) url = https://github.com/username/test_repojitory.git
  (変更後) url = ssh://git@github.com/username/test_repojitory.git

(参考)
http://stackoverflow.com/questions/7438313/pushing-to-git-returning-error-code-403-fatal-http-request-failed



上記(1)(2)の対処を行った後、「git push origin master」 すると、SSHの認証確認になるので
SSHのPassphrase を入力

 >>>>>>>>>
 Enter passphrase for key '/home/username/.ssh/id_rsa':
 Counting objects: 3, done.
 Writing objects: 100% (3/3), 215 bytes, done.
 Total 3 (delta 0), reused 0 (delta 0)
 To ssh://git@github.com/username/test_repojitory.git
  * [new branch]      master -> master
 >>>>>>>>>

 → push 成功!