Form could be useful for creating fields like Education interval or Work Experience interval. You could see such fields on facebook and linkedin.
Using: Flask, WTForms, SQLAlchemy, jQuery, Bootstrap
{% macro form_field(form, field, print_status=True) -%} | |
{% set has_label = kwargs.pop('has_label', True) %} | |
{% set placeholder = '' %} | |
{% if not has_label %} | |
{% set placeholder = field.label.text %} | |
{% endif %} | |
{% set field_status = '' %} | |
{% if form.errors and (form.submitted or (form.is_submitted() and form.submit.data)) %} | |
{# form.submit.data for support multiple forms on page #} | |
{# form.submitted - manual control for form without button (ajax) #} |
from flask import Flask | |
from flask.ext.sqlalchemy import SQLAlchemy | |
from flask.ext.wtf import Form | |
from flask.ext.babel import gettext | |
from wtforms import SelectField, TelField, TextField, FormField, Fieldlist, SubmitField | |
from wtforms.validators import Optional, Required | |
app = Flask(__name__) | |
db = SQLAlchemy(app) |
Using: Flask, SQLAlchemy, Infinite-scroll
# Execute plain query | |
db.engine.execute("Query here") | |
result = db.engine.execute("Query here") | |
for row in result: | |
print(row['id']) |
# Caching results in SELECT choices | |
# http://stackoverflow.com/questions/10368900/how-to-make-wtforms-read-from-the-datastore | |
# Choices will be cached | |
def get_clients_list_choices(): | |
choices = [(0, '')] | |
clients = Client.query.order_by('company') | |
for client in clients: | |
choices.append((client.id, client.fullname)) | |
return choices |
# list of files in current dir | |
$ ls -la | |
# open file for reading | |
$ cat filename | |
# open file for changes | |
$ nano filename | |
# remove folter and its contain |
# Install | |
# http://postgresapp.com/ | |
# http://postgresapp.com/documentation/cli-tools.html | |
DROP USER <username>; | |
CREATE USER <username> WITH PASSWORD '<password>'; | |
CREATE DATABASE <database-name>; | |
GRANT ALL privileges ON DATABASE <database-name> TO <username>; | |
# Create DB |
# N to M relationship without association_proxy | |
from sqlalchemy import create_engine, ForeignKey, Column, Integer, String, Table | |
from sqlalchemy.orm import backref, Session, relationship | |
from sqlalchemy.ext.declarative import declarative_base | |
engine = create_engine('sqlite:///', echo=False) | |
Base = declarative_base() | |
session = Session(bind=engine) |
Install / Update node modules
npm install
List of installed modules
npm list
npm list -g
npm list --depth=0