2014/09/19

mysql function DETERMINISTIC

・エラー:
This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)


・ファンクション生成に対する(SUPER権限を持たなければならず、決定論的か、データを修正しないかの別を宣言しなければならない)前の規制を緩和するには、グローバル log_bin_trust_function_creatorsシステム変数を1に設定します。
デフォルトで、これは0に設定されていますが、ユーザはこのようにして変更することができます。

mysql> SET GLOBAL log_bin_trust_function_creators = 1;

DETERMINISTIC特性とNOT DETERMINISTIC特性は、
あるインプットに対して、いつも同じ結果を生成するか否かを示します。
いずれかの特性を附与しない場合、デフォルト設定はNOT DETERMINISTICとなります。
ファンクションが決定論的であると宣言するには、DETERMINISTIC を明確に規定しなければなりません。

2014/08/18

mysqldumpでwhen using LOCK TABLESというエラーが出る

MySQLはダンプする前にテーブルにLockをかけるらしいのだが、そのLockをかけることができないようだ。
そこで、ダンプ時に誰も使っていない事が確認できたので(INSERTすることがない)、「--skip-lock-tables」というオプションを使ってダンプを行ったところ無事に完了した。
==>だれがつかったね。。

==> single-transaction
このオプションだとテーブルをロックせず、トランザクションの範囲でバックアップしてくれるとのことだった。

ruby on rails

bundle install
==>Install the modules include in the gemfile.
Unless you specify a version number to the gem command, Bundler will automatically install the latest version of the gem.
bundle update===>update!!


・deployの準備
bundle install --without production
group :production do
    gem 'pg'
    gem 'rails_12factor'
end

・@なになに。。
Once the @users variable is defined, the controller calls the view (Step 6), shown in Listing 2.6. Variables that start with the @ sign, called instance variables, are automatically available in the view;

・rails new sample_app --skip-test-unit
===>not to create test directory

・rails generate controller StaticPages home help --no-test-framework
===>「home help」MVCセットで2つ作る

・rails generate rspec:install
bundle exec rspec spec/requests/..rb==>実行、red->green->refactor

・JetBrains:
==>alt+ctr+s =->editerのところでline番号を表示する。

・<% provide(:title, 'Home') %>
Rails should call the provide function and associate the string ’Home’ with the label :title.
<%= yield(:title) %>
    yield==->自分で定義したブロック付きメソッドでブロックを呼び出すときに使います

・application.html.erb:
<%= yield %>
==>This code is responsible for inserting the contents of each page into the layout. It’s not important to know exactly how this works; what matters is that using this layout ensures that, for example, visiting the page /static_pages/home converts the contents of home.html.erb to HTML and then inserts it in place of <%= yield %>.


・first_name + " " + last_name
===
"#{first_name} #{last_name}"

・# Single-quoted strings don't allow interpolation

・Note that Ruby functions have an implicit return
meaning they return the last statement evaluated

・a = [42, 8, 17]
a[-1]==>17
a.sort
a.sort!===>a!
a.push(6)
a << 7
a << "foo" << "bar"

a.split--->array になる
array.join-->stringになる


(0..9).to_a
a[0..2]


・|i|
==>The vertical bars around the variable name in |i| are Ruby syntax for a block variable

mysql crash

★MySQL のクラッシュの多くは、インデックスファイルやデータファイルの破壊が原因です
-flush を指定して mysqld を開始することによって、各 SQL コマンド実行後、強制的にすべてをディスクと同期させることができます。
 つまり、以下のことがなければ、通常は破壊されたテーブルを得ることはありません。

    誰かまたは何かが、更新中に mysqld またはマシンを強制終了した。

    更新中に mysqld が死ぬようなバグを見つけた。

    テーブルを適切にロックしないで、mysqld 外でデータまたはインデックスフファイルを操作している。

    優れたファイルシステムロック(通常、lockd デーモンによって処理される)をサポートしていないシステム上で、同じデータに対して、多くの mysqld サーバを実行しているか、--skip-external-locking で複数サーバを実行している。

    mysqld を混乱させるような不正なデータを含んだ、破損したインデックスまたはデータファイルがある。

    データストレージのコードにバグを発見した。これはおそらくあり得ないことだが、可能性としてはある。この場合、修正されたテーブルのコピーに対して ALTER TABLE を使用して、ファイルタイプを別のデータストレージエンジンに変更することができる。

★クラッシュの原因を見つけるのは非常に難しいので、まず、他で動作しているものが自分の環境でクラッシュするかどうかを確認してください。
mysqld --log を使用して、ログの情報から、特定のクエリがサーバを終了させるかどうかを判断する。バグの 95% が特定のクエリに関係している。

