Skip to content

Instantly share code, notes, and snippets.

View finete's full-sized avatar

finete finete

View GitHub Profile
@finete
finete / gamad.py
Created April 11, 2021 11:02
Moshe interview - with guy
from random import randint, shuffle
from typing import List, Dict
PEOPLE = ['ADI', 'MOR', 'GUY', 'NOY']
def main(names: List[str]) -> Dict[str, str]:
length = len(names)
gamad_anak = {}
while len(gamad_anak) != length:
@finete
finete / isntall_docker_and_compose.sh
Last active September 21, 2022 00:43
install docker and docker compose on ubuntu
# install docker if not exists
if [ ! -x "$(command -v docker)" ]; then
echo "Install docker prerequisites"
sudo apt-get update
sudo apt-get install \
apt-transport-https -y \
ca-certificates -y \
curl -y \
gnupg-agent -y \
@finete
finete / gist:c49b0077efeb25fb1f0ba58d6c09b77b
Last active September 7, 2020 13:15
convert SqlAlchemy ORM query to string for Postgres RDBMS
from sqlalchemy.dialects import postgresql;
print(query.statement.compile(dialect=postgresql.dialect(), compile_kwargs={"literal_binds": True}))
@finete
finete / psql_insert_copy.py
Last active August 4, 2023 11:05
pandas to_sql method using postgres copy from with ON CONFLICT DO NOTHING
from io import StringIO
import csv
TEMP_TABLE = 'temp_table'
def psql_insert_copy(table, conn, keys, data_iter, on_conflict_ignore=False):
# gets a DBAPI connection that can provide a cursor
dbapi_conn = conn.connection
with dbapi_conn.cursor() as cur:
@finete
finete / display_jupyter.py
Last active January 22, 2020 10:01
display several objects (including pandas data frames) side by on jupyter lab/notebook
class display:
"""Display HTML representation of multiple objects"""
template = """<div style="float: left; padding: 10px;">
<p style='font-family:"Courier New", Courier, monospace'>{0}</p>{1}
</div>"""
def __init__(self, *args, **kwargs):
self.args = args
self.kwargs = kwargs
def _repr_html_(self):