Skip to content

Instantly share code, notes, and snippets.

View jasonamyers's full-sized avatar

Jason Myers jasonamyers

View GitHub Profile
@jasonamyers
jasonamyers / 2013-02-15-SQLAlchemy-Func-and-Group.py
Last active January 21, 2021 14:45
This is from my blog post on pyNash
from sqlalchemy import create_engine
engine = create_engine('sqlite:///:memory:', echo=True)
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
from sqlalchemy import Column, Integer, String, Float
class User(Base):
__tablename__ = 'users'
@jasonamyers
jasonamyers / appname.conf
Created February 24, 2013 18:35
nginx to gunicorn proxy.
upstream appname {
#server unix:/tmp/gunicorn.sock fail_timeout=0;
# For a TCP configuration:
server 127.0.0.1:5000 fail_timeout=0;
}
server {
listen 80;
server_name www.appname.com;
rewrite ^ https://$server_name$request_uri? permanent;
}
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
@jasonamyers
jasonamyers / supervisord.conf
Created February 24, 2013 18:51
A sample supervisor config file
; Sample supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
;
; Note: shell expansion ("~" or "$HOME") is not supported. Environment
; variables can be expanded using this syntax: "%(ENV_HOME)s".
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
@jasonamyers
jasonamyers / 2013-03-01-SQLAlchemy-Hybrid-Properties.py
Created March 1, 2013 13:38
This is from my blog post on pynash.org on 2013-03-01
from sqlalchemy import create_engine
engine = create_engine('sqlite:///:memory', echo=True)
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.hybrid import hybrid_property
Base = declarative_base()
from sqlalchemy import Column, Integer, String, Float
class Order(Base):
__tablename__ = 'orders'
order_id = Column(Integer, primary_key=True)
order_reference_code = Column(String)
@jasonamyers
jasonamyers / collections.js
Last active December 16, 2015 00:28
Not understanding how line 5 col is undefined
App = this.App || {};
App.Photos = Backbone.Collection.extend({
url: "/backlift/toc/photos"
});
App.Captions = Backbone.Collection.extend({
url: "/backliftapp/captions",
forFile: function(file) {
return this.find(function(item) {
@jasonamyers
jasonamyers / overview.txt
Created May 14, 2013 02:04
Possible pyramid structure
-App
|-- app
| |-- __init__.py
| |-- static
| | |-- css
| | `-- js
| |-- templates
| | |-- users
| | | |-- login.jinja2
| | |-- view1.jinja2
mport os
import unittest
from mock import Mock
from pyramid import testing
from paste.deploy.loadwsgi import appconfig
from sqlalchemy import engine_from_config
from sqlalchemy.orm import sessionmaker
# Usage:
# source iterm2.zsh
# iTerm2 window/tab color commands
# Requires iTerm2 >= Build 1.0.0.20110804
# http://code.google.com/p/iterm2/wiki/ProprietaryEscapeCodes
tab-color() {
echo -ne "\033]6;1;bg;red;brightness;$1\a"
echo -ne "\033]6;1;bg;green;brightness;$2\a"
echo -ne "\033]6;1;bg;blue;brightness;$3\a"
@jasonamyers
jasonamyers / gist:5978233
Created July 11, 2013 19:01
PyOhio Organizer Advice
Hi Jason,
I've chaired PyOhio for the last three years, and we'd love to see more conferences. With PyCon being capped, and with us only able to accept a third of the talk proposals we received this year, there is increasing demand for more get togethers where we can share and learn from one another.
I am not a board member of the PSF, so I can only speak to my experience in answering some of your questions. I don't speak for the PSF.
As for needing to be a 501, no you don't need to be. PyOhio only incorporated last year (this is our sixth year) and is still waiting on 501 status (we got caught up in the 501 scandal too). What incorporating does is gives you a structure to do things under rather than having individuals, and it helpful once you've reached critical mass. But you don't need it to start generally. 501 status makes paying taxes easier, otherwise if you have money in the bank at the end of the year, you have to pay taxes. Also, some sponsors prefer that because they can use funds from a differen