Skip to content

Instantly share code, notes, and snippets.

View kiendang's full-sized avatar
🐶

Kien Dang kiendang

🐶
View GitHub Profile
# This file makes tables for the concepts in this subfolder.
# Be sure to run postgres-functions.sql first, as the concepts rely on those function definitions.
# Note that this may take a large amount of time and hard drive space.
# string replacements are necessary for some queries
export REGEX_DATETIME_DIFF="s/DATETIME_DIFF\((.+?),\s?(.+?),\s?(DAY|MINUTE|SECOND|HOUR|YEAR)\)/DATETIME_DIFF(\1, \2, '\3')/g"
export REGEX_SCHEMA='s/`physionet-data.(mimic_derived|mimic_core|mimic_hosp|mimic_icu).(.+?)`/\2/g'
export CONNSTR='mimiciv mimic'
# this is set as the search_path variable for psql
-- Functions TODO:
-- FROM table CROSS JOIN UNNEST(table.column) AS col -> ???? (see icustay-hours)
-- ???(column) -> PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY column) (not sure how to do median in BQ)
-- psql 'dbname=mimiciv user=mimic options=--search_path=public,mimic_core,mimic_hosp,mimic_icu,mimic_derived' -f postgres-functions.sql
DROP FUNCTION IF EXISTS REGEXP_EXTRACT(str TEXT, pattern TEXT);
CREATE OR REPLACE FUNCTION REGEXP_EXTRACT(str TEXT, pattern TEXT) RETURNS TEXT AS $$
BEGIN
RETURN substring(str from pattern);
channels:
- defaults
- pytorch
- fastai
dependencies:
- pip
- ipykernel
- pytorch::pytorch
- pytorch::torchvision
- tensorflow-gpu
@kiendang
kiendang / unzip_into_dir.sh
Last active February 11, 2019 10:48
unzip all .zip files into directories
#!/bin/bash
find ${1:-.} -name '*.zip' | sed 's/.zip//' | xargs -n1 -P $(nproc) -I _ unzip _.zip -d _
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.7.1
---
output: html_document
editor_options:
chunk_output_type: inline
---
Copyright 2018 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
#!/bin/bash
#
# auto match window title and tab background color with
# terminal background color for iTerm2
# append to your .bashrc, .zshrc or whatever
# does not really work with High Sierra
# to reset:
# echo -e "\033]6;1;bg;*;default\a"
osascript -e \
import tensorflow as tf
from keras.backend.tensorflow_backend import set_session
gpu_options = tf.GPUOptions(allow_growth=True, per_process_gpu_memory_fraction=0.333)
sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options))
set_session(sess)
@kiendang
kiendang / compile_pytorch.sh
Created May 10, 2018 11:03
compile pytorch
CC=gcc-5 CXX=g++-5 NCCL_ROOT_DIR=/opt/cuda CFLAGS="${CFLAGS/-fno-plt/}" CXXFLAGS="${CXXFLAGS/-fno-plt/}" python setup.py bdist_wheel
@kiendang
kiendang / vlc_stream_browser_control.sh
Created March 11, 2018 04:48
stream media files using vlc + enable browser control
#!/bin/bash
vlc <filename> \
-I http --http-host 0.0.0.0 --http-port 4857 --http-password <password>
--sout '#standard{access=http,mux=ts,dst=:4875}'