This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from application import db | |
from application.views.modelview import ModelView | |
from application.models import Things # has an attribute called thing_type | |
class MyModelView(ModelView): | |
def get_query(self): | |
thing_type = request.args.get('type', None) # pretending we have a GET parameter called "type" | |
if thing_type == "type1": | |
return super(ModelView, self).get_query().filter(Things.thing_type.like('type1 %')) | |
elif thing_type == "type2": |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import optparse | |
from flask import redirect, Flask | |
from memory_profiler import memory_usage | |
# Create flask app | |
app = Flask(__name__) | |
app.debug = True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import optparse | |
import gc | |
from flask import redirect, Flask | |
from memory_profiler import memory_usage | |
# Create flask app | |
app = Flask(__name__) | |
app.debug = True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import optparse | |
import gc | |
from flask import redirect, Flask | |
from memory_profiler import memory_usage | |
from multiprocessing import Process | |
# Create flask app | |
app = Flask(__name__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get update && time sudo apt-get dist-upgrade | |
sudo timedatectl set-timezone America/Chicago | |
apt-get install git fail2ban htop nano | |
mkdir -p .ssh | |
nano .ssh/authorized_keys | |
eval `ssh-agent -s` | |
ssh-add ~/.ssh/id_rsa | |
apt-get install python-setuptools | |
easy_install pip | |
pip install virtualenvwrapper |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function send_invitiation_email($vars) { | |
$command = "sendemail"; | |
$adminuser = "secret"; | |
$values["messagename"] = "Google Groups Invitation"; | |
$values["id"] = $vars['userid']; | |
$results = localAPI($command, $values, $adminuser); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, redirect | |
from werkzeug.routing import RoutingException, HTTPException | |
app = Flask(__name__) | |
@app.route('/') | |
def hello_world(): | |
def helper_function(): | |
# Attempt #1 | |
# this obviously won't work: return redirect('www.google.com') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, request | |
from flask.ext.sqlalchemy import SQLAlchemy | |
from flask.ext.admin.contrib import sqla | |
from flask.ext.admin import expose, Admin | |
app = Flask(__name__) | |
app.config['DATABASE_FILE'] = 'sample_db.sqlite' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Single Unchecked Checkbox Form Demo</title> | |
</head> | |
<body> | |
<form method=post action="/"> | |
{{ form.uncheck_me.label }} | |
{{ form.uncheck_me }} | |
<br><input type=submit value=Submit> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, request | |
from flask.ext.sqlalchemy import SQLAlchemy | |
from flask.ext.admin.contrib import sqla | |
from flask.ext.admin import expose, Admin | |
app = Flask(__name__) | |
app.config['DATABASE_FILE'] = 'sample_db.sqlite' |