mysqldump view only

 mysql -u username INFORMATION_SCHEMA
  --skip-column-names --batch
  -e "select table_name from tables where table_type = 'VIEW'
      and table_schema = 'database'"
  | xargs mysqldump -u username database
  > views.sql
===>テーブルを分けるbackupする際、これがあればべんり。

--skip-column-names:
 結果にカラム名を記述しません===>列名がないこと?
--batch
ブとして、カラムセパレータを使用することで、各行が新しいライン上に配置されるように、結果をプリントします。

2014/08/09

window commandline sleep hibernate

Sleep Computer
Rundll32.exe powrprof.dll,SetSuspendState Sleep
If it hibernates instead of Sleep: Hibernate must be OFF

■休止状態機能の有効・無効を切り替える方法

コマンドプロンプトを管理者として実行し、次のコマンドを入力する。
  • 有効にする場合
    > powercfg /hibernate on
  • 無効にする場合
    > powercfg /hibernate off
  • 現在の設定を確認する場合
    > powercfg /a

2014/07/17

git 理解深める

git config --global alias.co checkout ==>カスタマイズ
git config --global core.editor "C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
.gitignore
==>
/.bundel
/db/*.sqlite3
/db/*.sqlite3-
/log/*.log


git log

remote/master
--->git clone ../...を実行する
local:master

リモートサーバーは更新された!
git fetch origin ==>リモートの更新を取得する

git remote add theName address ==>remote サーバー追加、ローカルでtheNameの名前で
git fetch name==>


Git 開発者の多くはこの考え方にもとづいた作業の流れを採用しています。つまり、完全に安定したコードのみを master ブランチに置き、いつでもリリースできる状態にしているのです。それ以外に並行して develop や next といった名前のブランチを持ち、安定性をテストするためにそこを使用します。常に安定している必要はありませんが、安定した状態になったらそれを master にマージすることになります

・git push -u origin masterとすると、次回からは git pushだけでorigin masterにpushする
==>For every branch that is up to date or successfully pushed, add
           upstream (tracking) reference

・git checkout -b modified-locally 
git branch==->全てのブランチ

・localで、
git checkout old-branch
git merge new-branch
==>new-branchをold-branchにmergeする
git branch -d new-branch
git branch -D new-branch--->mergeしていない物があってもDELETE!

・config
git config  --add receive.denyCurrentBranch ingore
git push
===>git config --unsetall key

・ちなみにcommit -vをすると、今から何をコミットしようとしているかのdiffなどが見れるからより安心

ansible 特殊 オプション

対象ホスト:
    hosts:
    [test-sever]
    test-test-[1:2][1:6]

テストオプション
★--list-hosts 対象ホスト名をリストするだけ、ほかに何もしない
    ansible test-server -m ** -a "...." -i hosts --list-hosts
    =>
    test-test-11..test-test-16
    test-test-21..test-test-26

★-l されにホストのfilterである!
  ansible test-server -m ** -a "...." -i hosts -l test-test-11 ==>test-test-11だけ対象になる
  ansible test-server -m ** -a "...." -i hosts -l test-test-1* ==>test-test-11~16 対象になる

★-f 一回実行する数
★-C テストモード

2014/07/15

Ruby On Rails

・ruby をインストールする
==>環境変数に追加する
・DevKit
ーー>downloadして解凍し、インストールする
ruby dk.rb init
==>rubyのディレクトリをconfi.ymlにincludeする
ruby dk.rb install

gem update --system
gem update rake
gem install rails

エラー==>x86_64-w64-mingw32-gcc command not found
    ==>devkitのバージョンが間違った!!


rails new blog
==>project作成

bundle install
==ー>projectを配置する

rake db:create
=->dbを作成する、sqlite is default

rails server
==>serverを起動する

=->地雷:no source of timezone data
----------
Try changing the tzinfo-data line in your Gemfile to gem 'tzinfo-data', platforms: [:x64_mingw, :mingw, :mswin] and then running bundle update.

The :x64_mingw platform option is needed to match 64-bit Windows MinGW builds of Ruby (such as the RubyInstaller x64 builds).
bundel update
---------

rails g controller home index
rails g scaffold post name:string title:string content:text
=>postのapp Templateみたいな物!



class Post < AcitveRecond :: Base
end

==>AcitveRecond :: Baseを継承しているから、CRUD、validate、などすごい機能があります。

==>何となくPLAY Frameworkに似っている!!。同じスタイル!

rails g model comment commenter:string body:text post:references

rake db:migrate===>dbを更新する,modle更新の後で。。