Skip to content

Instantly share code, notes, and snippets.

View teyfix's full-sized avatar

Halil Teyfik teyfix

  • Istanbul, Turkey
View GitHub Profile
@teyfix
teyfix / auth.ts
Last active December 21, 2025 03:14
Better Auth with dynamic baseURL workaround
import { serverConfig } from "@/config/server.config";
import { db } from "@/db/drizzle"; // your drizzle instance
import * as schema from "@/db/schemas/auth.schema";
import { betterAuth, type BetterAuthOptions } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { nextCookies } from "better-auth/next-js";
import { admin } from "better-auth/plugins";
import { v7 } from "uuid";
/**
@teyfix
teyfix / AUTHENTICATION.md
Last active December 16, 2025 20:12
NATS WebSocket Client Example with JWT Authentication

NATS JWT Authentication Setup (NSC)

This document explains how to set up JWT-based authentication for NATS using nsc. It is intentionally deployment-agnostic and focuses purely on concepts, commands, and verification.

All commands are executed using the official natsio/nats-box:0.19.2 Docker image.

@teyfix
teyfix / unfollow.js
Created December 15, 2025 21:03
Unfollow LinkedIn connections
(async function unfolowLinkedin() {
/**
* Sleep for a given duration
*
* @param {number} ms Duration to sleep in ms
* @returns {Promise<void>} A promise that resolves when the sleep is over
*/
const sleep = async (ms) => {
console.info("Sleeping for %dms", ms);
@teyfix
teyfix / client-server.json
Last active June 20, 2025 18:01
matrix-spec
This file has been truncated, but you can view the full file.
{
"components": {
"securitySchemes": {
"accessTokenBearer": {
"description": "The `access_token` returned by a call to `/login` or `/register`, using the\n`Authorization: Bearer` header.\n\nIt can also be the `as_token` of an application service.\n\nThis is the preferred method.",
"scheme": "bearer",
"type": "http"
},
"accessTokenQuery": {
@teyfix
teyfix / IsNationalIdentity.ts
Created April 13, 2025 20:36
Turkish National Identity Validation • TC Kimlik Numarası Doğrulama
/**
* Returns true if the given string is a valid Turkish national identity number.
*
* @remarks
* This implementation uses the algorithm described on the Wikipedia page
* "Turkish Identification Number".
* @param value - The string to check.
* @returns True if the string is a valid Turkish national identity number, false otherwise.
*/
const IsNationalIdentity = (value: string): boolean => {
@teyfix
teyfix / README.md
Last active June 20, 2024 06:44
Copy latest backup preserving folder structure over SSH with rsync
@teyfix
teyfix / Blueprint.ts
Created April 8, 2024 19:47
Blueprint for exposing every possible path of an TypeScript interface
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/ban-types */
import { Document } from 'mongoose';
/**
* Forbidden keys from mongoose Document type except _id.
*/
type _Forbidden = Exclude<keyof Document, '_id'>;
/**
@teyfix
teyfix / jitsi-meet.config.js
Created February 1, 2024 09:42
Jitsi Meet Branding Configuration
const branding = {
// The domain url to apply (will replace the domain in the sharing conference link/embed section)
"inviteDomain": "example-company.org",
// The hex value for the colour used as background
"backgroundColor": "#fff",
// The url for the image used as background
"backgroundImageUrl": "https://example.com/background-img.png",
// The anchor url used when clicking the logo image
"logoClickUrl": "https://example-company.org",
// The url used for the image used as logo
@teyfix
teyfix / tokens.md
Last active January 12, 2024 01:27
JSON Web Token (JWT) authentication Prosody plugin

Original File

JSON Web Token (JWT) authentication Prosody plugin

This plugin implements a Prosody authentication provider that verifies a client connection based on a JWT described in [RFC7519]. It allows use of an external form of authentication with lib-jitsi-meet. Once your user authenticates you need to generate the JWT as described in the RFC and pass it to your client app. Once it connects with a valid token, it is considered authenticated by the jitsi-meet system.

During configuration, you can choose between two JWT validation methods:

@teyfix
teyfix / ticTacToeWinner.ts
Created July 2, 2023 14:52
Check the winner of a Tic Tac Toe game
export class InvalidBoardError extends Error {}
export default function ticTacToeWinner<T extends number | string>(
board: T[][],
): T | "Tie" {
// Check if the board is a valid game board
for (let i = 0; i < board.length; i++) {
if (board.length !== board[i].length) {
throw new InvalidBoardError();
}