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
def create_contacts_table(): | |
with postgres_connector() as c: | |
query = "DROP TABLE IF EXISTS contacts;" | |
c.execute(query) | |
query = """ | |
CREATE TABLE contacts ( | |
contact_id SERIAL PRIMARY KEY, | |
first_name VARCHAR ( 50 ) NOT NULL, | |
last_name VARCHAR ( 50 ) NOT NULL |
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 csv | |
from celery import group | |
from tasks import worker_task | |
from utils import chunks, postgres_connector, timing | |
def main(): | |
create_contacts_table() |
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 csv | |
from faker import Faker | |
fake = Faker() | |
csv_file_path = "test.csv" | |
with open(csv_file_path, "w") as csv_file: | |
writer = csv.DictWriter(csv_file, fieldnames=["first_name", "last_name"]) | |
writer.writeheader() |
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
from contextlib import contextmanager | |
from functools import wraps | |
from itertools import chain, islice | |
from time import time | |
import psycopg2 | |
def timing(f): | |
@wraps(f) |
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
# tasks.py | |
from celery import Celery | |
from utils import postgres_connector | |
app = Celery("tasks", backend="rpc://", broker="pyamqp://guest@localhost//") | |
@app.task |
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 sqlite3 | |
conn = sqlite3.connect('test.db') | |
c = conn.cursor() | |
query = """ | |
CREATE TABLE IF NOT EXISTS contacts ( | |
contact_id INTEGER PRIMARY KEY, | |
first_name TEXT NOT NULL, | |
last_name TEXT NOT NULL | |
); | |
""" |
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
def make_str(string: str) -> str: | |
r = [] | |
w = len(string) | |
for i in range(w): | |
for j in range(w-i): | |
s = string[i:i + j + 1] | |
r.append(s) | |
return r | |
# print(make_str('ABC')) |
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/python3 | |
import math | |
import os | |
import random | |
import re | |
import sys | |
class Node: |
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
ccc = 'abcd' | |
def get_item_from_number(ite, number): | |
bin_number = f'{number:b}'.zfill(len(ite)) | |
s = '' | |
for i, c in enumerate(bin_number): | |
if c == '1': | |
s += ite[i] |
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
# to generate your dhparam.pem file, run in the terminal | |
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 |