Skip to content

Instantly share code, notes, and snippets.

View staciax's full-sized avatar

STACIA staciax

View GitHub Profile
@hansheng0512
hansheng0512 / crypto.ts
Created September 20, 2024 03:14
Encrypt and Decrypt string using Typescript
import * as crypto from 'crypto';
// Secret key generation (should be stored securely and not hardcoded)
const secretKey = crypto.createHash('sha256').update(String('your-secret-key')).digest('base64').substr(0, 32);
function encrypt(text: string): string {
const iv = crypto.randomBytes(16); // Initialization vector
const cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(secretKey), iv);
const encrypted = Buffer.concat([cipher.update(text, 'utf8'), cipher.final()]);
// Return the IV and encrypted data as a combined string
@nrbnlulu
nrbnlulu / msgspec_vs_pydanticv2.py
Created June 18, 2024 08:43
Msgspec vs Pydantic v2
from datetime import datetime
import json
import re
import timeit
from contextlib import contextmanager
from dataclasses import dataclass
from typing import Annotated, Any, Callable, Iterator, TypedDict
from pydantic.annotated_handlers import GetJsonSchemaHandler
@aamiaa
aamiaa / CompleteDiscordQuest.md
Last active April 20, 2025 23:43
Complete Recent Discord Quest

Complete Recent Discord Quest

Note

This does not works in browser for non-video, non-activity quests! For stream/play quests use the desktop app!

Note

When doing stream quests, you need at least 1 other account in the vc!

How to use this script:

  1. Accept a quest under Discover -> Quests
@jbwhit
jbwhit / example-ruff-formatting.ipynb
Last active April 13, 2025 12:31
Steps to use `ruff` in JupyterLab with the `jupyterlab_code_formatter` plugin.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jcrist
jcrist / kv.py
Created September 19, 2022 01:48
An example TCP Key-Value store written using msgspec and asyncio
"""An example key-value store server and client implementation using msgspec
and asyncio.
Requests are serialized using the MessagePack protocol, as implemented by
msgspec. Additionally, all messages are length-prefix framed using a 32 bit
big-endian integer.
Note that this encoding isn't tied to either asyncio or msgspec - this could
just as easily be implemented using sockets and a different serialization
protocol. Length-prefix framing is useful in that respect - it separates the IO
@Soheab
Soheab / wait_for_modal.md
Last active November 18, 2024 20:27
See how to wait for user input using a modal!

Wait for with a Modal

See here an overcomplicated way to wait for input from a user using a modal. Every step is explained using comments.

This is meant to replace Client.wait_for("message") for application commands.

Features

  • Easy way to construct a Modal with one text input field.
  • Easily pass a check from the constructor

Files

@idleberg
idleberg / vscode-macos-context-menu.md
Last active April 10, 2025 03:21
“Open in Visual Studio Code” in macOS context-menu

Open in Visual Studio Code

  • Open Automator
  • Create a new document
  • Select Quick Action
  • Set “Service receives selected” to files or folders in any application
  • Add a Run Shell Script action
    • your default shell should already be selected, otherwise use /bin/zsh for macOS 10.15 (”Catalina”) or later
    • older versions of macOS use /bin/bash
  • if you're using something else, you probably know what to do 😉
@Kavan72
Kavan72 / endpoints.txt
Last active February 27, 2025 12:37
Valorant endpoints
[PlayerFeedback_CheckForSurvey] POST
[PlayerFeedback_SendAnswers] POST
[PatchNotes_GetPatchNotes] GET
[AggStats_Fetch] GET
[AccountXP_GetPlayer] GET https://pd.ap.a.pvp.net/account-xp/v1/players/{user_id}
[Config_FetchConfig] GET https://shared.ap.a.pvp.net/v1/config/ap
@fsjorgeluis
fsjorgeluis / hashAndCompare.ts
Last active January 25, 2025 09:46
Functions to hash and compare password using bcrypt library and typescript
import * as bcrypt from 'bcrypt';
/**
* Hash password using bcrypt library
* @param password String
* @returns string type
*/
export const HashPassword = async (password: string): Promise<string> => {
const salt = await bcrypt.genSalt();
const hash = await bcrypt.hash(password, salt);
@mcroach
mcroach / storing-image-assets-in-repo.md
Last active March 23, 2025 19:53
Using an 'assets' branch to store images in your repo

Storing image assets in your repo and referencing in markdown

Create an assets branch and make the initial commit

git checkout --orphan assets
git reset --hard
cp /path/to/cat.png .
git add .
git commit -m 'Added cat picture'
git push -u origin assets