Can check if you're using swap with sudo swapon --show and free -h.
Useful for t2.micro and other instances with no access to instance store. Use this if you prefer not to mess with the root volume.
- Create the EBS volume e.g., 1 GB.
| update tests_summary_data set data = (jsonb_set(to_jsonb(data), '{misc,gap,pa}', '-1', false))::json where data->'misc'->'gap'->>'pa' = '0'; |
| #!/bin/python | |
| # | |
| # Copyright 2016 Flavio Garcia | |
| # | |
| # 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 | |
| # |
| /** | |
| * @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. | |
| */ |
| import collections | |
| def dict_merge(dct, merge_dct): | |
| """ Recursive dict merge. Inspired by :meth:``dict.update()``, instead of | |
| updating only top-level keys, dict_merge recurses down into dicts nested | |
| to an arbitrary depth, updating keys. The ``merge_dct`` is merged into | |
| ``dct``. | |
| :param dct: dict onto which the merge is executed | |
| :param merge_dct: dct merged into dct |
| 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}); |
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)
| 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 |
| 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 |
| /** | |
| * 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; |