Skip to content

Instantly share code, notes, and snippets.

@chenzhan
chenzhan / 50 Masterpieces you have to read before you die.txt
Created December 15, 2019 22:15
50 Masterpieces you have to read before you die
https://www.amazon.com/Masterpieces-you-have-read-before-ebook/dp/B01M28QE45
50 Masterpieces you have to read before you die Vol: 1
- The Divine Comedy [Dante Alighieri]
- Emma [Jane Austen]
- Persuasion [Jane Austen]
- Pride and Prejudice [Jane Austen]
- Father Goriot [Honoré de Balzac]
- Jane Eyre [Charlotte Brontë]
- The Tenant of Wildfell Hall [Anne Brontë]
@chenzhan
chenzhan / sqlalchemy_play.ipynb
Created October 20, 2016 02:34
Playing with SQLAlchemy
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chenzhan
chenzhan / Dockerfile
Created May 20, 2016 07:22
Postgresql 9.5 Docker
# vim:set ft=dockerfile:
# FROM debian:jessie
FROM ubuntu:latest
# explicitly set user/group IDs
RUN groupadd -r postgres --gid=999 && useradd -r -g postgres --uid=999 postgres
# grab gosu for easy step-down from root
ENV GOSU_VERSION 1.7
RUN set -x \
@chenzhan
chenzhan / docker_cheatsheet.md
Created May 17, 2016 18:32
Docker Cheatsheet

Docker Commands

Run instance

docker run -d centos
docker run -i -t centos /bin/bash

Set up

@chenzhan
chenzhan / window_function.sql
Created May 13, 2016 22:49
Window Function Example
with t as (
select x, y+x as y
from generate_series(1, 3) as t1(x) full outer join generate_series(11, 13) as t2(y) on 1=1
)
select x, y,
array_agg(x) over () as frame,
sum(x) over () as sum,
sum(x) over (partition by x order by y) as sum_rolling,
count(1) over (partition by x) as cnt_part,
count(1) over (partition by x order by y) as cnt_rolling,
@chenzhan
chenzhan / traverse_files.py
Created August 31, 2015 16:39
TraverseFiles
import os
import sys
import sqlite3 as lite
def traverse(dir, cur):
ft = list(tuple())
fl = os.listdir(dir)
for f in fl:
full_file_name = os.path.join(dir,f)
if os.path.isdir(full_file_name):
@chenzhan
chenzhan / redshift_admin_queries.sql
Last active August 8, 2023 05:49
Redshift Tips
# List all tables:
select db_id, id, name, sum(rows) as mysum
from stv_tbl_perm where db_id = 100546
group by db_id, id, name order by mysum desc;
# list all running processes:
select pid, query from stv_recents where status = 'Running';
# describe table
select * from PG_TABLE_DEF where tablename='audit_trail';