mac + mysql5.7.9
mac (OS X El Capitan 10.11.1) にmysqlを入れたんですが
brew install mysql mysql.server start
でサーバーが起動します。
ですが、
mysql -uroot
でログインできなかったのでメモをば。
brew info mysql
で確認してみると
Build: cmake の右にあるチェックマークが赤色だった。
cmake が入っていないようなので、cmakeを入れて再度mysqlをインストールする。
brew uninstall mysql brew install cmake brew install mysql brew info mysql
でBuild: cmake の右にあるチェックマークが緑色になった。
$ mysql.server start $ mysql -uroot ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
どうやら、rootにもパスワードがつくようになったみたい。
この場合、セーフモードで起動してrootパスワードを変更する必要があるようです。
mysql.server stop mysqld_safe --skip-grant-tables
ターミナルが操作できなくなるので、新規でターミナルを立ち上げて
mysql -uroot
でログインできるようになりました。
早速パスワードを変えていきます。
use mysql; UPDATE user SET authentication_string=password('ここに希望のパスワードを入力する') WHERE user='root'; flush privileges; quit;
mysql再起動
mysql.server restart
このままだとmysqlにログインしてもコマンド実行できないので再度パスワード変更
mysql -uroot --connect-expired-password -p set password='ここに希望のパスワードを入力する' exit;
これでmysqlが使えるようになります。
mysql -uroot -p mysql> show databases;
DB一覧が表示されればOK。
ItemsSourceを設定した際、親のDataContextにバインドする
ListBoxでItemsSourceを設定すると、親のDataContextにバインドできなくなる。
やりたいこととしては、下に書いた方法で親DataContextのHeightにバインドしたい。
でも下の方法ではできない。
MainWindowViewmodel.cs
class WindowViewModel { public List<string> List { get; set; } public int Height { get; set; }
MainWindow.xaml
<Grid> <ListBox Grid.Column="2" ItemsSource="{Binding person}"> <DataTemplate> <Grid> <Grid.RowDefinitions> <RowDefinition Height="{Binding Height}" /> <RowDefinition Height="Auto"/> </Grid.RowDefinitions>
で、下の様にResourcesを設定してあげるとバインドできるようになる。
MainWindow.xaml
<Window.Resources> <vm:WindowViewModel x:Key="viewmodels" /> </Window.Resources> <Grid> <ListBox Grid.Column="2" ItemsSource="{Binding person}"> <DataTemplate> <Grid> <Grid.RowDefinitions> <RowDefinition Height="{Binding Height, Source={StaticResource viewmodels}}" /> <RowDefinition Height="Auto"/> </Grid.RowDefinitions>
ハッシュとシンボル
railsチュートリアルをやってます。
第4章まで進めてて、4.3.3ハッシュとシンボル が気になった。
>> h1 = { :name => "Michael Hartl", :email => "michael@example.com" } => {:name=>"Michael Hartl", :email=>"michael@example.com"} >> h2 = { name: "Michael Hartl", email: "michael@example.com" } => {:name=>"Michael Hartl", :email=>"michael@example.com"} >> h1 == h2 => true
となるのに
>> h2 = { name: "Michael Hartl", email: "michael@example.com" } => {:name=>"Michael Hartl", :email=>"michael@example.com"} >> h3 = { ”name” => "Michael Hartl", "email" => "michael@example.com" } => {"name"=>"Michael Hartl", "email"=>"michael@example.com"} >> h2 == h3 => false
となる。
ここらへんの動きがなんとなくモヤモヤする。
シンボルに - が使えないから、仕方なく文字列を使うっていうのが主な理由らしいのですが。。
シンボルで無理やり - を使おうとするとこうなるのかな?
無理に-使おうとするとこういう書き方になるらしい。
>> {:"hoge-fuga" => "piyo"}[:"hoge-fuga"] => "piyo"
ruby on rails 初めてみた
会社でscalaを始めることになり、少しずつ勉強を始めてみた。
scalaの進捗を確認していく中で、ruby on railsを勉強してみようということになりまずはそちらの勉強からということになりました。
と、いうことで、railsを始めるにはまずチュートリアルからということでこちらから始めてみた。 railstutorial.jp