Skip to content

Instantly share code, notes, and snippets.

# in your ini file, have this:
# env.use_env_variables = true
# sqlalchemy.url = DATABASE_URL
# then, in your __init__.py file, the first thing you do in your main function is this:
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
# Baseview has crud methods set up to do crud, based on some class attributes which are intended
# to be overridden by subclasses. Needless to say I have the full set of CRUD, and they actually
# do stuff.
class BaseView(object):
def __init__(self, request):
self.request = request
def create(self):
return "New object"
@inklesspen
inklesspen / evocation.md
Created August 11, 2013 09:24
Evocation and Encroachment: creepy magic for FATE Core

I'm trying to come up with a magic system for a "Cyberpunk and Sorcery" game I'm looking to run; my goal is something about halfway between "normal RPG magic" like Zird has in the examples throughout FATE Core and "you would have to be desperate or an idiot to use this" like the system toolkit's Void Calling.

Extra: Evocation magic. The world is full of Powers that you can call upon for aid, if you know how. Sometimes, though, they have more of an effect than you were expecting. Or desiring.

Extra Skill: Evocation. Anyone may take this skill (or possibly even use it at mediocre level if you didn't take it; I'm not sure if I want this or not.) You use it in the usual way, to Overcome or Create an Advantage. Maybe Attack, probably not Defend. If you fail your roll, you can choose to not get what you wanted, or you can choose Encroachment. If you choose Encroachment, you add shifts to make your roll a tie or success (you can't succeed with style), but you take Encroachment damage equal to the number of shift

# Given a SQLAlchemy engine, this will drop all the tables reachable from that engine
# I've used this in PostgreSQL, but it should work with other dialects as well.
from sqlalchemy.engine import reflection
from sqlalchemy.schema import (
MetaData,
Table,
DropTable,
ForeignKeyConstraint,
DropConstraint,
/* global angular */
angular.module('myapp.overrides', []).
factory('$exceptionHandler', ['$log', function($log) {
return function(exception, cause) {
// This line comes from the original Angular exception handler.
$log.error.apply($log, arguments);
_rollbar.push(exception);
};
}]).
run(["$templateCache", function($templateCache) {
@inklesspen
inklesspen / tagviewer.css
Last active December 19, 2015 11:09
TagViewer plugin for XKit To install: go to the editor (http://www.tumblr.com/xkit_editor). make a new plugin called tagviewer. paste these files in the appropriate tabs
.xkit_tagviewer_button.xkit_new_dashboard:after,
.xkit_tagviewer_button {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAJcEhZcwAACxMAAAsTAQCanBgAAAG0aVRYdFhNTDpjb20uYWRvYmUueG1wAAEAAAA4ja1UzW+CMBy9+1c07AwFnDE0yGGS3cyMc4kcK1TXDShpa8T/fi34wQrusEg40Pd77/fK60dYo7qoCiIxqIu8FKieWThjW4LUt4ahBRqK/J5Zm8USzBknYOJ4jm9FIwBAyLMdWsWvZ7kazaxPKSsE4fF4dI5jh/E99IIggK4Pfd9WDFucSolruxRPbZNLn5iIlNNKUlYCPcZbdpAzyzpz2qc1knR3cyqF00zaSVkBdQV6jguvvXV7jaIVESw/6PYfJZWRF8Ih2FTNWVFxIoSqR5OzpIuZ/M2tXzT1z4IuaAreOCUqkKZ2mVMXM/nJkEHSNwihEep/wyY1vRO2rvTD1iha0prkm5gWpGxi8t0QDhZM4ZzljL9XOCU6DRMatEnu2SQ9m4eFkqXXSKoDz5t9nqWQ5EQ5SqFS8X6nkqVIHLZfJO1usYvxC97DLhn22Q+buTrOw6tZ46q/mIqNFiyju1OMJVH5emPbnap37U2QO0XBcwgNjqGec4Il42vG8qhZlUIPge/4rbJb//NfW1TdNtFIKS83VzT6AZAgcnsa/oF5AAACX0lEQVQ4y9WUPWgUQRTHT1SwEQVFRCtBEUGwUKxUsBLFxkj84lqRgAgWlsIVKvnYmf3emb29vc3u7Md9mJwH9oelTQoLKxECFsoViidoCMn43pKYaC7eCRZaPJadef/fvJn3nylIKQt/Mwr/PnDCb+9U3fSRytI2cUQLQ2PprMay+1MsOk5ZckNzM2F4
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.httpexceptions import HTTPFound
def show_popular(request):
pageno_s = request.matchdict['pageno']
if pageno_s == '':
pageno_s = '1'
pageno = int(pageno_s)
if pageno < 1:
'use strict'; /* global angular, $ */
/* Services */
angular.module('uploadApp.services', []).
factory('imageloader', ['$q', '$rootScope', function($q, $rootScope) {
// Loads an image offscreen and provides a promise. The promise
// will be resolved with the jQuery object containing the
// image. Only one image can be loaded at a time; a new request
// while the old one is pending will cancel the old one.
# Attempt to turn http://paste2.org/p/2878916 into SQLAlchemy code
# I've had to make some guesses about the intent, though.
from sqlalchemy import *
metadata = MetaData()
group_table = Table('group_table', metadata, Column('group_id', Integer, primary_key=True), Column('type', String), Column('description', String))
contact_table = Table('contact_table', metadata, Column('client_id', Integer, primary_key=True), Column('group_id_1', Integer, ForeignKey(group_table.c.group_id)), Column('group_id_2', Integer, ForeignKey(group_table.c.group_id)), Column('group_id_3', Integer, ForeignKey(group_table.c.group_id)))
@inklesspen
inklesspen / gist:4626495
Created January 24, 2013 19:01
installing pyramid 1.4 with easy_install, python 3.3, on OS X 10.8.2
jon@astyanax:~$ cd /tmp
jon@astyanax:/tmp$ mkdir py3test
jon@astyanax:/tmp$ cd py3test/
jon@astyanax:/tmp/py3test$ wget https://raw.github.com/pypa/virtualenv/master/virtualenv.py
--2013-01-24 10:58:54-- https://raw.github.com/pypa/virtualenv/master/virtualenv.py
Resolving raw.github.com... 199.27.75.193
Connecting to raw.github.com|199.27.75.193|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 114330 (112K) [text/plain]
Saving to: ‘virtualenv.py’