未分類
- 2023年02月15日
- 未分類
BingにAIが搭載されました
tanaka at 2023年02月15日 10:00:00
- 2023年02月01日
- 未分類
PICO4を触ってみました
TikTokで有名なByteDance社の子会社のPICOが
昨年10月に発売したVRヘッドセットのPICO4を買ったので触ってみました。
Meta Quest2 と同じようにPCが要らない単体で使える
両目4K解像度とカラーパススルーが売りのヘッドセットです。
無線か有線どちらかでPCに接続することでPCVRヘッドセットとしても
使うことができます。
単体での使用時は、私が以前持っていたHTC Viveと
比べてとても画質が良く感じました。
次に無線でPCに接続して使用した場合は映像をストリーミングしていることが
分かるくらいには画質の低下は感じられましたが、
コントローラーの遅延は特に感じませんでした。
Meta Quest 2を持っていないので比較することはできませんが、
単体で利用するには良い選択肢だと感じました。
水曜担当:Tanaka
tanaka at 2023年02月01日 10:00:00
- 2022年12月05日
- 未分類
Alternatives for Heroku
Heroku is a famous PAAS (Platform as a Service) that makes it very easy for developers to deploy applications in different languages and frameworks.
Heroku is very popular due to its simplicity and ease of use. In minutes, you can go from an app on your computer to an app deployed using a URL that you send to friends and clients. Heroku had a free tier that can be used for learning purposes and non-commercial applications such as personal projects.
However Heroku said
The reason for that decision was due to fraud and abuse of Heroku’s free product plan.
Here are some alternatives that offer a free plan.
You can also check this list of PAAS with free tiers: https://github.com/ripienaar/free-for-dev#paas
Yuuma
yuuma at 2022年12月05日 10:00:00
5 PHP Application Monitoring Tools
Today, I would like to share about 5 PHP application monitoring tools. Let’s take a look.
Sentry.io
Sentry.io was originally for python frameworks. Sentry enables end-to-end observability and collects complete stack traces and offers support for PHP, Laravel and Symfony.
PHP Server Monitor
PHP server monitor is an open-source tool to monitor the performance of PHP servers and websites. It allows for easy cronjob monitoring, email, SMS and Pushover notifications, logs collection and more.
Logtail
Logtail is as structured log management platform based on ClickHouse. It can collect and monitor data in real-time from any PHP application.
New Relic
New Relic monitor and helps with identifying and troubleshooting performance issues. It tracks key transactions, monitors critical metrics, and visualizes everything in dashboards. New Relic’s PHP monitoring promises improved performance, query optimization, and instant observability.
Atatus
Atatus is a tool supporting PHP performance monitoring and error handling. Using the Atatus, we can improve business metrics and optimize the performance of the application. It discovers the longest transactions, the slowest database queries, the slowest network calls and exceptions.
This is all for now. Hope you enjoy that.
By Asahi
waithaw at 2022年09月06日 10:00:00
- 2022年04月07日
- 未分類
Laravelでよりクリーンなコードを書く
行を正しく分割する
行は適当に分けないが、長くしすぎないようにする。配列を[]で開き、値をインデントするとうまくいく傾向がある。長い関数のパラメータ値も同様です。他にも、連鎖した呼び出しやクロージャも行を分割するのに適しています。
Bad
// No line split
return $this->request->session()->get($this->config->get('analytics.campaign_session_key'));
// Meaningless line split
return $this->request
->session()->get($this->config->get('analytics.campaign_session_key'));
// Good
return $this->request->session()->get(
$this->config->get('analytics.campaign_session_key')
);
// Closure
new EventCollection($this->events->map(function (Event $event) {
return new Entries\Event($event->code, $event->pivot->data);
}));
// Array
$this->validate($request, [
'code' => 'string|required',
'name' => 'string|required',
]);
ルックアップテーブルを使用する
else if ]ステートメントを繰り返し書く代わりに、配列を使って、持っているキーに基づいて、欲しい値を探します。コードはよりすっきりして読みやすくなり、何か問題が発生したときには理解しやすい例外を見ることができます。中途半端なエッジケースはありません。
// Bad
if ($order->product->option->type === 'pdf') {
$type = 'book';
} else if ($order->product->option->type === 'epub') {
$type = 'book';
} else if ($order->product->option->type === 'license') {
$type = 'license';
} else if ($order->product->option->type === 'artwork') {
$type = 'creative';
} else if $order->product->option->type === 'song') {
$type = 'creative';
} else if ($order->product->option->type === 'physical') {
$type = 'physical';
}
if ($type === 'book') {
$downloadable = true;
} else if ($type === 'license') {
$downloadable = true;
} else if $type === 'creative') {
$downloadable = true;
} else if ($type === 'physical') {
$downloadable = false;
}
// Good
$type = [
'pdf' => 'book',
'epub' => 'book',
'license' => 'license',
'artwork' => 'creative',
'song' => 'creative',
'physical' => 'physical',
][$order->product->option->type];
$downloadable = [
'book' => true,
'license' => true,
'creative' => true,
'physical' => false,
][$type];
可読性を向上させる場合は変数を作成する
複雑な呼び出しから値が得られることもあり、そのような場合は変数を作成すると可読性が向上し、コメントの必要性がなくなります。文脈が重要であり、最終的な目標は読みやすさであることを忘れないでください。
// Bad
Visit::create([
'url' => $visit->url,
'referer' => $visit->referer,
'user_id' => $visit->userId,
'ip' => $visit->ip,
'timestamp' => $visit->timestamp,
])->conversion_goals()->attach($conversionData);
// Good
$visit = Visit::create([
'url' => $visit->url,
'referer' => $visit->referer,
'user_id' => $visit->userId,
'ip' => $visit->ip,
'timestamp' => $visit->timestamp,
]);
$visit->conversion_goals()->attach($conversionData);
アクションクラスの作成
一つのアクションのためにクラスを作ることで、物事がきれいになることもあります。モデルは、それに関連するビジネスロジックをカプセル化する必要がありますが、あまり大きくなりすぎるのもよくありません。
// Bad
public function createInvoice(): Invoice
{
if ($this->invoice()->exists()) {
throw new OrderAlreadyHasAnInvoice('Order already has an invoice.');
}
return DB::transaction(function () use ($order) {
$invoice = $order->invoice()->create();
$order->pushStatus(new AwaitingShipping);
return $invoice;
});
}
// Good
// Order model
public function createInvoice(): Invoice {
if ($this->invoice()->exists()) {
throw new OrderAlreadyHasAnInvoice('Order already has an invoice.');
}
return app(CreateInvoiceForOrder::class)($this);
}
// Action class
class CreatelnvoiceForOrder
{
public function _invoke(Order $order): Invoice
{
return DB::transaction(function () use ($order) {
$invoice = $order->invoice()->create();
$order->pushStatus(new AwaitingShipping);
return $invoice;
});
}
}
イベント利用
コントローラからイベントへのロジックのオフロードを検討します。例えば、モデルを作成するときです。この利点は、モデルの作成がどこでも(コントローラ、ジョブ、…)同じように動作し、コントローラはDBスキーマの詳細について心配する必要がなくなるということです。
// Bad
// Only works in this place & concerns it with
// details that the model should care about.
if (! isset($data['name'])) {
$data['name'] = $data['code'];
}
$conversion = Conversion::create($data);
// Good
$conversion = Conversion::create($data);
// Model
class ConversionGoal extends Model
{
public static function booted()
{
static::creating(function (self $model) {
$model->name ??= $model->code;
});
}
}
来週は、クリーンコードに関するより多くのヒントを紹介する予定です。
By Tsuki
tsuki at 2022年04月07日 10:51:15