Skip to content

Instantly share code, notes, and snippets.

View viztea's full-sized avatar
😴
sleeping

viztea

😴
sleeping
View GitHub Profile
@viztea
viztea / permissions.ts
Created August 29, 2025 03:59
twilight permissions calculator in typescript
const ALL_PERMISSIONS_FIELD = new Permissions(Permissions.All).freeze();
const EMPTY_PERMISSIONS_FIELD = new Permissions().freeze();
/**
* Permissions associated with a guild only at the root level (i.e., not channel related).
*/
const PERMS_ROOT_ONLY =
0n |
Permissions.Flags.Administrator |
@viztea
viztea / schema.ts
Created June 20, 2023 00:20
@protobuf-ts/runtime types to @effect/schema
import { EnumInfo, FieldInfo, IMessageType, RepeatType, ScalarType } from "@protobuf-ts/runtime";
import * as PR from "@effect/schema/ParseResult";
import * as S from "@effect/schema/Schema";
import * as F from "@effect/data/Function";
import * as M from "@effect/match";
export type UnwrapScalarType<V> = V extends ScalarType.DOUBLE
? number
: V extends ScalarType.FLOAT
@viztea
viztea / drizzle-effect-schema.ts
Last active January 28, 2025 20:12
drizzle-zod but for @effect/schema
import {
type AnyColumn,
type Assume,
type DrizzleTypeError,
type Equal,
type Simplify,
type Table,
type WithEnum,
getTableColumns,
} from "drizzle-orm";
@viztea
viztea / keybase.md
Last active December 26, 2022 21:11

Keybase proof

I hereby claim:

  • I am melike2d on github.
  • I am melike2d (https://keybase.io/melike2d) on keybase.
  • I have a public key ASD3DXD7We-nhwBAJvtUcIVyhsdxLNHPW3d6kUA1r3bDJgo

To claim this, I am signing this object:

@viztea
viztea / redis_list.ts
Created July 15, 2022 22:38
redis list in typescript
import type { Redis } from "ioredis";
import * as crypto from "node:crypto";
export class RedisList {
readonly key: string;
#redis: Redis;
/**
@viztea
viztea / JsonType.kt
Last active March 21, 2022 23:08
Redis JSON with Jedis and Kxser
package redis.clients.jedis.kson
enum class JsonType {
NULL,
BOOLEAN,
INTEGER,
NUMBER,
STRING,
OBJECT,
ARRAY;
@viztea
viztea / Class.ts
Created January 30, 2022 21:27
java data input
import { TextDecoder } from "util";
export class Data {
private static readonly UTF = new TextDecoder("utf8");
private readonly buf: Uint8Array;
#pos = 0;
constructor (data: Uint8Array | string) {
sealed class Ansi {
val name: String get() = this::class.simpleName!!
abstract fun toString(str: String): String
}
class AnsiStyle(val a: Int, val b: Int) : Ansi() {
companion object {
val Bold = AnsiStyle(1, 21)
@viztea
viztea / Consumer.kt
Created January 5, 2022 18:05
A suspending java Predicate and Consumer interface
fun interface Consumer<T> {
/**
* Performs this operation on this given argument.
*
* @param t
* The input argument
*/
suspend fun accept(t: T)
}
@viztea
viztea / amqp.ts
Last active January 28, 2025 20:13
amqp utilities
import { decode, encode } from "@msgpack/msgpack";
import { Channel, connect, Connection, ConsumeMessage, Options } from "amqplib";
export interface AmqpResponseOptions {
ack: () => void;
nack: (allUpTo?: boolean, requeue?: boolean) => void;
reject: (requeue?: boolean) => void;
reply: (data: any) => void;
}