Skip to content

Instantly share code, notes, and snippets.

View DarkSuniuM's full-sized avatar

Alireza Ayinmehr DarkSuniuM

View GitHub Profile
"""SQLAlchemy MCVE."""
from sqlalchemy import create_engine, Column, Integer, String, Table, ForeignKey
from sqlalchemy.orm import sessionmaker, relationship
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine(
'mysql+pymysql://*******:*******@localhost/sqlalchemy_mcve')
Base = declarative_base(bind=engine)
Session = sessionmaker(bind=engine)
session = Session()
@DarkSuniuM
DarkSuniuM / docstrings.py
Created August 12, 2020 08:57
Python DocStrings
"""Python DocStrings Tutorial."""
def my_function():
"""Do nothing and return None."""
return None
class MyClass:
"""
@DarkSuniuM
DarkSuniuM / nginx.conf
Created March 12, 2020 21:57 — forked from ubermuda/nginx.conf
Proxy a unix socket HTTP server to a tcp port using nginx.
server {
listen 127.0.0.1:9000;
location / {
proxy_pass http://unix:/var/run/docker.sock:/;
}
}
$ apt update && apt upgrade -y # Update packages list and the packages
$ apt install sudo # Install 'sudo'
$ adduser coolguy # Create a new user
$ visudo # Add new user to the sudo users
# Disconnect root session
# SSH using the new user
#include <stdio.h>
#include <string.h>
char * reverseWords(const char *text);
char * reverseWord(char *word);
int main () {
char *text = "Hello World";
char *result = reverseWords(text);
printf("%s == %s\n", result, "olleH dlroW");
### Keybase proof
I hereby claim:
* I am darksunium on github.
* I am darksunium (https://keybase.io/darksunium) on keybase.
* I have a public key ASD9OJeHW1MXZ0y4I-gePkK2rkP4AoHAiJkyphOYB3PHDwo
To claim this, I am signing this object:
@DarkSuniuM
DarkSuniuM / Flask-Restful_S3_File_Upload.py
Last active November 5, 2018 04:03 — forked from RishabhVerma/Flask-Restful_S3_File_Upload.py
Uploading a file to S3 while using Flask with Flask-Restful to create a REST API. [ Python 3 ]
# -*- coding: utf-8 -*-
"""
An example flask application showing how to upload a file to S3
while creating a REST API using Flask-Restful.
Note: This method of uploading files is fine for smaller file sizes,
but uploads should be queued using something like celery for
larger ones.
"""
from io import BytesIO