Skip to content

Instantly share code, notes, and snippets.

View techniq's full-sized avatar

Sean Lynch techniq

View GitHub Profile
@techniq
techniq / getimageinfo.py
Created August 23, 2012 13:12
Get Image Info
import StringIO
import struct
def getImageInfo(data):
data = str(data)
size = len(data)
height = -1
width = -1
content_type = ''
@techniq
techniq / formview.py
Created August 23, 2012 14:19
FormView
from google.appengine.ext import db
from flask import flash, url_for, redirect, request
from flask.views import View
from flaskext.wtf import Form
from wtforms.ext.appengine.db import model_form
from application.decorators import templated
@techniq
techniq / simple-echo-server.py
Created August 23, 2012 15:12
Simple Echo Server
#!/usr/bin/env python
"""
A simple echo server
"""
import socket
host = ''
port = 50000
@techniq
techniq / set_dns.bat
Created September 12, 2012 02:07
Set Windows DNS Server
@ECHO OFF
set DNS_IP=
set /P DNS_IP=DNS server ip address: %=%
echo Setting DNS server...
netsh interface ip set dns "Local Area Connection 9" static %DNS_IP%
@techniq
techniq / base.html
Created November 13, 2012 14:47
Flask-Admin WTForms boostrap-wysihtml5
<!DOCTYPE html>
<html lang="en">
<head><script type="text/javascript">var NREUMQ=NREUMQ||[];NREUMQ.push(["mark","firstbyte",new Date().getTime()]);</script>
<link href='/static/bootstrap/css/bootstrap.css' rel='stylesheet' type='text/css' />
<link href='/static/wysihtml5/bootstrap-wysihtml5.css' rel='stylesheet' type='text/css' />
</head>
<body>
...
<script src="/static/wysihtml5/wysihtml5-0.3.0.min.js"></script>
@techniq
techniq / database.py
Created November 19, 2012 19:23
Flask-Script with fixture example
from flask_sqlalchemy import SQLAlchemy
from flask_script import Manager, prompt_bool
import application.models
db = SQLAlchemy()
manager = Manager("Perform database operations")
@manager.command
def drop():
@techniq
techniq / main.py
Last active December 10, 2015 20:09
SQLAlchemy / Google Cloud SQL issue
from sqlalchemy import create_engine
engine = create_engine('mysql+gaerdbms:///myapp',
connect_args={"instance":"instancename"})
connection = engine.connect()
@techniq
techniq / extensions.py
Created January 12, 2013 06:15
Configure Flask-Security
...
def configure_security(app):
# Flask-Security / Flask-Social / Flask-Login / Flask-Principal
from flask_security import Security
from flask_security.datastore import SQLAlchemyUserDatastore
from flask_social import Social
from flask_social.datastore import SQLAlchemyConnectionDatastore
Security(app, SQLAlchemyUserDatastore(db, models.User, models.Role))
Social(app, SQLAlchemyConnectionDatastore(db, models.Connection))
@techniq
techniq / app.py
Last active December 11, 2015 12:38
flask-script pull request 52 test app
from flask import Flask, request, flash, url_for, redirect, render_template
from flask.ext.sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config.from_pyfile('application.cfg')
db = SQLAlchemy(app)
from models import Todo
@techniq
techniq / select2_ajax.js
Created January 23, 2013 16:24
Select2 ajax example with custom query call to append data to the request. Note: Providing ajax settings is not needed (and not used) when query is provided. Left here as a full example.
$("[data-provide='select2']").each(function () {
var $element = $(this);
$element.select2({
placeholder: $element.data("placeholder"),
minimumInputLength: 0,
allowClear: true,
initSelection: function (element, callback) {
callback({
id: $(element).val(),