Skip to content

Instantly share code, notes, and snippets.

View wgwz's full-sized avatar
🌱

Kyle Lawlor-Bagcal wgwz

🌱
View GitHub Profile
@wgwz
wgwz / web-led-loop-problem
Created August 15, 2015 02:27
using Flask to make web-app with Rpi for controlling LED's
I asked this question a few weeks ago in the Raspberry Pi Forum's.
Unfortunately no one got back to me.
I am sure there is a simple solution to my problem.
So I am making a really simple webapp, which has two buttons.
One button starts a blink sequence on a multi-colored LED.
The other button turns the multi-LED completely off.
The blink sequence requires a loop.
The loop freezes the webapp.
@wgwz
wgwz / install-pymks.md
Last active August 29, 2015 14:27
my installation of pymks

OS: Linux Mint 17.2

Using Anaconda Distribution Python


The following worked for installation of pymks.

This walks through setting up sfepy as well

@wgwz
wgwz / wtf.txt
Created January 22, 2016 15:34 — forked from doobeh/wtf.txt
Persuading WTForms to Generate Checkboxes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WTForms takes the pain out of handling forms and validation, you define your form,
tell it what validation checks the data needs to pass, then WTForms uses it's
widgets to generate the html.
A common problem you'll face is "Multiple select fields suck, they are confusing--
how can I show the user a nice list of checkboxes instead?"
@wgwz
wgwz / tmux-cheatsheet.markdown
Created March 12, 2016 19:02 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@wgwz
wgwz / form_test.py
Created June 16, 2016 21:21 — forked from anddam/form_test.py
Pagination issue while using Flask-WTF in Flask with Flask-Bootstrap and Flask-SQLAlchemy
from flask import Flask, render_template_string, request
from flask_bootstrap import Bootstrap
from jinja2 import Template
from flask_wtf import Form
from wtforms import StringField
from wtforms.validators import DataRequired
from flask_sqlalchemy import SQLAlchemy
# Build the app along with its extensions and the route

Keybase proof

I hereby claim:

  • I am wgwz on github.
  • I am wgwz (https://keybase.io/wgwz) on keybase.
  • I have a public key ASAshCTfdnjeJYe5Ce-UY9fcQgWi5vu8dRhaFDTa5Dxttgo

To claim this, I am signing this object:

@wgwz
wgwz / issue.py
Created July 22, 2016 22:54 — forked from CorneliaXaos/issue.py
Demonstrates a Possible Issue with the Flask Test Client
from flask import Flask, Blueprint
app = Flask(__name__)
bp = Blueprint("test", __name__)
@bp.route("/test/")
def test():
return "TEST"
app.register_blueprint(bp, subdomain="test")
@wgwz
wgwz / gist:86367f1a53042bc4ad4935e406780a1e
Created October 18, 2016 18:06
example error running flask-socketio gunicorn
gunicorn -c "python:config.gunicorn" "api:create_app()"
[2016-10-18 14:01:37 -0400] [3654] [INFO] Starting gunicorn 19.6.0
[2016-10-18 14:01:37 -0400] [3654] [INFO] Listening at: http://0.0.0.0:8000 (3654)
[2016-10-18 14:01:37 -0400] [3654] [INFO] Using worker: eventlet
[2016-10-18 14:01:37 -0400] [3657] [INFO] Booting worker with pid: 3657
127.0.0.1 - - [18/Oct/2016:14:01:44 -0400] "GET /api/v1/ HTTP/1.1" 200 3101 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36" in 87173µs
127.0.0.1 - - [18/Oct/2016:14:01:44 -0400] "GET /socket.io/?EIO=3&transport=polling&t=1476813704788-0 HTTP/1.1" 200 119 "http://localhost:8000/api/v1/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36" in 782µs
127.0.0.1 - - [18/Oct/2016:14:01:44 -0400] "POST /socket.io/?EIO=3&transport=polling&t=1476813704809-1&sid=ac7af57072f74aa49d3c92e79bab9f9e HTTP/1.1" 200 2 "http://localhost:8000/ap
@app.route("/test_session")
def write():
session['uid']='my_uid'
return session.get('uid')
@app.route("/read_session")
def read():
return session.get('uid')
@wgwz
wgwz / flask_cors.py
Created April 12, 2017 01:07 — forked from blixt/flask_cors.py
How to add CORS support to a Flask app in 9 lines of code
def add_cors_headers(response):
response.headers['Access-Control-Allow-Origin'] = '*'
if request.method == 'OPTIONS':
response.headers['Access-Control-Allow-Methods'] = 'DELETE, GET, POST, PUT'
headers = request.headers.get('Access-Control-Request-Headers')
if headers:
response.headers['Access-Control-Allow-Headers'] = headers
return response
app.after_request(add_cors_headers)