View discord-ws.ts
import { getPlatformInfo } from '../utils/platform'; | |
import { noop } from '../utils/util'; | |
import * as http from '../lib/http'; | |
import { GATEWAY_VERSION } from '../constants/endpoints'; | |
import { GATEWAY } from '../constants/api'; | |
import { GatewayOP, ConnectionStatus } from '../constants/gateway'; | |
import { Inflate } from '@intrnl/pako-esm/inflate'; | |
import { Z_SYNC_FLUSH } from '@intrnl/pako-esm/constants'; |
View lazy-promise.js
export function createLazyPromise (executor) { | |
let promise; | |
function ensure () { | |
return promise || (promise = new Promise(executor)); | |
} | |
return { | |
then (onfulfilled, onrejected) { | |
return ensure().then(onfulfilled, onrejected); |
View sleep.ts
function sleep (ms: number): Promise<void> { | |
return new Promise((resolve) => setTimeout(resolve, ms)); | |
} |
View promise-queue.ts
// class Queue<V = any> | |
// function createDeferred<V> (): Deferred<V> | |
// function sleep (ms: number): Promise<void> | |
export class PromiseQueue { | |
queue = new Queue<Task<any>>(); | |
options: PromiseQueueOptions; | |
ongoing = 0; |
View deferred.ts
export function createDeferred<V> (): Deferred<V> { | |
let deferred: Deferred<V> = {} as any; | |
deferred.promise = new Promise((resolve, reject) => ( | |
Object.assign(deferred, { resolve, reject }) | |
)); | |
return deferred; | |
} |
View queue.ts
export class Queue<V = any> { | |
head?: Node<V>; | |
tail?: Node<V>; | |
size!: number; | |
constructor () { | |
this.clear(); | |
} |
View handler.js
import * as ed from './noble-ed25519'; | |
let encoder = new TextEncoder(); | |
let commands = new Map(); | |
export function define (name, handler) { | |
commands.set(name, handler); | |
} |
View google-forms-get-url-with-filled-answer.js
// A teacher told us to submit the same form multiple times as sort of memory strengthening. | |
// I don't like that though, so here's a script that creates a Forms URL that contains the answers I've already filled. | |
location.origin + location.pathname + '?' + | |
Array.from(document.querySelectorAll('input[name^="entry."]')) | |
.filter((el) => el.value) | |
.map((el) => `${el.name}=${encodeURIComponent(el.value)}`) | |
.join('&'); |
View use-reactive.jsx
import { render } from 'preact'; | |
import { useRef, useState } from 'preact/hooks'; | |
function useReactive (initialState) { | |
let [, forceUpdate] = useState({}); | |
let reactive = useRef(null); | |
if (!reactive.current) { | |
reactive.current = new Proxy(initialState, { |
View 0001-fix-indent.patch
From 13c2054ae99cf4c1587d9c6f2058d0ae18db3cc3 Mon Sep 17 00:00:00 2001 | |
From: intrnl <intrnl28+git@gmail.com> | |
Date: Wed, 21 Oct 2020 17:08:08 +0700 | |
Subject: [PATCH 1/2] fix indent | |
--- | |
PKGBUILD | 38 +++++++++++++++++++------------------- | |
1 file changed, 19 insertions(+), 19 deletions(-) | |
diff --git a/PKGBUILD b/PKGBUILD |
NewerOlder