Skip to content

Instantly share code, notes, and snippets.

View nakanoasaservice's full-sized avatar
:octocat:

Nakano as a Service nakanoasaservice

:octocat:
View GitHub Profile
@nakanoasaservice
nakanoasaservice / client.tsx
Last active October 11, 2025 15:05
Next.jsでトーストライブラリsonnerをServer Actionsから呼べるようにするラッパー
"use client"
import { usePathname } from "next/navigation"
import { useEffect } from "react"
import { toast } from "sonner"
import * as v from "valibot"
import { TOAST_COOKIE_NAME, ToastCommandSchema } from "./commons"
/**
@nakanoasaservice
nakanoasaservice / wareki.py
Last active February 11, 2021 19:15
Pythonで西暦から和暦への変換
from datetime import date, datetime
WAREKI = [
(date(1989,1,8), date(2019,4,30), "平成"),
(date(2019,5,1), date.max, "令和"),
]
def seireki2wareki(target: str) -> str:
try:
@nakanoasaservice
nakanoasaservice / fastapi_firebase_auth_validation.py
Created June 6, 2020 16:36
FastAPIでFirebaseのトークンを検証する
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
from fastapi import FastAPI, Depends, HTTPException, status
import firebase_admin
from firebase_admin import auth, credentials
app = FastAPI()
cert = credentials.Certificate('path/to/cert.json')
firebase_admin.initialize_app(cert)
@nakanoasaservice
nakanoasaservice / get_firebase_auth_token.py
Created June 6, 2020 16:34
Firebase Authorizationからトークンを発行する
import requests
from pprint import pprint
CONFIG = {
"apiKey": "YOUR API KEY",
"authDomain": "YOURPROJECTID.firebaseapp.com",
"databaseURL": "https://YOURPROJECTID.firebaseio.com",
"projectId": "YOUR PROJECT ID",
"storageBucket": "YOUR PROJECT ID.appspot.com",
"messagingSenderId": "YOUR MESSAGE SENDER ID",
import base64, uuid
base64.urlsafe_b64encode(uuid.uuid1().bytes).rstrip(b'=').decode('ascii')
for f in *.flv; ffmpeg -i $f -codec:v copy -codec:a copy (basename $f .flv).mp4; and rm $f; end
@nakanoasaservice
nakanoasaservice / game.rs
Created February 9, 2019 06:25
IBMのRustコーディングガイドにあった3目並べのサンプル
use std::io;
use rand;
// StringからEnumにした
type Board = Vec<Vec<Mark>>;
enum Turn {
Player,
Bot,
}
@nakanoasaservice
nakanoasaservice / not_use_vue.html
Last active June 18, 2018 10:33
Qiitaのすべての投稿を取ってきて表示する
<!DOCTYPE html>
<html lang="js" dir="ltr">
<head>
<meta charset="utf-8">
<title>Qiita All Contributions</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.css">
</head>
<body>
<section class="section">
<div class="container">