Skip to content

Instantly share code, notes, and snippets.

View ianjosephwilson's full-sized avatar

Ian Wilson ianjosephwilson

View GitHub Profile
from time import sleep
from Arduino import Arduino
import logging
import sys
board = Arduino(port='/dev/ttyACM0')
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
storage_location_ids = server.model.stock.location.search([
('type', '=', 'storage'),
('parent', 'child_of', location_ids)])
@ianjosephwilson
ianjosephwilson / gist:8330653
Last active January 2, 2016 16:29
broken form helpers
{% macro form_error(key, errors) -%}{%- endmacro %}
{% macro form_input(key, values, errors=None, label=None, type='text') %}
<div class="form-group{{' error' if errors and key in errors else ''}}">
<label class="form-label">{{ label or key.replace('_', ' ').title() }}</label>
<input type="{{ type }}" name="{{ key }}"
value="{{ values.get(key, '') }}"
class="form-control">
{% form_error(key, errors) %}
</div>
@ianjosephwilson
ianjosephwilson / gist:8263540
Created January 5, 2014 02:30
gentoo blocking
sudo emerge --oneshot portage
* IMPORTANT: 6 news items need reading for repository 'gentoo'.
* Use eselect news to read news items.
Calculating dependencies... done!
[ebuild NS ] dev-lang/python-3.3.2-r2 [2.7.3-r2, 3.2.3] USE="gdbm ipv6 ncurses readline sqlite ssl threads xml -build -doc -examples -hardened -tk -wininst"
[ebuild U ] sys-apps/portage-2.2.7 [2.1.11.62] PYTHON_TARGETS="python3_3* -python3_2*"
[blocks B ] <sys-apps/sandbox-2.6-r1 ("<sys-apps/sandbox-2.6-r1" is hard blocking dev-lang/python-3.3.2-r2)
<div class="control-group">
<span class="control-label">Field</span>
<div class="controls">
<span class="help-inline">Value</span>
</div>
</div>
class TrytonServerWrapper(object):
def __init__(self, user_id, session_id, context, target):
self.user_id = user_id
self.session_id = session_id
self.context = context
self.target = target
def __call__(self, *args):
new_args = [self.user_id, self.session_id]
@ndb.transactional(xg=True)
def remove(self, new_rep_id=None):
# Un-assign this rep from all their stores.
stores = Store.query_stores(rep_id = self.key, active=None)
for store in stores:
store.rep_id = new_rep_id
store.put()
self.active = False
self.put()
from pyramid.config import Configurator
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
config = Configurator(settings=settings)
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '{url:.*}')
config.scan()
@ianjosephwilson
ianjosephwilson / app.js
Created September 27, 2013 19:57
loading notification
app.config(function($routeProvider, $locationProvider, $httpProvider) {
// ...
$httpProvider.responseInterceptors.push(function ($q, $rootScope) {
return function (promise) {
$rootScope.$broadcast('startLoading');
return promise.then(function (response) {
$rootScope.$broadcast('stopLoading');
return response;
}, function (response) {
$rootScope.$broadcast('stopLoading');
@ianjosephwilson
ianjosephwilson / app.js
Last active December 24, 2015 02:49
loading manager
$httpProvider.responseInterceptors.push(function ($q, LoadingManager) {
return function (promise) {
LoadingManager.startLoading();
return promise.then(function (response) {
LoadingManager.stopLoading();
return response;
}, function (response) {
LoadingManager.stopLoading();
return $q.reject(response);
});