技術情報

Deleting a Git branch locally and remotely

You may have accidentally created a local branch or a remote branch on your local machine or remote host, respectively. In other cases, you may simply want to delete the local or remote branch.

Delete the local branch

To delete a local Git branch, you need to specify the –delete or -d flag in your git branch command (the latter is just an alias for –delete).

$ git branch --delete local-branch

Or you can also use like this

$ git branch -d local-branch

As for force deleting , you can use like this

$ git branch -D my-local-branch-name

Delete a Remote Branch

You can delete a remote branch using as below.

$git push origin --delete remote-branch

Now, once the remote branch is removed from the remote host, you need to make sure that the other machines are also in sync. The branch has been removed from both the local machine and the remote host, but other machines may still have the old tracking branch. This can be listed by running git branch -a.

To ensure that all machines are in-sync, you need to run

$git fetch --all --prune

Yuuma



知っておいていただきたいこと – 4

今回も、Laravelの知っておいた方がいいとおもったことをいくつか紹介します。

Laravel Tip

ここでは、クエリを少し読みやすくするための小さな工夫を紹介します。あるオブジェクトに「属している」レコードを問い合わせる際には、 ‘whereBelongsTo’ メソッドを使用します。

$article = Article::where('user_id', $user->id)->paginate(10);

//After

$article = Article::whereBelongsTo($user)->paginate(10);

ということで、今回はこれで終わります。

金曜担当 – Ami



aws ec2環境でphpアップロードファイルのサイズ上限を変更する

今回はaws ec2環境でphpアップロードファイルのサイズ上限を変更する方法を
シェアしたいと思います。

続きを読む

Encrypt and Decrypt files with GPG in linux

Today, I would like to share about encrypting and decrypting files with GPG in linux. Let’s take a look.

GPG, known as GNU Privacy Guard (GnuPG), is an open-source command-line tool to encrypt things like files, emails, messages and so on.

Installation

GPG usually pre-installed with most of the Linux Distributions. But just in case, you can install by the following command in terminal.

sudo apt install gnupg

Usage

Generate keys

To encrypt files, you need to generate a GPG key on the system firstly.

gpg –full-generate-key

If the options to select are asked, you can read and use default values by pressing Enter.

But you will need to fill name and email.

Checking GPG keys

You can also check your key lists as follows.

Encrypting a file

Firstly, let’s create a sample text file with some text.

And let’s encrypt a file by the following command.

The recipient argument is the email you wrote when creating key.

The above command output the encrypted file with .gpg extension. You can delete original file after encryption.

And we can see the contents of the encrypted file as follow.

Decrypting a file

You can decrypt an encrypted gpg file by the following command.

This command outputs a decrypted file named decrypted_test.txt. Now you can see correct text contents of the file.

So this is all for now and for more details, I recommend to read here.

Hope you enjoy that.

By Asahi



知っておいていただきたいこと – 3

今回も、Laravelの知っておいた方がいいとおもったことをいくつか紹介します。

Tip # Laravel #exclude

入力を受け付けると、そのデータを使ってモデルを作りたいと思うことがよくあります。
例えば、登録フォームはUserモデルを作成するために使われるでしょう。しかし、すべてのフィールドを検証する必要がある一方で、モデルを作成するためにすべてのフィールドを必要としないかもしれません。このような場合、「exclude」ルールを使用します。

class StoreRequest extends FormRequest
{
  public function rules(){
      return [
         'name'                    => 'required|string',
         'email_address'           => 'required|string|email',
         'terms_and_conditions'    => 'required|accepted|exclude',    
       ];
  }
}

exclude’ ルールを使用すると、Laravel は ‘terms_and_conditions’ フィールドが全てのバリデーションルールをパスすることを保証しますが、 ‘validate’ または ‘validated’ メソッドによって返されるわけではありません。これにより、DBに’terms_and_conditions’のカラムがないことを気にせずに、簡単にモデルを作ることができます。

class RegistrationController extends Controller 
{
     public function store(StoreRequest $request)
     {
        $playload = $request->validate(); //名とメールだけ
        $user = User::create($playload);
        Auth::login($user);
        return redirect()->route('dashboard');
     }
}

ということで、今回はこれで終わります。

金曜担当 – Ami




アプリ関連ニュース

お問い合わせはこちら

お問い合わせ・ご相談はお電話、またはお問い合わせフォームよりお受け付けいたしております。

tel. 06-6454-8833(平日 10:00~17:00)

お問い合わせフォーム