Skip to content

Instantly share code, notes, and snippets.

View ogaty's full-sized avatar

Yuji Ogata ogaty

View GitHub Profile
@ogaty
ogaty / Postman-pre-request-script-csrf-token-laravel-sanctum.js
Created May 31, 2024 02:16 — forked from janzikmund/Postman-pre-request-script-csrf-token-laravel-sanctum.js
Postman Pre-Request script to append CSRF token in header for POST requests in Laravel Sanctum authenticated SPA. Requires active environment with {{url}} variable defined for main app domain.
/**
* Postman Pre-Request script to append CSRF token in header for POST requests in Laravel
* Sanctum authenticated SPA. Requires active environment with {{url}} variable defined
* for main app domain.
*
* Postman Interceptor allows appending cookies from browser, but Laravel CSRF middleware
* only validates CSRF in headers or in _token form field, not in cookies. Axios automatically
* appends the CSRF from cookie to headers, but Postman cannot access intercepted cookies
* and use them, so we have to do one pre-request to get the CSRF token, store it
* in environment so it can be reused, and then append it to headers.
@ogaty
ogaty / svg.php
Last active May 24, 2023 01:30
svg
<html>
<head>
</head>
<body>
<form method="POST" enctype="multipart/form-data">
<input type="file" name="svg" id="svg">
<input type="submit">
@ogaty
ogaty / route.csv
Last active July 19, 2023 03:59
make url check test for laravel
admin method url controller name title
admin get /admin/news NewsController admin.news.index admin news
front get /news NewsController admin.news.index front news
@ogaty
ogaty / react.md
Created January 5, 2023 00:52
react vue

基本は

npm create vite@latest

で作れる

<div id="root"></div>

ここにjsxを当て込んでいく

@ogaty
ogaty / nsdate.md
Last active October 27, 2022 05:01
NSdate
                DateTime date = new DateTime(jsonObj.birth_year, jsonObj.birth_month, jsonObj.birth_day, 12, 0, 0);
                DateTime reference = new DateTime(2001, 1, 1, 0, 0, 0);
                NSDate dd = NSDate.FromTimeIntervalSinceReferenceDate(
                    (date - reference).TotalSeconds);
                event_date.DateValue = dd;
 DateTime d = DateTime.Parse(event_date.DateValue.ToString());
@ogaty
ogaty / cocoa.md
Last active October 25, 2022 07:08
mac cocoa c# xamarin

label

nameLabel.StringValue

TextField

event_name.StringValue = jsonObj.name;

popup(combo)

list.RemoveAllItems(); list.AddItems(items);

@ogaty
ogaty / openssl.md
Last active October 20, 2022 09:47
openssl

csr

openssl genrsa -out ca.key 2048
openssl req -new -key astro.ogatism.com.key -out astro.ogatism.com.csr
Country Name (2 letter code) [AU]:JP
State or Province Name (full name) [Some-State]:Kanagawa
Locality Name (eg, city) []:Kawasaki
@ogaty
ogaty / htaccess.md
Created October 20, 2022 00:30
htaccess
# BEGIN Redirect to https
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{ENV:HTTPS} !on
RewriteCond %{HTTP:X-Forwarded-Proto} http
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
# END Redirect to https
@ogaty
ogaty / for.md
Last active July 19, 2023 04:28
色んな言語のfor foreach

JavaScript

// indexのみ
for (index in a) {
  console.log(a[index]);
}

// 中身のみ
for (i of a) {
 console.log(i);
@ogaty
ogaty / luxon.md
Last active July 19, 2023 04:29
javascript datetime luxon

moment.jsよりも分かりやすい

https://moment.github.io/luxon/#/install

<script src="https://cdn.jsdelivr.net/npm/luxon@3.0.4/build/global/luxon.min.js"></script>

初期登録

var DateTime = luxon.DateTime;