Skip to content

Instantly share code, notes, and snippets.

import timeit
from StringIO import StringIO
from cStringIO import StringIO as cStringIO
from tempfile import TemporaryFile
closure = dict()
def generate_test_data(size=1000):
@TallGirlVanessa
TallGirlVanessa / gist:03e3b0f1218e699c38f3
Created October 6, 2014 22:27
Send result of backend process to web socket
#!/usr/bin/env python
from flask import Flask, render_template
from flask.ext.uwsgi_websocket import WebSocket
app = Flask(__name__)
ws = WebSocket(app)
@app.route('/')
def index():
return render_template('index.html')
$ bower install -V
bower momentjs#* not-cached git://github.com/moment/moment.git#*
bower momentjs#* resolve git://github.com/moment/moment.git#*
bower momentjs#* error Arguments to path.join must be strings
Stack trace:
TypeError: Arguments to path.join must be strings
at path.js:360:15
at Array.filter (native)
at Object.exports.join (path.js:358:36)
@TallGirlVanessa
TallGirlVanessa / ansible error
Last active August 29, 2015 14:01
Ansible "operation not permitted" in 1.6.0
__________________________________________________________
< TASK: deploy_web | Deploy | Create Flask instance folder >
----------------------------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
import logging
from sqlalchemy.engine import create_engine
from sqlalchemy.types import Integer, String, TypeDecorator
from sqlalchemy.sql import text
from sqlalchemy.schema import Column
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy.ext.declarative import declarative_base
from nose import tools
@TallGirlVanessa
TallGirlVanessa / gist:8745534
Created January 31, 2014 23:40
Stored procedure and ORM queries
def _trackable_truckload_details():
""" Executes the `ODSQuery.SelectBridgeLoadBoard` stored procedure to retrieve load board details for track-able
truckload shipments.
Note: This function should only be called once, periodically and the results should be cached.
"""
return db.session.query(
LoadBoard.load,
LoadBoard.orgn_stop,
LoadBoard.dest_stop,
@TallGirlVanessa
TallGirlVanessa / gist:8745448
Created January 31, 2014 23:32
SQLAlchemy monkeypatch
class _PatchedEngineConnector(_EngineConnector):
def get_engine(self):
with self._lock:
uri = self.get_uri()
echo = self._app.config['SQLALCHEMY_ECHO']
encoding = self._app.config.get('SQLALCHEMY_ENCODING')
if (uri, echo) == self._connected_for:
return self._engine
info = make_url(uri)
options = {'convert_unicode': True}
@TallGirlVanessa
TallGirlVanessa / vagrant up error
Created December 10, 2013 18:23
Vagrant 1.4 seems to break vagrant-parallels
$ vagrant up
Bringing machine 'default' up with 'parallels' provider...
/Users/matthewphipps/.vagrant.d/gems/gems/vagrant-parallels-0.0.8/lib/vagrant-parallels/action.rb:22:in `block in action_boot': uninitialized constant VagrantPlugins::Parallels::Action::NFS (NameError)
from /Users/matthewphipps/.vagrant.d/gems/gems/vagrant-parallels-0.0.8/lib/vagrant-parallels/action.rb:13:in `tap'
from /Users/matthewphipps/.vagrant.d/gems/gems/vagrant-parallels-0.0.8/lib/vagrant-parallels/action.rb:13:in `action_boot'
from /Users/matthewphipps/.vagrant.d/gems/gems/vagrant-parallels-0.0.8/lib/vagrant-parallels/action.rb:225:in `block (4 levels) in action_start'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.0/lib/vagrant/action/builtin/call.rb:47:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.0/lib/vagrant/action/builtin/call.rb:47:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.0/lib/vagrant/action/warden.rb:34:in `call'
from /Applications/Vagrant/embedded/gems/g