Skip to content

Instantly share code, notes, and snippets.

View dwcaraway's full-sized avatar

Dave Caraway dwcaraway

  • Microsoft
  • Virginia
  • 08:28 (UTC -05:00)
View GitHub Profile
@dwcaraway
dwcaraway / example.js
Created November 14, 2018 22:25
example for tenet3 voyager API
var Voyager = require('voyager');
var defaultClient = Voyager.ApiClient.instance;
// Configure API key authorization: api_key
var api_key = defaultClient.authentications['api_key'];
api_key.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//api_key.apiKeyPrefix['api_key'] = "Token"
@dwcaraway
dwcaraway / Embeded ESL
Created October 17, 2014 14:14
Embeds the Code for Dayton English-As-A-Second-Language app using an iframe
<html>
<head>
</head>
<body>
<iframe allowtransparency="true" src='http://codefordayton.org/esl/' frameborder="0" style="width:100%; height:600px; border:none;" scrolling="yes">
</body>
</html>
@dwcaraway
dwcaraway / model_dictize.py
Created January 28, 2014 05:17
this is causing formats like application/json to be forced into string JSON
def _unified_resource_format(format_):
''' Convert resource formats into a more uniform set.
eg .json, json, JSON, text/json all converted to JSON.'''
format_clean = format_.lower().split('/')[-1].replace('.', '')
formats = {
'csv' : 'CSV',
'zip' : 'ZIP',
'pdf' : 'PDF',
'xls' : 'XLS',
@dwcaraway
dwcaraway / package.py
Created December 11, 2013 18:45
https://github.com/GSA/enterprise-data-inventory/issues/34: Problem of resource being required for all datasets
if not data_provided and save_action != "go-dataset-complete":
if save_action == 'go-dataset':
# go to final stage of adddataset
redirect(h.url_for(controller='package',
action='edit', id=id))
# see if we have added any resources
try:
data_dict = get_action('package_show')(context, {'id': id})
except NotAuthorized:
abort(401, _('Unauthorized to update dataset'))
@dwcaraway
dwcaraway / data.json
Last active December 28, 2015 22:28
Valid data.json / Common Core Metadata entry
[{
"title": "Data Catalog",
"description": "Version 1.0",
"contactPoint": "somebody important",
"keyword": ["catalog"],
"modified": "2013-05-09 06:00:00",
"publisher": "US Department of X",
"person": "Contact Person",
"mbox": "[email protected]",
"language": ["aav"],
@dwcaraway
dwcaraway / lang.py
Created November 20, 2013 20:06
Python script to generate a Javascript regular expression (regex) for BCP 47 / RFC 5646, a port of http://stackoverflow.com/questions/7035825/regular-expression-for-a-language-tag-as-defined-by-bcp47
regular = "(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang)"
irregular = "(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)"
grandfathered = "(" + irregular + "|" + regular + ")"
privateUse = "(x(-[A-Za-z0-9]{1,8})+)"
singleton = "[0-9A-WY-Za-wy-z]"
extension = "(" + singleton + "(-[A-Za-z0-9]{2,8})+)"
variant = "([A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3})"
region = "([A-Za-z]{2}|[0-9]{3})"
script = "([A-Za-z]{4})"
extlang = "([A-Za-z]{3}(-[A-Za-z]{3}){0,2})"
@dwcaraway
dwcaraway / test.py
Created November 20, 2013 03:19
trying to help debug weird error with ckan spatial extension.
import ckanext.spatial.validation.validation as v
from lxml import etree
TEST_FILE = 'satellite-systems_dscovr.xml'
with open(TEST_FILE, 'r') as f:
xmlobj = etree.XML(f.read())
validator = v.ISO19139NGDCSchema()
print(validator.is_valid(xmlobj))
{% if show_organizations_selector %}
{% set existing_org = data.owner_org %}
<div class="control-group">
<label for="field-organizations" class="control-label">{{ _('Organization') }}</label>
<div class="controls">
<select id="field-organizations" name="owner_org" data-module="autocomplete">
<option value="" {% if not selected_org and data.id %} selected="selected" {% endif %}>{{ _('Select an organization...') }}</option>
{% for organization in organizations_available %}
{# get out first org from users list only if there is not an existing org #}
{% set selected_org = (existing_org and existing_org == organization.id) or (not existing_org and not data.id and organization.id == organizations_available[0].id) %}
def default_create_package_schema():
schema = {
'__before': [duplicate_extras_key, ignore],
'id': [empty],
'revision_id': [ignore],
'name': [not_empty, unicode, name_validator, package_name_validator],
'title': [if_empty_same_as("name"), unicode],
'author': [ignore_missing, unicode],
'author_email': [ignore_missing, unicode],
'maintainer': [ignore_missing, unicode],