Skip to content

Instantly share code, notes, and snippets.

View ikasoba's full-sized avatar
貴様ッ!見ているなッ!

ikasoba ikasoba

貴様ッ!見ているなッ!
View GitHub Profile
@ikasoba
ikasoba / index.csv
Last active August 10, 2023 09:52
みすてむマイクラサーバーの座標一覧
名前 座標 場所
メサ 37 ~ -271 生活
トラップタワー 118 ~ 308 資源
森(オークと白樺) 433 ~ 244 生活
古代都市(メサの地下) 714 ~ 1455 資源
@ikasoba
ikasoba / Result.ts
Created August 2, 2023 04:36
result型作ってみた
export type Result<T, E> = ResultImpl<T, never> | ResultImpl<never, E>;
export const Result = class {
static ok(value: void): Result<void, never>;
static ok<T>(value: T): Result<T, never>;
static ok<T>(value: T): Result<T, never> {
return new ResultImpl(true, value as {}) as Result<T, never>;
}
static err(value: void): Result<never, void>;
static err<E>(value: E): Result<never, E>;
@ikasoba
ikasoba / logical.ts
Created June 25, 2023 05:21
型レベルの論理なんちゃら
type And<A extends boolean, B extends boolean> = (A | B) extends true ? true : false;
type Or<A extends boolean, B extends boolean> = true extends (A | B) ? true : false;
type Not<A extends boolean> = A extends false ? true : false;
type Xor<A extends boolean, B extends boolean> = boolean extends (A | B) ? true : false;
@ikasoba
ikasoba / jbon.js
Created March 25, 2023 17:31
The one that encodes json to binary
const BinaryTypes = {
EOO: 0,
Null: 1,
NumberF64: 2,
NumberF32: 3,
NumberI32: 4,
NumberU32: 5,
BoolTrue: 6,
BoolFalse: 7,
String: 8,
cmp_version_le(){ \
v1=($(echo -n $1 | xargs -d.)) \
; v2=($(echo -n $2 | xargs -d.)) \
; if [ ${#v1[*]} -lt ${#v2[*]} ]; then \
t=$v1 \
; v1=$v2 \
; v2=$t \
; fi \
; for i in ${!v1[*]}; do \
if [ ${#v2[$(($i + 1))]} = 0 ]; then \
@ikasoba
ikasoba / calculator.ts
Created October 27, 2022 14:29
calculator.ts
type Pattern<T> = (i: number, s: string) => null | [number, T]
interface TokenBase {
type: string
}
interface NumberToken extends TokenBase {
type: "number",
value: number
}
@ikasoba
ikasoba / createEnum.ts
Created July 12, 2022 09:10
create enum like object from string[]
const createEnum = <T extends string|number>(a:readonly T[]|T[]): {[K in T]: K} => Object.fromEntries<T>(a.map(x => [x,x])) as any;
@ikasoba
ikasoba / hulu_pictureinpicture.raw
Last active July 9, 2022 04:56
Huluでピクチャインピクチャ
javascript:(()%3D%3E%7Bconst%20p%3Ddocument.querySelector(%22video%5Bid*%3Dvjs_video%5D%22)%3Bp.disablePictureInPicture%3Dfalse%3Bp.requestPictureInPicture()%7D)()
@ikasoba
ikasoba / baseN.js
Created June 29, 2022 10:04
任意進数のエンコード、デコード
class BaseN {
table = undefined
/** @type {bigint} */
n = undefined
constructor(chars){
this.table = new Map([...Object.entries(chars).map(([k,v])=>[v,BigInt(k)]),...Object.entries(chars).map(([k,v])=>[BigInt(k),v])])
this.n = BigInt(chars.length)
}
/** @param {arrayBuffer} buf */
enc(buf){
function isBase64(value){
if (value == "")return false;
for (let i = 0; i<value.length; ){
const x = value.slice(i,i+=4);
if (i==value.length-1 && !x.match(/^[a-zA-Z0-9]+={0,4}$/))return false;
if (i<value.length-1 && !x.match(/^[a-zA-Z0-9]+$/))return false;
if (x.length != 4)return false;
}
return true
}