This file contains 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
SRC_PATH = "../backend" | |
ENV_PATH = "../backend/.env.loc" | |
import redis | |
import random | |
import pickle | |
import pprint | |
import zlib | |
import os |
This file contains 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
alias run='nohup "$@" > /dev/null 2>&1 &' |
This file contains 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
alias pe='source $(ls ~/.cache/pypoetry/virtualenvs | fzf | xargs -I {} echo ~/.cache/pypoetry/virtualenvs/{}/bin/activate)' |
This file contains 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
// Unselect all | |
document.getElementsByName("viewed").forEach(ch => {if(ch.checked) {ch.click()}}) | |
// Select some with "key" | |
document.getElementsByName("viewed").forEach(ch => { if (!ch.checked && ch.id.includes("key")) { ch.click(); } }); |
This file contains 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
"""Creating thread safe and managed sessions using SQLAlchemy. | |
The sessions that are created are expected to be: | |
- thread safe | |
- handle committing | |
- handle rolling back on errors | |
- handle session removal/releasing once context or thread is closed. | |
Author: Nitish Reddy Koripalli | |
License: MIT |
This file contains 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
import subprocess | |
import IPython | |
import psycopg2 | |
def main(log_group): | |
def process_log_entry(timestamp, log_group, log_entry): | |
cursor.execute( | |
"INSERT INTO cloudwatch_logs (timestamp, log_group, log_entry) VALUES (%s, %s, %s)", | |
(timestamp, log_group, log_entry) |
This file contains 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
import subprocess | |
import IPython | |
import duckdb | |
def main(log_group): | |
def process_log_entry(timestamp, log_group, log_entry): | |
conn.execute( | |
"INSERT INTO cloudwatch_logs (timestamp, log_group, log_entry) VALUES (?, ?, ?)", | |
[timestamp, log_group, log_entry], | |
) |
This file contains 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
#!/bin/bash | |
icon_name="$1" | |
icon_directory="/usr/share/icons" | |
find "$icon_directory" -name "*$icon_name*" |
This file contains 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
-- Reference | |
-- https://stackoverflow.com/questions/46470030/postgresql-index-size-and-value-number | |
SELECT | |
i.relname "Table Name" | |
, indexrelname "Index Name" | |
, pg_size_pretty(pg_total_relation_size(relid)) As "Total Size" | |
, pg_size_pretty(pg_indexes_size(relid)) as "Total Size of all Indexes" | |
, pg_size_pretty(pg_relation_size(relid)) as "Table Size" | |
, pg_size_pretty(pg_relation_size(indexrelid)) "Index Size" |
This file contains 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
# PROS: Easy to use in CRUDs | |
# CONS: Invalid autocompletion | |
from inspect import isclass | |
from pydantic import BaseModel, create_model | |
from pydantic_core import SchemaSerializer, SchemaValidator | |
def omit(*fields): |
NewerOlder