Skip to content

Instantly share code, notes, and snippets.

View tkim90's full-sized avatar
💥

Tae Kim tkim90

💥
View GitHub Profile
@tkim90
tkim90 / docker-compose.yml
Last active September 6, 2019 18:35 — forked from onjin/docker-compose.yml
example docker compose for postgresql with db init script
postgres:
image: postgres:9.4
volumes:
# running multiple files
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
- ./schema.sql:/docker-entrypoint-initdb.d/1-schema.sql
- ./data.sql:/docker-entrypoint-initdb.d/2-data.sql
@tkim90
tkim90 / resume.md
Last active October 28, 2019 22:21
Tae Kim - Resume - Software Engineer
@tkim90
tkim90 / http.ts
Last active September 27, 2023 13:00
typescript fetch pattern
// Source: https://www.carlrippon.com/fetch-with-async-await-and-typescript/
// Source: https://eckertalex.dev/blog/typescript-fetch-wrapper
interface HttpResponse<T> extends Response {
parsedBody?: T;
error?: T;
}
export async function http<T>(request: RequestInfo): Promise<HttpResponse<T>> {
const response: HttpResponse<T> = await fetch(request);
@tkim90
tkim90 / Dockerfile
Created May 4, 2021 22:02
Sample Dockerfile for nextjs
# https://nextjs.org/docs/deployment
# Install dependencies only when needed
FROM node:alpine AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
# Rebuild the source code only when needed
@tkim90
tkim90 / useOnClickOutside.js
Created August 10, 2021 07:05
useOnClickOutside Hook
import * as React from "react";
export default function useOnClickOutside(ref, handler) {
React.useEffect(
() => {
const listener = (event) => {
// Do nothing if clicking ref's element or descendent elements
if (!ref.current || ref.current.contains(event.target)) {
return;
}
@tkim90
tkim90 / user.sql
Created October 5, 2024 00:33
Creating SQL user with limited privileges
-- Run these commands to create privileged users.
-- application: can run all except truncate or delete tables
-- dev_user: can only read from tables
-- db_admin: can only create roles or delegate roles to users
-- RDS is on Postgres 10.17
----------------------------
-- Create application user
----------------------------
--- Before running these commands, make sure no tables exist in the database.
@tkim90
tkim90 / breakpoints.html
Created January 18, 2025 00:22
HTML render breakpoints
<div className="fixed bottom-50 right-0 m-1 p-2 bg-red-500 text-white rounded">
<div className="block sm:hidden">xs</div>
<div className="hidden sm:block md:hidden">sm</div>
<div className="hidden md:block lg:hidden">md</div>
<div className="hidden lg:block xl:hidden">lg</div>
<div className="hidden xl:block 2xl:hidden">xl</div>
<div className="hidden 2xl:block">2xl</div>
</div>
@tkim90
tkim90 / try-catch.ts
Created March 31, 2025 08:41 — forked from t3dotgg/try-catch.ts
Theo's preferred way of handling try/catch in TypeScript
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};
@tkim90
tkim90 / .vimrc
Last active April 7, 2025 13:31
zshrc + vimrc
# relative number
set relativenumber
# Global clipboard
set clipboard+=unnamed
""""""""""""""""""""""""""""""""""""""""""""""""
" Setup Vundler for plugin management
""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible
export interface PipelineContext<T> {
task: T;
stop: boolean;
}
export type Middleware<T> = (context: PipelineContext<T>) => Promise<PipelineContext<T>>;
/**
* Stops the pipeline execution by setting the stop flag to true.
*