Skip to content

Instantly share code, notes, and snippets.

@moshfiqur
moshfiqur / docker-entrypoint.sh
Created May 20, 2019 21:27
Docker entrypoint script for Demo Flask App deployed on Google App Engine
#!/bin/bash
# perform the data migration
flask db migrate
flask db upgrade
if [ "$FLASK_ENV" == "development" ]; then
flask run --host=0.0.0.0 --port=8080
else
gunicorn --bind=0.0.0.0:8080 run:app
@moshfiqur
moshfiqur / Dockerfile
Created May 20, 2019 21:24
Dockerfile for Demo Flask App deployed on Google App Engine
FROM python:3.6
WORKDIR /usr/src/app
# To avoid invalidating docker's build
# cache everytime we are copying the app
# into the image, we will copy the
# requirements.txt first and then in later
# step we will copy the entire app
COPY requirements.txt /usr/src/app/
RUN pip install -r requirements.txt
@moshfiqur
moshfiqur / app.yaml
Created May 20, 2019 21:22
App settings for Google App Engine using Docker and MySQL database instance
runtime: custom
env: flex
# Replace project and instance with the values obtained when configuring your
# Cloud SQL instance. "INSTANCE-CONNECTION-NAME" Can be copied from
# https://console.cloud.google.com/sql/instances/
beta_settings:
cloud_sql_instances: INSTANCE-CONNECTION-NAME
@moshfiqur
moshfiqur / requirements.txt
Created May 20, 2019 21:16
All python modules requirements for Demo Flask App deployed on Google App Engine using Docker
alembic==1.0.10
bcrypt==3.1.4
blinker==1.4
cachetools==3.1.0
captcha==0.3
certifi==2019.3.9
cffi==1.11.5
chardet==3.0.4
Click==7.0
Flask==1.0.2
@moshfiqur
moshfiqur / face_detection_n_crop.py
Created June 22, 2018 10:22
Cropped faces after detection in an image using face_detection module and save them.
import face_recognition
from PIL import Image
np_image = face_recognition.load_image_file("avengers2.jpg")
# face_locations returns a list of locations for each face
# detected in the picture, each list item contains a tuple
# of 4 items in the format of (top, right, bottom, left)
face_locations = face_recognition.face_locations(np_image)
@moshfiqur
moshfiqur / wp_create_category.php
Created January 3, 2017 17:37
Programmatically create post category for wordpress
<?php
// Guessing this script is placed in the root wordpress directory.
// If not, change the require_once statements script path accordingly.
require_once('wp-load.php');
require_once('wp-admin/includes/taxonomy.php');
$conn = new mysqli('localhost', 'username', 'password', 'database');
if ($conn->connect_error) {
die('Connection failed');
@moshfiqur
moshfiqur / wp_create_post.php
Created January 3, 2017 17:34
Programmatically create wordpress post and add category/tags with them
<?php
// Guessing this script is placed in the root wordpress directory.
// If not, change the require_once statements script path accordingly.
require_once('wp-load.php');
require_once('wp-admin/includes/taxonomy.php');
// Connect to database and get data
$conn = new mysqli('localhost', 'username', 'password', 'databasename');
if ($conn->connect_error) {
/**
* A simple function to sort an array of obejcts each with a string field
* called 'name' and and a number field called 'age'.
*/
//
// Test Code
//
// var familyMembers = [
// {