Skip to content

Instantly share code, notes, and snippets.

View aiya000's full-sized avatar
🐶
Inu

aiya000 aiya000

🐶
Inu
View GitHub Profile
const chars = [
'亜',
'哀',
'挨',
'愛',
'曖',
'悪',
'握',
'圧',
'扱',
#!/bin/bash
negative_state=$(cat <<- END
{
"state": "failure",
"context": "poi",
"description": "hi"
}
END
)
echo "$negative_state"
module.exports = {
trailingComma: 'all',
tabWidth: 2,
semi: false,
singleQuote: true,
printWidth: 100,
}
module.exports = {
root: true,
env: {
browser: true,
node: true,
},
extends: [
'@nuxtjs/eslint-config-typescript',
'@vue/prettier',
'@vue/prettier/@typescript-eslint',
const x: { x: number } | null = { x: 10 }
console.log(x.x) // no errors
const y: { x: number } | null = null
console.log(y.x) // 2531: Object is possibly 'null'.
/**
* The type 'true' means a proof is satisfied.
* The type 'never' means a proof is not satisfied.
*/
// Basic of this idea.
type AWrongProof = { x: number } extends { x: string } ? true : never
// Compile NG
@aiya000
aiya000 / types.ts
Created February 20, 2021 15:08
TypeScriptは`interface Foo { ... }`と`type Foo = { ... }`を区別するっぽい!?
/**
* Proves that A and B is the same types.
*/
export type Equal<A, B> = A extends B ? (B extends A ? true : never) : never
/**
* Makes all fields of A to `<its-type> | null`.
*/
export type Nullable<A extends Record<string, unknown>> = { [K in keyof A]: A[K] | null }
@aiya000
aiya000 / Nullable.ts
Created February 20, 2021 14:55
証明できてる?
/**
* Proves that A and B is the same types.
*/
export type Equal<A, B> = A extends B ? (B extends A ? true : never) : never
/**
* Makes all fields of A to `<its-type> | null`.
*/
export type Nullable<A extends Record<string, unknown>> = { [K in keyof A]: A[K] | null }
@aiya000
aiya000 / auth-user.ts
Last active February 19, 2021 12:40
Getting an access token of VRChat API. and then getting friend list using it. VRChat APIでアクセストークンを使って、フレンドを取得するやつ。
import axios from 'axios'
function isThatArray<T>(x: unknown, p: (a: unknown) => a is T): x is Array<T> {
return Array.isArray(x) && x.every(p)
}
function isString(x: unknown): x is string {
return typeof x === 'string'
}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE FlexibleInstances #-}
newtype Fix f = Fix
{ unFix :: f (Fix f)
}
cata :: Functor f => (f a -> a) -> Fix f -> a
cata f (Fix x) = f $ fmap (cata f) x