2014年11月18日火曜日

Laravel4 Migrations Tips

As we read programming books or homepages, we sometimes encounter the confusion because of the different explanations from authers to authers.

Laravel's Migrations is in that case. Let's me explain the best use of migrate:make command.

First, here are three lines for migrate:make command. You will see which is the best way to write seeing the results.

Laravel4 Formal Documentation

1. $ php artisan migrate:make create_users

2. $ php artisan migrate:make create_users --table=users
2-2. $ php artisan migrate:make create_users --table="users" //Double quotations are not required. This line shoud be like upper one.

Sorry, I made a mistake. 3-2 is wrong. 3 is a true line I intended. Originally, I wrote this blog in august.
3. $ php artisan migrate:make create_users --create=users
3-2. $ php artisan migrate:make create_users --create --table=users

The results for each command are like below.

The result for the first command line.
------------------------------
<?php
use Illuminate\Database\Migrations\Migration;
class CreateUsers extends Migration {
/**
* Run the migrations.
*
* @return void
*/
 public function up()
 {
  //
 }
/**
* Reverse the migrations.
*
* @return void
*/
 public function down()
 {
  //
 }
}
-------------------------------


The result for the second command line.
-------------------------------
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsers extends Migration {
/**
* Run the migrations.
*
* @return void
*/
 public function up()
 {
  Schema::table('users', function(Blueprint $table) {
  });
 }
/**
* Run the migrations.
*
* @return void
*/
 public function down()
 {
  Schema::table('users', function(Blueprint $table) {
  });
 }
}
-----------------------------


The result for the last command line.
-----------------------------
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsers extends Migration {
/**
* Run the migrations.
*
* @return void
*/
 public function up()
 {
  Schema::create('users', function(Blueprint $table) {
   $table->increments('id');
   $table->timestamps();
  });
 }
/**
* Reverse the migrations.
*
* @return void
*/
 public function down()
 {
  Schema::drop('users');
 }
}
------------------------------


The last line is the best for us. The migrate:make command make more job for us with the last. It's result makes us saving the coding time with less errors.

2014年11月1日土曜日

画像の歪みを簡単に補正できるGIMPはフリーソフトです

パンフレットなどに使う写真は、建物や機器が菱形(昔、高校の先生がひしがたなどと読むな、りょうけいと読めと言っていた)や台形に写っていると見栄えがよくないという経験を多くの人がしていると思う。

火曜日の朝、お友達の会社から11月5日からの展示会用パンフレットを作ってくれと電話があった。素人写真なので歪みや傾きがひどい。何かいいソフトはないかとググッて、いくつか試した。その中で、GIMPが圧倒的にすばらしかった。

GIMPは昔使ったことがあったが、当時、PhotoShopLE3.5を使っていたので、GIMPを継続して利用することはなかった。

GIMPには画像の歪みを修正する機は以前からあったようだが、現在のGIMPの性能はまったく驚くべきもので、GUIで簡単にあっという間に歪みが修正できる。必要に応じて画像の四隅のどこかを引っ張るだけで四隅が90度の画像ができる。しかも、品質のいいきれいな画像だ。オープンソースソフトウェアの世界はまったくもって賞賛され尊敬されるに値するものだ。

最新のGIMPは起動すると、独立した3つのウィンドウが表示される。真ん中のウィンドウに画像を読み込む。左のウィンドウは各種のツール類がアイコンになって並んでいる。その中の補正用のアイコンをクリックして、中央に表示された画像の四隅を適当に引っ張る。これだけのことです。画像の歪みの補正を考えている人は、絶対にGIMPがお勧めです。

最後に一つ、インストールに関して。GIMPのインストールの前にGTK+をインストールすることと書いているページがあるけど、現在はGIMPをダウンロードしてそれをインストールすればGTK+も自動的にインストールされる。