The following gist is an extract of the article Flask-SQLAlchemy Caching. It allows automated simple cache query and invalidation of cache relations through event among other features.
# pulling one User object
user = User.query.get(1)
/** | |
:inlineStyle filter | |
An inline style selector filter. | |
Usage: $("div:inlineStyle(display:none)"); // returns any divs with display style set to none | |
$("div:inlineStyle(width)"); // returns any divs with a width style set | |
$("div:inlineStyle"); // returns any divs with an inline style set | |
Written by Corban Brook @corban |
import unicodecsv | |
from django.http import HttpResponse | |
def export_as_csv_action(description="Export selected objects as CSV file", | |
fields=None, exclude=None, header=True): | |
""" | |
This function returns an export csv action | |
'fields' and 'exclude' work like in django ModelForm | |
'header' is whether or not to output the column names as the first row | |
""" |
upstream phpfpm { | |
server 127.0.0.1:9000; | |
} | |
server { | |
listen 80; | |
server_name _; | |
root /var/www/html; | |
index index.php; |
/** | |
* Swap the elements in an array at indexes x and y. | |
* | |
* @param (a) The array. | |
* @param (x) The index of the first element to swap. | |
* @param (y) The index of the second element to swap. | |
* @return {Array} The input array with the elements swapped. | |
*/ | |
var swapArrayElements = function (a, x, y) { | |
if (a.length === 1) return a; |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy import Integer, Column | |
from postgresql_json import JSON | |
Base = declarative_base() | |
class Document(Base): | |
id = Column(Integer(), primary_key=True) | |
data = Column(JSON) | |
#do whatever other work |
from sqlalchemy import create_engine, event, orm | |
from sqlalchemy.orm import sessionmaker | |
from sqlalchemy.orm.session import Session as SessionBase, object_session | |
from sqlalchemy.event.api import listen | |
# The following adds delete, insert, and update events after successful commits. | |
# SQLAlchemy provides only events after flushes, but not after commits. | |
# The classes are adapted from Flask-SQLAlchemy. | |
# see also https://stackoverflow.com/a/12026787/60982 |
The following gist is an extract of the article Flask-SQLAlchemy Caching. It allows automated simple cache query and invalidation of cache relations through event among other features.
# pulling one User object
user = User.query.get(1)
var app = angular.module('app', ['firebase']); | |
app.controller('ctrl', function($scope, $pageArray) { | |
$scope.pageItems = $pageArray(ref, 'number'); | |
}); | |
app.factory('$pageArray', function($firebaseArray) { | |
return function(ref, field) { | |
// create a Paginate reference | |
var pageRef = new Firebase.util.Paginate(ref, field, {maxCacheSize: 250}); |
# Copyright 2016-2022 Paul Durivage | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, |
/** | |
* @OnlyCurrentDoc Limits the script to only accessing the current spreadsheet. | |
*/ | |
/** | |
* Adds a custom menu with items to show the sidebar and dialog. | |
* | |
* @param {Object} e The event parameter for a simple onOpen trigger. | |
*/ |