Skip to content

Instantly share code, notes, and snippets.

@Goganoid
Goganoid / log.ts
Created November 5, 2024 06:32
Nestjs logger decorator
import { Logger, LoggerService } from '@nestjs/common';
export type Transform = (data: any) => any;
export interface Options {
logger?: LoggerService;
prefix?: string;
transform?: Transform;
timestamp?: boolean;
}
@Goganoid
Goganoid / useAutoSubmit.ts
Created September 4, 2024 17:04
react-hook-form autosubmit
import { debounce } from 'lodash';
import { useCallback, useEffect, useState } from 'react';
import { type UseFormWatch, type FieldValues, type UseFormTrigger, type Path } from 'react-hook-form';
interface AutoSubmitProps<T extends FieldValues> {
trigger: UseFormTrigger<T>;
watch: UseFormWatch<T>;
excludeFields?: Path<T>[];
onSubmit: () => void;
onValidationFailed?: () => void;
@Goganoid
Goganoid / typescript-react-snippets.code-snippets
Created August 30, 2024 08:25
Useful React snippets for VS code
{
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
"Modular react arrow function component": {
"prefix": "mtsrafce",
"scope": "typescript,typescriptreact,javascript,javascriptreact",
"body": [
@Goganoid
Goganoid / main.rs
Last active October 5, 2021 06:01
Doom on Zephyrus G14 Anime Matrix
use std::error::Error;
use captrs::*;
use std::time::{Duration, Instant};
use std::thread::sleep;
use std::sync::mpsc::{Sender, Receiver};
use std::sync::mpsc;
// clone https://gitlab.com/asus-linux/asusctl into this project, because some crate are not present on crates.io
use rog_anime::{AnimeDataBuffer, {AnimeImage, Vec2}, ANIME_DATA_LEN, Pixel};
use rog_dbus::RogDbusClient;