Skip to content

Instantly share code, notes, and snippets.

@darktable
darktable / app.yaml
Created March 16, 2011 19:10
GAE: App.yaml designed for serving a static site on Google App Engine (Python). Copy your static html and files into a folder called "static" next to app.yaml. Contains a bunch of mimetype declarations from html5boilerplate's .htaccess. May not be neces
application: you-app-name-here
version: 1
runtime: python
api_version: 1
default_expiration: "30d"
handlers:
- url: /(.*\.(appcache|manifest))
mime_type: text/cache-manifest
@podhmo
podhmo / sqlalchemy_example.py
Created December 20, 2012 14:59
sqlalchemy query example.
import sqlalchemy as sa
import sqlalchemy.orm as orm
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy.orm import scoped_session, sessionmaker
DBSession = scoped_session(sessionmaker())
class BaseMixin(object):
query = DBSession.query_property()
id = sa.Column(sa.Integer, primary_key=True)
@sontek
sontek / gist:5660624
Created May 28, 2013 05:09
Small application using Pyramid, SQLAlchemy, and dogpile.cache
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
from pyramid.compat import text_type
from sqlalchemy.orm import scoped_session
from sqlalchemy.orm import sessionmaker
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
@alanhamlett
alanhamlett / api.py
Last active January 24, 2023 21:03
Serialize SQLAlchemy Model to dictionary (for JSON output) and update Model from dictionary attributes.
import uuid
import wtforms_json
from sqlalchemy import not_
from sqlalchemy.dialects.postgresql import UUID
from wtforms import Form
from wtforms.fields import FormField, FieldList
from wtforms.validators import Length
from flask import current_app as app
from flask import request, json, jsonify, abort
@jeremydw
jeremydw / google-app-engine-environment.textile
Last active April 8, 2018 13:19
Google App Engine Environment Variables (as of Google App Engine/1.8.6, October 2013)
APPENGINE_RUNTIME python27
APPLICATION_ID s~appid
AUTH_DOMAIN gmail.com
CONTENT_LENGTH 148
CONTENT_TYPE application/x-www-form-urlencoded
CURRENT_MODULE_ID default
CURRENT_VERSION_ID appid.370290628632119235
DATACENTER us1
DEFAULT_VERSION_HOSTNAME appid.appspot.com
HTTPS on
@bsommardahl
bsommardahl / gist:8605208
Last active January 17, 2024 15:42
RTD Client in C#
public interface IRtdClient
{
object GetValue(params object[] args);
}
public class RtdClient : IRtdClient
{
readonly string _rtdProgId;
static IRtdServer _rtdServer;
@stojg
stojg / consul
Created December 1, 2014 04:51
consul service init script for debian
#!/bin/sh
### BEGIN INIT INFO
# Provides: consul
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: Consul service discovery framework
# Description: Healthchecks local services and registers
# them in a central consul database.
# -*- coding:utf-8 -*-
import logging
logger = logging.getLogger(__name__)
from datetime import datetime
from pyramid.config import Configurator
from pyramid.view import view_config
from pyramid.httpexceptions import HTTPError
from pyramid.response import Response
import json
import sqlalchemy as sa
@yunano
yunano / consul.service
Created May 1, 2015 15:52
/etc/systemd/system/consul.service
[Unit]
Description=consul agent
Requires=network-online.target
After=network-online.target
[Service]
EnvironmentFile=-/etc/sysconfig/consul
Environment=GOMAXPROCS=2
Restart=on-failure
ExecStart=/usr/local/sbin/consul agent $OPTIONS -config-dir=/etc/consul.d
@svpino
svpino / pipeline_example.py
Created May 18, 2015 23:49
Google App Engine Pipeline API Example
# This pipeline sums up a bunch of values. That simple.
class SumPipeline(pipeline.Pipeline):
def run(self, *values):
return sum(values)
# This pipeline takes care of computing the score of one specific player
class PlayerScorePipeline(pipeline.Pipeline):
def run(self, player, level):
# Let's call our remote REST API to return the score
# of this player on the supplied level.