Skip to content

Instantly share code, notes, and snippets.

View ogaty's full-sized avatar

Yuji Ogata ogaty

View GitHub Profile
@ogaty
ogaty / docker.md
Last active October 20, 2022 00:31
m1macでdocker

いくつか方法はあるけど、platform: linux/x86_64をつけるのが一番簡単

mysql:
    image: mysql:5.7
    platform: linux/x86_64
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: mydb
      MYSQL_USER: myuser
 MYSQL_PASSWORD: password
@ogaty
ogaty / swapfile.md
Last active September 22, 2022 05:04
swapfile swap
sudo dd if=/dev/zero of=/swapfile bs=1M count=1024
sudo mkswap /swapfile
sudo chmod 0600 /swapfile
sudo swapon /swapfile

fstab

/swapfile swap swap defaults 0 0
@ogaty
ogaty / laravel-tips
Last active September 6, 2022 02:55
laravel tips
# renderしたviewをコントローラへ戻す
```
$a = view('index')->with(['id' => 1])->render();
```
@ogaty
ogaty / laravel-validation.md
Last active July 19, 2023 04:31
laravel validation

バリデーション

Requestクラスでやる

php artisan make:request で authorizeをtrueにするのを忘れずに

    public function rules()
    {
        return [
@ogaty
ogaty / laravel-request.md
Created August 2, 2022 08:16
laravel request

Request

リクエストクラスを取り出す

controller

DIで取り出す場合、引数に

Request $request

を入れる

@ogaty
ogaty / laravel-form.md
Last active October 19, 2022 04:55
laravel form

Form

結論:formファサード使ったほうが良い

composer require laravelcollective/html

基本

{{ Form::open(['url' => '/admin_users/add', 'method' => 'post', 'id' => 'create_form']) }}
@ogaty
ogaty / sd.md
Last active July 19, 2023 04:31
一括置換

これはたしかにsedより楽だ
ripgrepとの組み合わせいいね

rg "fortune2018" -l | xargs sd "ogatism.jp/fortune2018/" "ogatism.jp/post/fortune2018/"
@ogaty
ogaty / grep.md
Last active August 2, 2022 06:27
grep

grep

$ grep "/aaa" *
123.txt:<a href="/aaa">aaa</a>
123.txt:<a href="/aaa">aaa</a>
456.txt:<a href="/aaa">bbb</a>
456.txt:<a href="/aaa">bbb</a>
<?php
$args = array(
// ↓ 特定の「著者」に関連付けられた投稿を表示する場合
'author' => '1,2,3', // 著者IDを指定
'author_name' => 'solecolor', // user_nicknameを指定(名前ではありません)
'author__in' => array( 2 , 6 ), // 著者IDを配列で指定(著者IDを含む記事を絞り込む)
'author__not_in' => array( 2 , 6 ), // 著者IDを配列で指定(著者IDを含まない記事を絞り込む)
// ↓ 特定の「カテゴリー」に関連付けられた投稿を表示する場合
'cat' => 5, // カテゴリーIDを指定
@ogaty
ogaty / wordpress.md
Last active August 2, 2022 08:13
wordpress

functions

ID

get_the_ID();

パーマリンク

get_the_permalink()