2012年12月18日火曜日

【GitHub】SSH公開キー&リポジトリ作成手順


gitHubのアカウントを作成後、SSH公開鍵を作成し、リポジトリを登録、pushするまでの手順
(環境:CentOS5.5)

(1) https://github.com/ にSign In

(2) SSH公開鍵作成

 ・CentOS環境にTeraTermで入って
  
  ssh-keygen
  
 ・「Enter file in which to save the key (/Users/machida/.ssh/id_rsa): 」と
  表示されるので、Enterキー押す

 ・「Enter passphrase (empty for no passphrase):」と表示されたら、
  SSH用のパスフレーズを決めて入力(確認出るのでもう一度入力)
  
  →下記の場所に公開鍵(id_rsa.pub)と秘密鍵(id_rsa)が作成される
  
   $HOME/.ssh/

(3) 作成したSSH公開鍵をGitHubのアカウントに設定する

 ・https://github.com/ の右上「Account Setting」アイコンクリック
 ・左側のメニューから「SSH Keys」選択
 ・「Add SSH Key」をクリック
  タイトル:鍵のタイトル(適当に決める)
  キー:公開鍵(id_rsa.pub)の内容を丸ごとコピー&貼り付け

  →キーの下の「Add Key」クリックで保存

(4)リポジトリの作成

 ・ https://github.com/ の右上「Create a New Repo」アイコンクリック
 ・リポジトリ名、説明(Description)を記入
  (Public / Private の選択あるが、無料の場合はPublic のみ可)
  →「Create Repository」クリックでリポジトリ作成

(5)GitHubのヘルプ(https://help.github.com/articles/create-a-repo)
 を参考に、CentOS環境にリポジトリフォルダ & READMEファイルを作成

  $ mkdir [フォルダ名]
  $ cd [フォルダ名]
  $ git init
  $ touch README

(6)READMEファイルをgit add /git commit する
 (READMEの中身は空でよい)

  git add README
  git commit -m 'firast commit'

(7)READMEファイルをgit push する

  $ git remote add origin https://github.com/[username]/[リポジトリ名].git
  (例: git remote add origin https://github.com/yadamada/test_yadamada.git)

  $ git push origin master

  → SSHの認証エラー等発生するので、以下の方法で対処

  【GitHub】CentOS5.5でgitHubのリポジトリにpushした時、SSL認証エラー発生
    http://yachi-googleblogyachiyo.blogspot.jp/2012/12/githubcentos55githubpushssl.html

(8)  https://github.com/ で、作成したリポジトリの「Code」クリックし、
  READMEファイルが登録されていることを確認

2012年12月14日金曜日

【Open Office3.0】BaseデータをCalcに貼り付けると文字化けする

Open Office3.0 で、Baseデータを表示させて、Calcにコピー&貼り付けると文字化けする

【対応】
Calcをあらかじめ表示しておき、Baseのテーブルアイコンをドラッグ&ドロップすると
文字化けせずに内容貼り付けできる

(参考)
http://forum.openoffice.org/ja/forum/viewtopic.php?f=16&t=209

2012年11月21日水曜日

【Rake】初期データを投入する


【初期データの設定】
  db/seed.rb で、モデルの初期データ設定を記述(create)
 csvからの読み込みも可能

 (参考)
  http://www.rubylife.jp/rails/model/index10.html



【初期データの投入】

    rake db:seed


【DB作成&初期データ投入】


 ・DB作成&初期データ投入(migration実行ではなく、schema.rbから復帰)
  (Create the database, load the schema, and initialize with the seed data)


      rake db:setup

 ・DB再作成&初期データ投入(migration実行ではなく、schema.rbから復帰)
  (Drops and recreates the database from db/schema.rb
       for the current environment and loads the seeds)

      rake db:reset

  ・schema.rbでなく、migration から再作成したいときは

      rake db:migrate:reset

(参考)
rakeのタスク一覧
http://pentan.info/ruby/ror/rake_list.html#rake_db

2012年11月9日金曜日

UNIXコマンド(grep検索、ソート、置換)



・ファイル内のある文字列をすべて検索(grep)

  [例]
    grep 'text' file1.txt


・ファイル内の行をソートして重複する内容を除く(sort FILE | uniq)

  [例]
   sort file1.txt | uniq


・ファイル内の文字列を置換してを除く(sed)

  [例] 
      sed -e "s/henko_text//g;" file1.txt




        ※)置換に「/」を含む場合、置換区切り文字には別の文字(「%」など)を指定)


        sed -e "s%diff --git a/%%g;" file1.txt


2012年11月7日水曜日

【UNIX】オーナー変更(chown)



# chown user file
ファイル file の所有者をユーザ user に変更する
# chown user:group file
ファイル file の所有者/グループを user/group に変更する
# chown :group dir
ディレクトリ dir のグループを group に変更する


・フォルダ以下のすべての所有者/グループを user/group に変更する

# chown -R user:group .


2012年11月6日火曜日

【git】ブランチの作成

【ブランチを一覧表示】

 git branch          (ローカルに存在するブランチのみ表示)
 git branch -a         (ローカルとリモート全てに存在するブランチが表示)



【ローカルブランチの作成と切替(チェックアウト)】

 git branch [作成ブランチ名]
 git checkout [作成ブランチ名]


(例)

 (1) ローカルの「develop」から「feature」ブランチを作成して切替

   git checkout -b feature-2.2.1 develop

    ※「-b」は「git branch」のショートカット



 (2)「feature-2.2.1」というローカルブランチを、リモートの「origin/develop」から作成して切替

   git checkout -b feature-2.2.1 remotes/origin/develop



【ブランチのマージ】

 git checkout [マージ先ブランチ名]
 git merge [--no-ff] [マージしたいブランチ名]

(例)
  ローカルのdevelop に feature-2.2.1 をマージしたい場合

    git checkout develop
    git merge --no-ff feature-2.2.1



【マージ済みのブランチ一覧を表示】

  git branch --merged

【マージされていないブランチ一覧を表示】

  git branch --no-merged

【ブランチの削除】

  git branch -d [ブランチ名]

   ※マージ済みでない(作業が残っている)ブランチは「-d」で削除できない。
   ※強制削除したい場合は大文字「git branch -D」で削除




【ブランチ名を変更】

 git branch -m [新ブランチ名]


【既存のブランチ名に上書き変更】
 git branch -M [新ブランチ名]



2012年10月30日火曜日

firebugが消えた

Firefox(ver14.0.1)から突然 fireBugが消えた
 ⇒「ツール」-「Web開発」-「その他のツール」で
「Firefoxに追加」押すとふっかつ!