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
# Improvement after each stage: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o4htns2axmh87lieoclw.png | |
# Resource 1 => https://simplernerd.com/docker-typescript-production/ | |
# Resource 2 => https://medium.com/@ankit.wal/the-why-and-how-of-multi-stage-docker-build-with-typescript-example-bcadbce2686c | |
FROM node:18-alpine3.15 as ts-compiler | |
WORKDIR /usr/app | |
COPY package*.json ./ | |
COPY tsconfig.json ./ | |
RUN npm install --include=dev | |
COPY src src | |
RUN ["npm", "run", "build"] |
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
""" | |
Written by Arsham Arya | |
Some snippets around pymongo package to prevent my confusion. | |
""" | |
from pymongo import MongoClient | |
# Initializing | |
client = MongoClient("mongodb://username:password@host:port/default_db?authSource=admin") | |
database = client.get_database("db_name") | |
collection = database.get_collection("collection_name") |
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
from scrapy import crawler | |
from scrapy.utils.project import get_project_settings | |
# pip install crochet | |
from crochet import setup as crochet_setup, run_in_reactor | |
crochet_setup() | |
runner = crawler.CrawlerRunner(get_project_settings()) | |
@run_in_reactor |
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
""" | |
Written by Arsham Arya | |
I'm not sure it's the best way, | |
So any contribution makes everyone happy! | |
""" | |
from os import environ | |
# pip install python-dotenv | |
from dotenv import dotenv_values |
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
""" | |
Written by Arsham Arya | |
I'm not sure it's the best way, | |
So any contribution makes everyone happy! | |
""" | |
# pip install requests | |
from requests import get | |
# Config is can is a dictionary of ENV variables including TMDB_API_KEY | |
# https://gist.github.com/arshamalh/16a42854cb43bbe48038c7431529a552 |
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
# Compound unique indexs are indexes made of multiple columns together. | |
# For example if we have this data: | |
""" | |
("arsham", 930) | |
""" | |
# We can have ("arsham", 920), ("arsham", 910), Also we can have ("atousa", 930) | |
# but we can't have ("arsham", 930) again. | |
# I hope I explained it well enough. 😊 | |
from pymongo import MongoClient, ASCENDING |
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
from tkinter import * | |
from tkinter import messagebox | |
root = Tk() | |
root.geometry("480x170") | |
root.title("Raha Contacts books") | |
Name = StringVar() | |
Number = StringVar() | |
Address = StringVar() |
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
# Written by Arsham Arya | |
# I'm not sure it's the best way, | |
# So any contribution makes me and other readers happy :) | |
from psycopg2.pool import ThreadedConnectionPool | |
import config | |
_CONNECTION_POOL = None | |
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
-- Written by Arsham Arya | |
-- Any contribution makes readers happy. | |
INSERT INTO table_name (user_id, my_array_field) | |
VALUES (2233, array[112, 333]) | |
ON CONFLICT (user_id) DO | |
UPDATE SET my_array_field = array( | |
SELECT DISTINCT unnest(table_name.my_array_field || array[112, 333]) | |
) WHERE table_name.user_id = 2233; |
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
// Written by Arsham Arya | |
// I'm not sure it's the best way, | |
// So any contribution makes me and other readers happy :) | |
import pgPromise from "pg-promise"; | |
import Cursor from "pg-cursor"; | |
require("dotenv").config(); | |
const pgp = pgPromise(); |