Skip to content

Instantly share code, notes, and snippets.

View anhcuong's full-sized avatar
🎯
Focusing

Frank anhcuong

🎯
Focusing
  • Sydney
  • 17:50 (UTC +11:00)
View GitHub Profile
@anhcuong
anhcuong / cheat_sheet.md
Last active July 2, 2022 11:39 — forked from nhudinhtuan/cheat_sheet.md
15 days cheat sheet for interviews
import os
f = open('removed_parcels.txt')
removed_parcels = f.readlines()
f.close()
if removed_parcels[0] == '\n':
num_parcels = 0
removed_parcels_str = "No parcel is removed"
else:
num_parcels = len(removed_parcels)
removed_parcels_str = ''
@anhcuong
anhcuong / sql
Created March 13, 2018 03:10
List all running queries in Redshift/Postgres
SELECT
pid,
  user_name,
  starttime,
  query
FROM stv_recents
WHERE status = 'Running'
AND user_name = ‘admin’
-- Bad use of aggregation
SELECT
users.id,
users.email,
users.name,
MAX(users.created_at) AS created_at, -- not necessary
COUNT(orders.id) AS orders_count
FROM orders
LEFT JOIN users
ON users.id = orders.user_id