Skip to content

Instantly share code, notes, and snippets.

View euclid1990's full-sized avatar
🍔
Code for food

Nguyen Van Vuong (Vic) euclid1990

🍔
Code for food
View GitHub Profile
// these are labels for the days of the week
cal_days_labels = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
// these are human-readable month name labels, in order
cal_months_labels = ['January', 'February', 'March', 'April',
'May', 'June', 'July', 'August', 'September',
'October', 'November', 'December'];
// these are the days of the week for each month, in order
cal_days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
@euclid1990
euclid1990 / Releaseflow.md
Last active July 2, 2019 16:52 — forked from fujimaki-k/Releaseflow.md
リリースまでの流れ

リリースまでの流れ

1. フィーチャーブランチの作成

  • develop ブランチから新たに作成する機能のためのフィーチャーブランチを作成します。
git branch feature/new_feature develop

2. プログラムの開発とテスト

@euclid1990
euclid1990 / VagrantFile
Created June 24, 2019 08:41 — forked from yudaykiran/VagrantFile
VagrantFile for automating Kubernetes Setup
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.require_version ">= 1.6.0"
# K8s Master Nodes
M_NODES = ENV['M_NODES'] || 1
@euclid1990
euclid1990 / php-pools.md
Created June 6, 2019 09:39 — forked from holmberd/php-pools.md
Adjusting child processes for PHP-FPM (Nginx)

Adjusting child processes for PHP-FPM (Nginx)

When setting these options consider the following:

  • How long is your average request?
  • What is the maximum number of simultaneous visitors the site(s) get?
  • How much memory on average does each child process consume?

Determine if the max_children limit has been reached.

  • sudo grep max_children /var/log/php?.?-fpm.log.1 /var/log/php?.?-fpm.log
@euclid1990
euclid1990 / gist:c3042ba8807ce1468703ecb90c68aa28
Created June 6, 2019 09:38 — forked from edavis/gist:1395977
Get memcached working with SASL
Download memcached source
./configure --enable-sasl --enable-sasl-pwdb
make
echo "user:password" > memcached-sasl-pwdb
export MEMCACHED_SASL_PWDB=memcached-sasl-pwdb
./memcached -S -vv
Don't need anything with sasl, saslpasswd2, or memcached.conf
@euclid1990
euclid1990 / M2M_Association_SQLalchemy.py
Created September 21, 2017 12:37 — forked from SuryaSankar/M2M_Association_SQLalchemy.py
An example of a many to many relation via Association Object in SQLAlchemy
import sqlalchemy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import sessionmaker, relationship, backref
from sqlalchemy.ext.associationproxy import association_proxy
import uuid
engine = sqlalchemy.create_engine('sqlite:///:memory:')
Base = declarative_base()
@euclid1990
euclid1990 / meta.py
Created September 14, 2017 04:57 — forked from shazow/meta.py
My latest SQLAlchemy model base class.
"""SQLAlchemy Metadata and Session object"""
import datetime
import json
import time
from sqlalchemy import MetaData
from sqlalchemy.orm import scoped_session, sessionmaker
__all__ = ['Session', 'metadata', 'Model', 'SchemaEncoder']
@euclid1990
euclid1990 / audit_mixin.py
Created September 13, 2017 06:38 — forked from ngse/audit_mixin.py
Rough attempt at implementing an audit log against Flask/Flask Login/SQLAlchemy models
# Requires use of Flask Login for the user tracking
# Implement by using AuditableMixin in your model class declarations
# e.g. class ImportantThing(AuditableMixin, Base):
import json
from flask_login import current_user
from sqlalchemy import event, inspect
from sqlalchemy.orm import class_mapper
from sqlalchemy.orm.attributes import get_history
@euclid1990
euclid1990 / README.md
Created September 5, 2017 07:44 — forked from rduplain/README.md
Flask-Script: demo passing in configuration file.

This demonstrates that you can configure a Flask application through Flask-Script, without having to create a Flask instance or deal with circular dependencies. Note that Flask-Script's Manager accepts a factory function in place of a Flask app object.

Running:

python manage.py runserver

gives "Hello, world!" on http://localhost:5000/, while running:

python manage.py runserver -c development.cfg
@euclid1990
euclid1990 / Large-app-how-to.md
Created September 1, 2017 07:06 — forked from cuibonobo/Large-app-how-to.md
How to structure a large application in Flask. Taken from the Flask wiki: https://github.com/mitsuhiko/flask/wiki/Large-app-how-to

Here's an example application that uses the pattern detailed below: https://github.com/tantastik/talent-curator


This document is an attempt to describe the first step of a large project structure with flask and some basic modules:

  • SQLAlchemy
  • WTForms

Please feel free to fix and add your own tips.