Skip to content

Instantly share code, notes, and snippets.

View fweep's full-sized avatar

Jim Stewart fweep

View GitHub Profile
@fweep
fweep / karma.config.js
Created November 8, 2016 12:58
Karma config
'use strict';
var path = require('path');
module.exports = function (config) {
config.set({
basePath: '../webpack/test',
reporters: ['mocha'],
port: 9876,
@fweep
fweep / gist:5af1c5fc8084fe219129
Last active August 29, 2015 14:01
SQL problem
create table file_upload (
id serial not null,
name text
);
create table reg_domain (
id serial not null,
name text
);
@fweep
fweep / gist:aefb9d8fbfed6478fccd
Created May 6, 2014 18:16
pyramid_mailer traceback
Traceback (most recent call last):
File "/Users/jim/uniregistrar/uniregistrar/uniregistrar/lib/tasks/job_task.py", line 79, in execute_job_task
response = task_method(job_task)
File "/Users/jim/uniregistrar/uniregistrar/uniregistrar/lib/tasks/file_upload_email_forward_task.py", line 29, in task_file_upload_email_forward
result = file_upload_email_forward(user_id, account_id, job_data)
File "/Users/jim/.virtualenv/unireg/lib/python2.7/site-packages/celery-3.1.8-py2.7.egg/celery/local.py", line 167, in <lambda>
__call__ = lambda x, *a, **kw: x._get_current_object()(*a, **kw)
File "/Users/jim/.virtualenv/unireg/lib/python2.7/site-packages/celery-3.1.8-py2.7.egg/celery/app/trace.py", line 417, in __protected_call__
return orig(self, *args, **kwargs)
File "/Users/jim/.virtualenv/unireg/lib/python2.7/site-packages/celery-3.1.8-py2.7.egg/celery/app/task.py", line 419, in __call__
CREATE TABLE account (
id SERIAL NOT NULL UNIQUE,
name TEXT NOT NULL
);
CREATE TABLE credit_card (
id SERIAL NOT NULL UNIQUE,
account_id INTEGER NOT NULL REFERENCES account(id),
card_number TEXT NOT NULL,
UNIQUE (account_id, id)
# encoding: utf-8
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column
from sqlalchemy import ForeignKey
from sqlalchemy import ForeignKeyConstraint
from sqlalchemy.types import INTEGER
from sqlalchemy.types import TEXT
@fweep
fweep / testlogging.py
Created November 29, 2013 15:34
pyramid logging example
#!/usr/bin/env python
from pyramid.paster import bootstrap
stuff = bootstrap("development.ini")
import logging
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger(__name__)
from pyramid.authentication import AuthTktAuthenticationPolicy
from pyramid.authorization import ACLAuthorizationPolicy
from myapp.tests.base import ViewTestBase
from myapp.views.authentication.login import login_view
from myapp.tests.helper import create_user
class LoginViewTests(ViewTestBase):
def setUp(self):
@fweep
fweep / test_login.py
Last active December 20, 2015 13:39
Pyramid, WebTest, SQLAlchemy functional test
import unittest
from myapp.tests.helper import create_user
SQLALCHEMY_URL = "postgresql://unireg@localhost/myapp"
def _init_testing_db():
from sqlalchemy import create_engine
from myapp.models import DBSession, Base
engine = create_engine(SQLALCHEMY_URL)
@fweep
fweep / gist:5306664
Created April 4, 2013 00:20
before filter example
class StudentsController < ApplicationController
before_filter :find_student, only: [:show, :update]
def show
# @student will already be loaded here
# do whatever
end
private
@fweep
fweep / gist:5241832
Created March 25, 2013 23:26
Host config with Vimrunner hanging
$ uname -a
Darwin lemur.wired.fweep.com 12.3.0 Darwin Kernel Version 12.3.0: Sun Jan 6 22:37:10 PST 2013; root:xnu-2050.22.13~1/RELEASE_X86_64 x86_64 i386 MacBookAir4,2 Darwin
$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Mar 19 2013 10:54:27)
Included patches: 1-244, 246-762
Compiled by jim@lemur.wired.lan.fweep.com
Huge version with GTK2 GUI. Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments