Skip to content

Instantly share code, notes, and snippets.

View haandev's full-sized avatar

Hakan Özoğlu haandev

  • İstanbul
  • 22:37 (UTC +03:00)
View GitHub Profile
@haandev
haandev / esbuild-plugin-private-to-symbols.ts
Last active September 27, 2025 11:19
convert private class members to symbols
import type { Plugin } from 'esbuild'
function privateToSymbols(descriptions: boolean = true): Plugin {
return {
name: 'private-to-symbols',
setup(build) {
build.onLoad({ filter: /\.ts$/ }, async (args) => {
if (args.path.includes('node_modules')) return
const source = await readFile(args.path, 'utf8')
@haandev
haandev / post-format-one-line-imports.js
Created May 30, 2025 17:26
Prettier imports to single line
import fs from 'fs'
import { glob } from 'glob'
import path from 'path'
function parseArgs() {
const args = process.argv.slice(2)
const ignorePattern =
args.find((arg) => arg.startsWith('--ignore='))?.split('=')[1] ||
['**/node_modules/**', '**/dist/**', '**/build/**', '**/coverage/**']
const globPattern =
import { useEffect, useRef, useState } from 'react'
type StateSetFunction<T> = (prev: T) => Partial<T>
type Initializer<T> = (
set: (fn: StateSetFunction<T>) => void,
get: () => T,
) => T
const create = <T extends Record<string, any>>(initializer: Initializer<T>) => {
const setter = (fn: StateSetFunction<T>) => {
state = { ...state, ...fn(state) }
import React, { useEffect, useSyncExternalStore } from "react";
// QueryClient class
export class QueryClient {
public queries: Map<string, unknown> = new Map();
setQuery(queryKey: string, config: UseQueryConfig) {
this.queries.set(queryKey, config);
}
public queryData = new Map<string, unknown>();
@haandev
haandev / httpsExpressApp.js
Created September 20, 2021 16:51 — forked from ryanhanwu/httpsExpressApp.js
Express JS HTTP + HTTPs server (including auto redirect)
var express = require('express'),
routes = require('./routes'),
upload = require('./routes/upload'),
http = require('http'),
https = require('https'),
fs = require('fs'),
path = require('path'),
httpApp = express(),
app = express(),
certPath = "cert";