Skip to content

Instantly share code, notes, and snippets.

@musou1500
musou1500 / shorts2vid.js
Created August 10, 2023 11:47
bookmarklets
javascript:(()=>{const m=/^https:\/\/(www\.)?youtube\.com\/shorts\/([a-zA-Z0-9-_]+)$/.exec(location.href);if(m==null){alert("invoke it on shorts page");}else{location.href=`https://youtube.com/watch?v=${m[2]}`;}})();
//vscodeはコードをコピーしたとき、シンタックスハイライトされたhtmlをクリップボードに書き込む
// それを利用すると簡単にシンタックスハイライトされたhtmlを入手できる
(async () => {
const item = (await navigator.clipboard.read()).find(item => item.types.includes('text/html'));
item&&console.log(await (await item.getType('text/html')).text());
})();
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
.list {
display: flex;
width: 320px;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
unsigned char base64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
char *b64_encode(unsigned char *s, int len) {
int bit_len = len * 8;
int dest_len = bit_len / 6 + (bit_len % 6 != 0);
const formGroup = new FormGroup({
username: new FormControl([
Validators.minLength({
len: 1,
message: "user name must longer than or equal to 1",
}),
]),
});
@musou1500
musou1500 / form-library.ts
Last active January 17, 2022 14:06
design of type-safe form library
import React from "react";
// lib.ts
type FieldValue<L, R> = { isValid: false; value: L; } | { isValid: true; value: R };
type FieldApi<L, R> = {
setValue: (value: FieldValue<L, R>) => void;
getValue: () => FieldValue<L, R>;
};
type FComponent<L, R> = React.VFC<{ field: FieldApi<L, R> }>;
type FItem<K extends string, L, R> = readonly [K, FComponent<L, R>];
// お試し珊瑚宮心海(lv80)
// 武器: 不滅の月華 lv80
// HP:30711
// 天賦lv: すべて8
// 攻撃力:1271
// ダメージバフ:83.2+15
// 与える治療効果:70.9
// 通常攻撃1段目:1399
// 通常攻撃1段目(元素爆発中):6053
// 敵: lv80ヒルチャール
@musou1500
musou1500 / main.ts
Created July 3, 2021 11:13
Example nestjs-graphql-redis-subscriptions
import { Inject, ValidationPipe } from "@nestjs/common";
import { NestFactory } from "@nestjs/core";
import { Module } from "@nestjs/common";
import {
IOModule,
RedisPubSub,
REDIS_PUB_SUB_TOKEN,
} from "nestjs-graphql-redis-subscriptions";
class AppService {
@musou1500
musou1500 / swirl.ts
Created May 17, 2021 15:51
Genshin Swirl Damage Calculator
export const debuffResistance = (orig: number, debuff: number) => {
if (orig < debuff) {
return -(debuff - orig) / 2;
} else {
return orig - debuff;
}
};
export const swirl = (
char: {
/**
* domain module
* UserAggregate
* - (Aggregate Root) User
* - (Aggregate Root) UserQuota
*/
export class User {
#organizationId: number;
#name: string;