Skip to content

Instantly share code, notes, and snippets.

View ianjosephwilson's full-sized avatar

Ian Wilson ianjosephwilson

View GitHub Profile
define([], function() {
'use strict';
return function ($scope, $http, $routeParams, $q, $location) {
var warehouseId = $routeParams.warehouseId,
warehouseDeferred = $q.defer(),
locationsDeferred = $q.defer();
// @TODO: Resolve these.
$scope.crumbs = [];
$scope.warehouse = warehouseDeferred.promise;
$scope.locations = locationsDeferred.promise;
@ianjosephwilson
ianjosephwilson / app.js
Created September 9, 2013 22:08
do not route a url with angular while using html5mode, ie. this route should leave angularjs and do a full page load
// ...
// ...
app.config(function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
// ...
$routeProvider.otherwise({
redirectTo: function (params, path, search) {
search = jquery.param(search);
if (search) {
window.location = path + '?' + search;
@ianjosephwilson
ianjosephwilson / __init__.py
Created September 2, 2013 18:24
pyramid save off url in forbidden view
def redirect_if_not_logged_in(request):
if request.user is None:
request.session['original_url'] = request.url
return HTTPFound(location=request.route_url(
request.registry.settings['auth.login_route_name']))
return Forbidden()
def main(global_config, **settings):
#...
from sqlalchemy.ext.declarative import declarative_base
import sqlalchemy as db
from sqlalchemy.orm import relationship
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
from datetime import datetime
Base = declarative_base()
def set_request_url_info(request, settings):
# Need this to get port included when not 80,443.
request.host = None
request.scheme = settings['scripts.server_scheme']
request.server_name = settings['scripts.server_name']
request.server_port = settings['scripts.server_port']
@ianjosephwilson
ianjosephwilson / scriptlib.py
Created July 31, 2013 23:18
set request host for bootstrapped script
def set_request_url_info(request, settings):
# Need this to get port included when not 80,443.
request.host = None
request.scheme = settings['scripts.server_scheme']
request.server_name = settings['scripts.server_name']
request.server_port = settings['scripts.server_port']
upstream proxy_example_com {
server 127.0.0.1:5000;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
server_name proxy.example.com;
@ianjosephwilson
ianjosephwilson / slideshow.js
Last active December 20, 2015 06:09
Simple embedded slideshow.
/*globals jQuery*/
require([
"dojo/domReady!"
], function () {
"use strict";
var slideshow = {
imageTransitionDuration: 400,
imagePollTimeout: 5000,
imagePollFrequency: 100,
init: function (slideshowEl) {
@ianjosephwilson
ianjosephwilson / traceback
Created June 30, 2013 23:53
cornice + pyramid traceback: this exception occurs because I accidentally returned a db model which cannot be serialized to json
2013-06-30 16:51:59,609 ERROR [pyramid_debugtoolbar][Dummy-2] Exception at http://localhost:6543/events
traceback url: http://localhost:6543/_debug_toolbar/exception?token=da6152730325fdebcfa1&tb=55887184
Traceback (most recent call last):
File "/home/ian/workspace/scramble-project/ve/lib/python2.7/site-packages/pyramid_debugtoolbar-1.0.6-py2.7.egg/pyramid_debugtoolbar/toolbar.py", line 141, in toolbar_tween
response = _handler(request)
File "/home/ian/workspace/scramble-project/ve/lib/python2.7/site-packages/pyramid_debugtoolbar-1.0.6-py2.7.egg/pyramid_debugtoolbar/panels/performance.py", line 55, in resource_timer_handler
result = handler(request)
File "/home/ian/workspace/scramble-project/ve/lib/python2.7/site-packages/pyramid/tweens.py", line 40, in excview_tween
response = view_callable(exc, request)
File "/home/ian/workspace/scramble-project/ve/lib/python2.7/site-packages/pyramid/config/views.py", line 377, in viewresult_to_response
>>> from busysignal.model.shopsearch import ShopPlantSearchIndex; [p.scientific_name for p in ShopPlantSearchIndex(registry.settings['search.shop_plant_index_path']).search(u'Ribes')]
Query
(scientific_name:ribes^1000.0 OR common_names:ribes^10.0 OR description:ribes)
5626.11576821
5624.69278587
5624.64085731
5623.78431022
5621.25668483
5620.41278602
5617.7906843