Skip to content

Instantly share code, notes, and snippets.

View StevenJL's full-sized avatar

Steven Li StevenJL

  • Fountain Inc.
  • SF Bay Area
  • 01:58 (UTC -07:00)
View GitHub Profile
@StevenJL
StevenJL / periodoxical_linked_in_discussion.rb
Created June 3, 2024 00:26
Periodoxical LinkedIn Discussion
# https://www.linkedin.com/feed/update/urn:li:activity:7202561717019578368?commentUrn=urn%3Ali%3Acomment%3A%28activity%3A7202561717019578368%2C7202905522717552640%29&dashCommentUrn=urn%3Ali%3Afsd_comment%3A%287202905522717552640%2Curn%3Ali%3Aactivity%3A7202561717019578368%29
# Schedule A is a meeting every other Monday at 4pm
# Schedule B is a reminder email for the meeting sent 2 days before it
require "periodoxical"
schedule_a = Periodoxical.generate(
time_zone: 'America/Los_Angeles',
start_date: '2024-06-02',
@StevenJL
StevenJL / .ctags
Created March 25, 2024 22:30
ctags config for tsx support
# Typescript TSX ctags
# Based on https://github.com/romainl/ctags-patterns-for-javascript/blob/d965c4abfd00e438a24f6f828b5a1d00258f330c/ctagsrc
--langdef=tsx
--langmap=tsx:.tsx
# These are the added ctags
--regex-tsx=/^[ \t]*(export[ \t]{1,})?type[ \t]{1,}([A-Za-z0-9_$]{1,})/\2/t,Type,Types/{pcre2}
--regex-tsx=/^[ \t]*(export[ \t]{1,})?interface[ \t]{1,}([A-Za-z0-9_$]{1,})/\2/t,Type,Types/{pcre2}
@StevenJL
StevenJL / aoc2002.txt
Last active December 11, 2022 07:23
aoc2022
# _____ _ _ _____ ______ ______ ______ ______ ______ ______ ______ _______
# / ____| | | |_ _| ____| ____| ____| ____| ____| ____| ____|__ __|
# | (___ | |__| | | | | |__ | |__ | |__ | |__ | |__ | |__ | |__ | |
# \___ \| __ | | | | __| | __| | __| | __| | __| | __| | __| | |
# ____) | | | |_| |_| |____| |____| |____| |____| |____| |____| |____ | |
# |_____/|_| |_|_____|______|______|______|______|______|______|______| |_|
######################## Day 1 ################################
@StevenJL
StevenJL / zsmnli_chatbot.py
Last active July 31, 2022 03:57
Zero-shot MNLI Chatbot Demo
#
# ```
# which python3
# pip3 install torch
# pip3 install transformers
# ```
import numpy as np
from transformers import pipeline
classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
@StevenJL
StevenJL / slow_running_queries.sql
Last active September 1, 2021 07:44
Slowest queries right now
# See the slowest queries right now
SELECT
pid,
age(clock_timestamp(), query_start) as time_running,
substr(query, 0, 75)
FROM pg_stat_activity WHERE state != 'idle'
ORDER BY time_running DESC;
# pid | time_running | query
@StevenJL
StevenJL / psql_connections.sql
Last active July 27, 2021 06:12
See postgres connections
SELECT state, COUNT(*) FROM pg_stat_activity
WHERE pid <> pg_backend_pid()
GROUP BY 1;
# state | count
# ---------------------+-------
# active | 7
# idle | 569
# idle in transaction | 2
# | 9
@StevenJL
StevenJL / blocking_queries.sql
Created June 15, 2021 07:00
Blocking Queries
SELECT blocked_activity.query AS blocked_statement,
blocking_activity.query AS current_statement_in_blocking_process
FROM pg_catalog.pg_locks blocked_locks
JOIN pg_catalog.pg_stat_activity blocked_activity ON blocked_activity.pid = blocked_locks.pid
JOIN pg_catalog.pg_locks blocking_locks
ON blocking_locks.locktype = blocked_locks.locktype
AND blocking_locks.database IS NOT DISTINCT FROM blocked_locks.database
AND blocking_locks.relation IS NOT DISTINCT FROM blocked_locks.relation
AND blocking_locks.page IS NOT DISTINCT FROM blocked_locks.page
AND blocking_locks.tuple IS NOT DISTINCT FROM blocked_locks.tuple
@StevenJL
StevenJL / low_use_indices.sql
Last active April 22, 2021 05:19
low use indices
WITH table_scans as (
SELECT relid,
tables.idx_scan + tables.seq_scan as all_scans,
( tables.n_tup_ins + tables.n_tup_upd + tables.n_tup_del ) as writes,
pg_relation_size(relid) as table_size
FROM pg_stat_user_tables as tables
),
all_writes as (
SELECT sum(writes) as total_writes
FROM table_scans
@StevenJL
StevenJL / init.vim
Last active February 21, 2021 06:33
~/.config/nvim/init.vim
" map kj to ESC
imap kj <ESC>
" Show line numbers in editor
set number
" Shows file name in terminal window title bar
set title
" When line length exceeds editor width, content does not wrap around
@StevenJL
StevenJL / shared_buffers.sql
Created February 8, 2021 03:42
Show Shared Buffers
SHOW SHARED_BUFFERS;
# shared_buffers
# ----------------
# 128MB
# (1 row)