Skip to content

Instantly share code, notes, and snippets.

View sany2k8's full-sized avatar
:octocat:
Focusing

Md. Sany Ahmed sany2k8

:octocat:
Focusing
  • Khulna, Bangladesh
View GitHub Profile
@alexjeen
alexjeen / eventbridge.tf
Created June 27, 2023 16:10
Using the EventBridge modules multiple times
variable "env_level" {
description = "Environment level"
default = "dev"
}
module "eventbridge_price" {
source = "terraform-aws-modules/eventbridge/aws"
create_bus = false
create_connections = true
create_api_destinations = true
@sany2k8
sany2k8 / pydantic_phone_number_field.py
Created September 16, 2022 14:54 — forked from iRhonin/pydantic_phone_number_field.py
Pydantic Phone Number Field
import phonenumbers
from pydantic.validators import strict_str_validator
class PhoneNumber(str):
"""Phone Number Pydantic type, using google's phonenumbers"""
@classmethod
def __get_validators__(cls):
yield strict_str_validator
yield cls.validate
@sany2k8
sany2k8 / pydantic_password_field.py
Created September 16, 2022 14:54 — forked from iRhonin/pydantic_password_field.py
Pydantic Password Field
from typing import Any
from typing import Dict
from typing import Set
from typing import Type
from pydantic import SecretStr
from pydantic.utils import update_not_none
class Password(SecretStr):
@sany2k8
sany2k8 / pytest.md
Last active July 26, 2022 13:40 — forked from kwmiebach/pytest.md
pytest cheat sheet

Usage

(Create a symlink pytest for py.test)

pytest [options] [file_or_dir] [file_or_dir] ...

Help:

@sany2k8
sany2k8 / script.sh
Created October 25, 2021 08:49 — forked from vielhuber/script.sh
PostgreSQL: Backup and restore export import pg_dump with password on command line #sql
# best practice: linux
nano ~/.pgpass
*:5432:*:username:password
chmod 0600 ~/.pgpass
# best practice: windows
edit %APPDATA%\postgresql\pgpass.conf
*:5432:*:username:password
# linux
import asyncio
import aiohttp
import time
async def gather_with_concurrency(n, *tasks):
semaphore = asyncio.Semaphore(n)
async def sem_task(task):
async with semaphore:
@sany2k8
sany2k8 / pg_stat_statements
Created January 6, 2021 08:00 — forked from troyk/pg_stat_statements
enable postgres pg_stat_statements
1) see re: increasing shmmax http://stackoverflow.com/a/10629164/1283020
2) add to postgresql.conf:
shared_preload_libraries = 'pg_stat_statements' # (change requires restart)
136 pg_stat_statements.max = 1000
137 pg_stat_statements.track = all
3) restart postgres
4) check it out in psql
@sany2k8
sany2k8 / notes.md
Last active January 5, 2021 14:56 — forked from ian-whitestone/notes.md
Best practices for presto sql

Presto Specific

  • Don’t SELECT *, Specify explicit column names (columnar store)
  • Avoid large JOINs (filter each table first)
    • In PRESTO tables are joined in the order they are listed!!
    • Join small tables earlier in the plan and leave larger fact tables to the end
    • Avoid cross joins or 1 to many joins as these can degrade performance
  • Order by and group by take time
    • only use order by in subqueries if it is really necessary
  • When using GROUP BY, order the columns by the highest cardinality (that is, most number of unique values) to the lowest.
@mustafaileri
mustafaileri / serverless.py
Created April 24, 2020 20:30
sample serverless app with ffmpeg and python
import json
import os
import boto3
def lambda_handler(event, context):
try:
s3 = boto3.client('s3')
"""Downlod video from private S3"""
s3.download_file('serverless-test-2020', 'Big_Buck_Bunny_1080_10s_1MB.mp4', '/tmp/test-video.mp4')
@berkorbay
berkorbay / github_desktop_ubuntu.md
Last active May 21, 2024 18:26
To install Github Desktop for Ubuntu

IMPORTANT

See the following links for further updates to Github Desktop for Ubuntu. These are official instructions. (also mentioned by fetwar on Nov 3, 2023)

For the sake of "maintaining the tradition" here is the updated version.