Skip to content

Instantly share code, notes, and snippets.

need to support

  • bi-directional model to select2 selected object changes
  • select2 data-set changes
  • select2 object to ng-model mapping that supports attributes, not necessarily the whole object, similar to <option ng-repeat value={{obj.attribute}}>{{obj.humanReadableAttribute}}</option>
  • should work for both multi and single-value selects
  • should support optgroups
GaTransactionConf = namedtuple("GaTransactionConf", ["sku", "name", "category"])
class GaTransactionsDict(dict):
def __getitem__(self, key):
if isinstance(key, GaTransactionConf):
for mapping in self.keys():
if cmp_ga_conf(key, mapping):
key = mapping #update the key
return dict.__getitem__(self, key)
@dtheodor
dtheodor / tagged_articles.py
Last active August 29, 2015 14:08
Tagging and retrieving versions of objects with arbitrary key/value.
from sqlalchemy_continuum import get_versioning_manager
class VersionBase(object):
"""Base class for SQL Alchemy continuum objects that supports tagging"""
@classmethod
def tag_current_transaction(cls, **kwargs):
"""Add keyword arguments that will be stored as a `TransactionMeta`
entry on next successful commit that includes versioned objects.
"""
@dtheodor
dtheodor / listen_pg.py
Created December 18, 2014 21:30
Listen for pg_notify with Psycopg2
import select
import datetime
import psycopg2
import psycopg2.extensions
conn = psycopg2.connect(database="postgres", user="vagrant")
#conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
curs = conn.cursor()
@dtheodor
dtheodor / listen_sqla.py
Last active August 7, 2023 11:38
Listen for pg_notify with SQL Alchemy + Psycopg2
import select
import datetime
import psycopg2
import psycopg2.extensions
from sqlalchemy import create_engine, text
engine = create_engine("postgresql+psycopg2://vagrant@/postgres")
@dtheodor
dtheodor / app.md
Last active August 29, 2015 14:13
Port angular app + browserify example from http://benclinkinbeard.com/talks/2014/ng-conf/#/19 to use RequireJS

app.js

define(['angular', 'login', 'charts', 'routes'],
function(angular, login, charts, routes){
  'use strict';

  angular.module('app', [
      login.name,
      charts.name
      ...
@dtheodor
dtheodor / data.md
Last active August 29, 2015 14:16
data with loaded listeners and is loading status

Problem:

  • There's a module that knows how to load (and re-load) data through an API, and stores it locally.
  • Multiple modules access the loaded data, and transform them into a different representation (each module does a different transform), also storing them locally
  • The transformed data is exposed to the view, with a 'loading' indication when the original data is (re)loaded and/or the transformation is in progress.

##API idea

Promises support:

  • on resolution callbacks, where the transform function can be attached.
  • a isResolved attribute, which is false when the promise has been started but not yet resolved.
@dtheodor
dtheodor / api_suggestion.md
Last active August 29, 2015 14:23
Task callbacks, dependencies, cached results

Task callbacks, dependencies, cached results

Discussion on a celery API and implementation that solves

  1. Ability to dynamically add callbacks to already running tasks
  2. Tasks with dependencies
  3. Caching/invalidating task results
  4. Being able to stop/restart a task

Async result that allows adding callbacks

@dtheodor
dtheodor / oracle_ubuntu_sqlalchemy.md
Last active August 29, 2015 14:23
Oracle on ubuntu with python/sqlalchemy

Oracle with SQLAlchemy on Ubuntu

Installation

Download and install all instant client rpms from the Oracle website. For version 11.2.0.4.0 you probably need at least

oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm

Jenkins stuff

Ideas on what to do per build, when to trigger builds, etc.

Basic build per project

  • compile
    • triggers build failure
  • run unittests
  • triggers build unstable