This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://leetcode.com/problems/coin-change/?envType=problem-list-v2&envId=oizxjoit | |
def coin_change(coins, amount) | |
# The cache remembers how many coins it takes to make a certain amount | |
cache = {} | |
coin_change_recurser( | |
original_amount: amount, | |
coins: coins.sort.reverse, | |
current_coin_count: 0, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Consider an array of typed elements | |
type actions = "fart" | "burp" | "poop" | "barf" | |
let arrayOfActions: actions[] = [ | |
"fart", | |
"burp", | |
"poop" | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Algorithm to detect delete/insertion change (ie. drag-n-drop) in array of unique elements | |
# From https://webshittery.com/blog/cumbersome-apis/ | |
# Note that in certain situations where there is more than one correct answer | |
# For example: | |
# | |
# find_moved_element([1, 2, 3, 4, 5], [1, 3, 2, 4, 5]), | |
# | |
# Correct answers include: | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# _____ _ _ _____ ______ ______ ______ ______ ______ ______ ______ _______ | |
# / ____| | | |_ _| ____| ____| ____| ____| ____| ____| ____|__ __| | |
# | (___ | |__| | | | | |__ | |__ | |__ | |__ | |__ | |__ | |__ | | | |
# \___ \| __ | | | | __| | __| | __| | __| | __| | __| | __| | | | |
# ____) | | | |_| |_| |____| |____| |____| |____| |____| |____| |____ | | | |
# |_____/|_| |_|_____|______|______|______|______|______|______|______| |_| | |
######################## Day 1 ################################ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# ``` | |
# 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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder