Skip to content

Instantly share code, notes, and snippets.

View akkefa's full-sized avatar
💻
Grit

Ikram Ali akkefa

💻
Grit
View GitHub Profile
"""A setuptools based setup module.
See:
https://packaging.python.org/en/latest/distributing.html
"""
# Always prefer setuptools over distutils
from setuptools import setup, find_packages
# To use a consistent encoding
from codecs import open
from os import path
version: '3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: wordpress
@akkefa
akkefa / Docker-compose V 3.3 Django setup
Last active January 24, 2019 17:21
Docker-compose V3.3 Django mysql nginx Setup
version: '3.3'
services:
django:
container_name: "django"
build:
context: ./docker/django
working_dir: /var/www
command: ["gunicorn", "-b", "0.0.0.0:8000" ,"-w" ,"4" ,"djangoapps.wsgi"]
from functools import wraps
from flask import session, request, redirect, url_for
def login_required(f):
@wraps(f)
def decorated_function(*args, **kwargs):
if session.get("username") is None:
return redirect(url_for("user_app.login", next=request.url))
return f(*args, **kwargs)
version: '3.3'
services:
app:
container_name: "test_app"
build:
context: ./
dockerfile: ./docker/python/Dockerfile
volumes:
import os
print os.environ['HOME']
# Or you can see a list of all the environment variables using:
os.environ
#As sometimes you might need to see a complete list!
# using get will return `None` if a key is not present rather than raise a `KeyError`
print os.environ.get('KEY_THAT_MIGHT_EXIST')
from flask.views import MethodView
from flask import jsonify, request, abort, make_response, current_app
from flask_jwt_extended import jwt_required
from agent import Agent
from web.extensions import csrf
from web.blueprints.data.models import Utterance
class SlackAPI(MethodView):
"""
@akkefa
akkefa / SQLAlchemy Cheat Sheet
Created January 27, 2018 15:14
SQLAlchemy is a deep and powerful thing made up of many layers. This cheat sheet sticks to parts of the ORM (Object Relational Mapper) layer,and aims to be a reference not a tutorial. That said, if you are familiar with SQL then this cheat sheet should get you well on your way to understanding SQLAlchemy.
#A SQLAlchemy Cheat Sheet
###Introduction
##Basic Models
One model is used to describe one database table. For example:
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import scoped_session,sessionmaker
from zope.sqlalchemy import ZopeTransactionExtension
from sqlalchemy import (
@akkefa
akkefa / install-docker.sh
Created February 20, 2018 04:32
Install latest docker CE version in ubuntu through Bash script.
#!/usr/bin/env bash
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
@akkefa
akkefa / 1. Install python3.6 & pip3.md
Created February 23, 2018 13:25 — forked from alyssaq/1. Install python3.7 & pip3.md
python3.6 setup on Mac 10.13 (High Sierra)
  1. Install Python 3.6.x from https://www.python.org/downloads/ or via homebrew
    Check that python3 has been installed by running it at the terminal:
$ python3
>>> Python 3.6.4
  1. Download get-pip.py from https://bootstrap.pypa.io/get-pip.py and install (this should already be installed if python was installed from python.org or homebrew):
$ curl -O https://bootstrap.pypa.io/get-pip.py
$ sudo python3 get-pip.py