Skip to content

Instantly share code, notes, and snippets.

View taekyunk's full-sized avatar

Taekyun Kim taekyunk

  • NY
View GitHub Profile
@taekyunk
taekyunk / quarto.code-snippets
Last active April 14, 2025 13:38
Quarto code snippets for VScode
{
// Place your lang workspace 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.
// Placeholders with the same ids are connected.
// Example:
// "Print to console": {
// "scope": "javascript,typescript",
@taekyunk
taekyunk / markdown.code-snippets
Last active April 14, 2025 13:39
Markdown code snippets for VScode
{
// Place your foam-template workspace 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.
// Placeholders with the same ids are connected.
// Example:
// "Print to console": {
// "scope": "javascript,typescript",
@taekyunk
taekyunk / clean_dendron_frontmatter.py
Created March 26, 2025 02:09
Clean frontmatters from markdown files created by Dendron
# To simplify frontmatter of md files created in Dendron to fit my taste
# - remove 'id', 'title', 'desc'
# - convert 'created' and 'updated' to human readable format
# to enable all outputs per cell
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
import pandas as pd
pd.options.display.max_rows = 4000
@taekyunk
taekyunk / jelly_snippets.txt
Last active March 14, 2025 13:41
Jelly snippets for code
-==-
rc |+| ```r%\n%\e%\n```
-==-
pc |+| ```python%\n%\e%\n```
-==-
sc |+| ```sql%\n%\e%\n```
-==-
bc |+| ```bash%\n%\e%\n```
-==-
tc |+| ```text%\n%\e%\n```
alias gs='git status '
alias ga='git add '
alias gb='git branch '
alias gc='git commit '
alias gd='git diff'
alias gds='git diff --staged'
alias gk='gitk --all&'
alias gb='git branch '
alias gl='git log --pretty=format:"%h: %ad: %an: %s" --date=short'
@taekyunk
taekyunk / mixed_models_combined_effect
Last active August 29, 2024 01:49
Find combined effect and interval for both fixed and random effects
## combine using s.e. using the logic here
# Ben 2014
# https://stackoverflow.com/a/26206495/4475353
# Ben 2023
# https://stackoverflow.com/questions/76317756/calculate-confidence-interval-of-random-fixed-effect-coefficients-in-a-mixed-e
library(tidyverse)
library(janitor)
@taekyunk
taekyunk / work_with_pickle.py
Created June 23, 2023 00:34
Work with pickle file
import pickle
def write_pickle(obj, file_name):
with open(file_name, 'wb') as fp:
pickle.dump(obj, fp)
def read_pickle(file_name):
with open(file_name, 'rb') as fp:
result = pickle.load(fp)
return result
@taekyunk
taekyunk / setup_rethinking.r
Created December 30, 2022 18:03
Set up rethinking package (with stan/cmdstanr)
install.packages('tidyverse')
install.packages('here')
library(tidyverse)
library(here)
# rstan -------------------------------------------------------------------
@taekyunk
taekyunk / simulation.r
Created August 31, 2022 19:54
Simulate E[XY] != E[X]E[Y]
library(MASS)
library(tidyverse)
sim <- function(r){
n_obs <- 200
mean_vec <- c(3, 4)
cov_mat <- matrix(c(1, r, r, 1), nrow = 2)
@taekyunk
taekyunk / feature_names.py
Last active July 10, 2022 00:39
Get features names from a fitted column transformer
# https://github.com/scikit-learn/scikit-learn/issues/12525#issuecomment-1071203398
# Just shorten the function name
import pandas as pd
from skimpy import clean_columns
from sklearn.compose import ColumnTransformer
from sklearn.pipeline import Pipeline
from sklearn.utils.validation import check_is_fitted
def get_feature_names(column_transformer, clean_column_names=False, verbose=True):