Skip to content

Instantly share code, notes, and snippets.

View gwangjinkim's full-sized avatar

Gwang-Jin Kim gwangjinkim

View GitHub Profile
@gwangjinkim
gwangjinkim / xlsx2dfs.py
Last active April 23, 2021 15:41
print list of dataframes into excel sheets
#################################################
# solution mainly using pandas functionalities
# reading-in returns an ordered dict (which contains sheet_names as key) -> close to R functionality
# appending to excel like this might be slower
#################################################
def xlsx2dfs(fpath, **kwargs):
return pd.from_excel(fpath, sheet_name=None, **kwargs)
@gwangjinkim
gwangjinkim / install-and-start-postgresql-in-conda-locally
Last active February 17, 2026 10:06
How to install and run postgresql in conda
This gist I write, because I couldn't find any step by step instructions
how to install and start postgresql locally (using conda within a conda environment - with the result
that you can run it without sudo/admin rights on your machine!)
and not globally in the operating system (which requires sudo/admin rights on that machine).
I hope, this will help especially people new to postgresql
(and those who don't have sudo/admin rights on a specific machine but want
to run postgresql there)!
Prerequisite is to have miniconda already installed in your Computer.
# TimSort by https://quinston.com/code-snippets/timsort-algorthm-search-code/
import random
def InsertionSort(array):
for x in range (1, len(array)):
for i in range(x, 0, -1):
if array[i] < array[i - 1]:
t = array[i]
@gwangjinkim
gwangjinkim / export_plotly2SVG.R
Created September 14, 2018 11:52 — forked from salim-b/export_plotly2SVG.R
R function to export Plotly graphs as static SVG (and optionally PDF and PNG) images.
# Remarks:
#
# The export is done using the automated testing framework [Selenium](https://
# de.wikipedia.org/wiki/Selenium) which results in opening a browser window
# (Google Chrome) that might has to be closed by hand. Other than Plotly's
# own `export()` function this one also allows to set the `width` and `height`
# of the exported plot (in the former it's hardcoded to 800x600 pixels). If
# `incl_PDF_copy`/`incl_PNG_copy` is set to `TRUE`, the exported SVG additionally
# gets converted to a PDF/PNG using the R package [`rsvg`](https://github.com/
# jeroen/rsvg/tree/40576ac326621b40224db344b09158f4ff717433) which relies on