Skip to content

Instantly share code, notes, and snippets.

View ognis1205's full-sized avatar
πŸˆβ€β¬›

Shingo OKAWA ognis1205

πŸˆβ€β¬›
View GitHub Profile
fn generic<T>(x: T) where T: 'static { ... }
// Accepts any type T as its argument which satisfies 'static lifetime trait bounds.
fn generic<T: 'static>(v: T) {}
// 1. No references.
struct NoReferences(String);
// 2. Includes a 'static lifetime reference.
struct IncludesStaticRef(&'static str);
// 3. Inclues a lifetime reference named 'a
@ognis1205
ognis1205 / OAuth2Api.java
Created December 12, 2024 14:33
OAuth2 API created by OpenAPI Generator
/*
* Unity Control API
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
@ognis1205
ognis1205 / openapi.ts
Last active December 15, 2024 08:40
openapi-typescript utility module.
import axios from 'axios';
import type { AxiosInstance } from 'axios';
/**
* Represents the type of HTTP methods.
*/
export type HttpMethod =
| 'get'
| 'put'
| 'post'
@ognis1205
ognis1205 / example.ts
Last active December 15, 2024 08:43
openapi-typescript utility usage example.
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { CLIENT } from '../context/catalog';
import { route as _route, isError, assertNever } from '../utils/openapi';
import type {
paths as CatalogApi,
components as CatalogComponent,
} from '../types/api/catalog.gen';
import type {
paths as ControlApi,
components as ControlComponent,
@ognis1205
ognis1205 / OktaSignInWidget.tsx
Last active January 28, 2025 12:54
OktaSignInWidget.tsx
import { useEffect } from 'react';
import OktaSignIn from '@okta/okta-signin-widget';
interface OktaSignInWidgetProps {
onSuccess: (tokens: any) => void;
onError: (error: Error) => void;
}
export default function OktaSignInWidget({
onSuccess,