Skip to content

Instantly share code, notes, and snippets.

@Joseph507
Joseph507 / sqlalchemy_parse.py
Created January 12, 2016 17:58
SQL Alchemy JSON Encoder
import decimal, datetime
def alchemyencoder(obj):
"""JSON encoder function for SQLAlchemy special classes."""
if isinstance(obj, datetime.date):
return obj.isoformat()
elif isinstance(obj, str):
return obj.strip()
elif isinstance(obj, decimal.Decimal):
return float(obj)
@Joseph507
Joseph507 / select2_helper.rb
Last active November 7, 2016 02:33 — forked from infertux/select2_helper.rb
Helper to select a Select2 item with Capybara/Cucumber
# spec/support/capybara/select2_helper.rb or features/support/select2_helper.rb
module Select2Helper
# @example
# select2 "Item", from: "select_id"
# select2 /^Item/, from: "select_id"
#
# @note Works with Select2 version 3.4.1.
def select2(text, options)
find("#s2id_#{options[:from]}").click