Skip to content

Instantly share code, notes, and snippets.

View postgres-make-concepts.sh
# 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
View postgres-functions.sql
-- 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);
View environment.yml
channels:
- defaults
- pytorch
- fastai
dependencies:
- pip
- ipykernel
- pytorch::pytorch
- pytorch::torchvision
- tensorflow-gpu
@kiendang
kiendang / unzip_into_dir.sh
Last active Feb 11, 2019
unzip all .zip files into directories
View unzip_into_dir.sh
#!/bin/bash
find ${1:-.} -name '*.zip' | sed 's/.zip//' | xargs -n1 -P $(nproc) -I _ unzip _.zip -d _
View pyenv_install_shared.sh
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.7.1
View bigquery_tutorial_updated.Rmd
---
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
View iterm_bar_color.sh
#!/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 \
View keras_tf_limit_gpu.py
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)
View compile_pytorch.sh
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 Mar 11, 2018
stream media files using vlc + enable browser control
View vlc_stream_browser_control.sh
#!/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}'