技術情報

DataTablesを使用したテーブル生成とサーバーサイド連携(6)

本記事ではDataTablesを使用したテーブル生成方法とサーバーサイド連携方法をシェアします。
今回は前回の記事で説明をおこなったサーバーサイドでのページング処理実装の続きをおこなっていきたいと思います。

続きを読む

Most used 5 Python Image Processing Libraries

Today, I would like to share about most used image processing libraries in python. Let’s take a look.

OpenCV

First released in 2000, OpenCV has become a popular library due to its ease of use and readability. It is mostly used in computer vision tasks such as object detection, face detection, face recognition, image segmentation, etc.

Scikit-Image

Scikit-Image is a python-based image processing library that has some parts written in Cython to achieve good performance. It is a collection of algorithms for image processing such as:

  • Segmentation,
  • Geometric transformations,
  • Color space manipulation,
  • Analysis,
  • Filtering,
  • Morphology,
  • Feature detection

Pillow/PIL

PIL (Python Imaging Library) is an open-source library for image processing in Python. PIL can perform tasks on an image such as reading, rescaling, saving in different image formats. PIL can be used for Image archives, Image processing, Image display.

NumPy

NumPy(Numerical Python) is a open-source Python library for data manipulation and scientific computing. It is used in the domain of linear algebra, Fourier transforms, matrices, and the data science field. NumPy arrays are faster than Python Lists. And an image is essentially an array of pixel values where each pixel is represented by 1 (greyscale) or 3 (RGB) values. So, NumPy can easily perform tasks such as image cropping, masking, or manipulation of pixel values.

Matplotlib

Matplotlib is mostly used for 2D visualizations, but it can also be leveraged for image processing. Matplotlib is effective in altering images for extracting information out of it although it does not support all the file formats.

This is all for now.

Hope you enjoy that.

By Asahi



Fleet IDE

 “Fleet is also a fully functional IDE bringing smart completion, refactorings, navigation, debugging, and everything else that you’re used to having in an IDE – all with a single button click.” – JetBrains

Credit: JetBrain

Fleet takes that approach one step further by making it a single IDE. You no longer have to open another IDE to get the functionality you need for a particular technology. With Fleet, everything is in one app.

Languages include:

  • Java
  • Kotlin
  • Python
  • Go
  • JSON
  • JavaScript
  • Rust
  • TypeScript
  • PHP
  • C++
  • C#
  • HTML
  • Ruby

The fleet is built with collaboration in mind. This makes it easy to collaborate on a project, whether it’s local or remote. It provides the ability to work on the same or different files at the same time, run tests, access the device, and do other things you would expect from a collaboration IDE at the same time.

Fleet has a set of integrated tools to help developers enjoy their work and be more productive.

  • Terminal
  • Git
  • Run & Debug
  • Navigation
  • MultiPlatform
  • Themes
  • Plugins
  • etc.

The fleet’s architecture is designed to support a variety of configurations and workflows. Fleet can only run on your own machine, or you can move some processes to another location like docker , clouds etc.

This IDE also has tons of features and might worth to give it a try.

Yuuma



素晴らしいHTMLの属性について

今回は素晴らしいHTMLの属性についていくつか共有したいと思います。

Contenteditable

Contenteditable属性は、コンテンツが編集可能かどうかを確認するために使用される。

Spellcheck

Spellcheck属性は、編集可能なモードでテキストのスペルや文法をチェックするために使用されます。

Translate

Translate属性は、あるコンテンツを翻訳するかどうかチェックするために使用されます。

Multiple

Multiple 属性は、ユーザーが複数の値を入力/選択できることを指定します。

Accept

accept属性は、ユーザーがファイル入力ダイアログボックスから選択できるファイルの種類をフィルタリングするために指定します。

Poster

poster 属性は、ユーザーが再生ボタンを押すまで表示する画像を指定することができます。

Download

download 属性は、ユーザーがリンクをクリックしたときに画像やビデオがダウンロードされることを指定します。

Inputmode

ブラウザに適切な仮想キーボードを表示できるようにする。

はい!ということで今回は以上になります。

金曜担当:Ami



Laravelのフォームリクエスト: prepareForValidation

今回は、Laravelで検証を行う前にリクエストデータを操作することについて話したいと思います。

フォームのリクエスト例

まず、記事の投稿を保存するためのフォームリクエストの例から見てみましょう。入力に適用されるルールに注目してください。

<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class StoreRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'title' => 'required|max:200',
            'body' => 'required',
            'tags' => 'required|array|max:10',
            'is_published' => 'required|boolean',
            'author_name' => 'required',
        ];
    }
}

ここで、ユーザーが投稿を作成するためにフォームを送信し、次のような入力データを渡したと仮定します。

[
    'title' => 'My  articles post',
    'body' => 'This is the <script>alert('Alert!')</script> articles body.',
    'tags' => 'laravel,code,updates',
    'is_published' => 'true',
    'author_name' => 'Ami',
]

tagsはカンマ区切りの値のリストとしてフロントエンドから送信され、is_publishedの入力は文字列として解釈されます。どちらも、コンテンツの観点からは正しいにもかかわらず、形式が正しくないだけで検証は失敗します。

さらに、titleにタイプミスがあり、本文に悪意のあるコードが含まれているように見えます。技術的にはこれらはバリデーションの問題ではないと言えますが、ユーザーを自分自身から救い、アプリケーションを保護する手助けをすることは可能です。

prepareForValidation

このメソッドはprepareForValidationという適切な名前で、デフォルトのアクションを持ちません。つまり、オーバーライドするためだけに置かれたものです。

protected function prepareForValidation()
{
    // no default action
}

ベースとなる FormRequest クラスは Request クラスを継承しているので、 merge ヘルパーメソッドにアクセスし、必要な入力値だけを更新することができます。また、入力値そのものにクラスのプロパティのようにアクセスすることもできます。

protected function prepareForValidation()
    {
        $this->merge([
            'title' => fix_typos($this->title),
            'body' => filter_malicious_content($this->body),
            'tags' => convert_comma_separated_values_to_array($this->tags),
            'is_published' => (bool) $this->is_published,
        ]);
    }

値はリクエスト自体で更新されるので、バリデーションを行った後にコントローラでどのようにアクセスしても、操作された値が戻ってくることになります。

[
    'title' => 'My blog post',                         // 誤字を修正しました!
    'body' => 'This is the post body.',         //悪質なコンテンツは削除されました!
    'tags' => ['laravel', 'code', 'updates'],   // 配列になりました!
    'is_published' => true,                     // 今はブール値です!
    'author_name' => 'Ami',    // 相変わらずです。

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

By Ami




アプリ関連ニュース

お問い合わせはこちら

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

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

お問い合わせフォーム