Skip to content

Instantly share code, notes, and snippets.

View seanupton's full-sized avatar

Sean Upton seanupton

  • Mostscript, LLC
  • Salt Lake City, Utah USA
View GitHub Profile
#!/bin/bash
PROJPATH=/Users/sean/projects
SRCPATH=$PROJPATH/plotqi/build
PKGPATH=$PROJPATH/dev43/app/src/uu.chart
DESTPATH=$PKGPATH/uu/chart/browser/resources/plotqi
# copy assets from plotqi build to uu.chart resource directory:
cp $SRCPATH/plotqi.*s* $DESTPATH
@seanupton
seanupton / parsedate.js
Last active February 23, 2016 23:19
Parse date using moment, untested on most locales other than en-US (rev 2)
/*jshint browser: true, nomen: false, eqnull: true, es5:true, trailing:true,undef:true */
/*global jQuery, console, QUnit, COREMODELNS, window, alert */
var parsedate = (function (ns, moment) {
/** sensible date-parsing of human-entered date strings, using moment
* ALL TIMES UTC for sanity!
*/
"use strict";
var m = moment.utc,
@seanupton
seanupton / gist:9538b05b4d61dc5e9166f529e72cfc98
Created July 8, 2016 22:38
Mockup 2.3.0 (master), plone.app.widgets 1.x, Plone 4.3.x, jQuery 1.11.2: select2 pattern fails to initialize for both input and select elements (tags, language fields)
patterns.pat.select2: Failed while initializing 'select2' pattern. TypeError: self.$el.select2 is not a function
Stack trace:
Select2<.initializeSelect2@http://localhost:28080/policy3/portal_javascripts/Sunburst%20Theme/++resource++plone.app.widgets.js:20677:7
Select2<.init@http://localhost:28080/policy3/portal_javascripts/Sunburst%20Theme/++resource++plone.app.widgets.js:20756:7
Base@http://localhost:28080/policy3/portal_javascripts/Sunburst%20Theme/++resource++plone.app.widgets.js:15944:9
Base.extend/child@http://localhost:28080/policy3/portal_javascripts/Sunburst%20Theme/++resource++plone.app.widgets.js:15979:34
initBasePattern@http://localhost:28080/policy3/portal_javascripts/Sunburst%20Theme/++resource++plone.app.widgets.js:15932:27
registry.initPattern@http://localhost:28080/policy3/portal_javascripts/Sunburst%20Theme/++resource++plone.app.widgets.js:15771:25
executeBound@http://localhost:28080/policy3/portal_javascripts/Sunburst%20Theme/++resource++plone.app.widgets.js:13198:56
_.partial/bound@http://l
@seanupton
seanupton / deploy-plotqi.sh
Created October 29, 2016 03:00
iTerm2 3.x deploy applescript for copying from one repository to another
#!/bin/bash
PROJPATH=/Users/sean/projects
SRCPATH=$PROJPATH/plotqi/build
PKGPATH=$PROJPATH/dev43/app/src/uu.chart
DESTPATH=$PKGPATH/uu/chart/browser/resources/plotqi
# copy assets from plotqi build to uu.chart resource directory:
cp $SRCPATH/plotqi.*s* $DESTPATH
@seanupton
seanupton / patch.py
Created December 16, 2016 04:48
Monkey patch plone.autoform to make omitted fields exception for plone.schemaeditor listing
# monkey patch autoform to exempt schemaeditor from considering
# omitted fields
from plone.autoform import utils
from plone.autoform.interfaces import OMITTED_KEY
orig_mergedTaggedValuesForForm = utils.mergedTaggedValuesForForm
def mergedTaggedValuesForForm(schema, name, form):
if form.__class__.__name__ == 'SchemaListing' and name == OMITTED_KEY:
if &t_Co > 1
syntax enable
endif
set ts=4 et ruler number
set sw=4
set softtabstop=4 " insert/delete 4 spaces when hitting a TAB/BACKSPACE
set shiftround " round indent to multiple of 'shiftwidth'
set t_Co=256
highlight NonText ctermfg=234
call pathogen#infect()
@seanupton
seanupton / planning-20180103.rst
Last active January 2, 2018 20:08
Jan 3 2018 Planning

January 3 2018 Iteration Planning

Possible or Likely Tasks

  • Complete all metadata fields in specification, added to models.
    • Respective model, form classes updated accordingly.
@seanupton
seanupton / hyrax-resource-types-app-override.rst
Created January 30, 2018 16:40
Overriding Hyrax Resource Types / Random notes

Background

There is no need to define a service for resource_types, because hyrax already has one, and it reads the config/authorities/resource_types.yml file from one's app. There are a few gotchas with this:

  1. There is no caching of local vocabularies. Qa/Hyrax is going to hit disk and load a file for every field, every time you load a form. This could be a performance concern in any system that made use of forms more than trivial (ideally, there should be some kind of in-memory memoization of terms).
  2. There is no i18n at all for local vocabulary terms, generally. For our project, at this moment, this is YAGNI, but something to consider at some future date?
  3. Qa gem is supposed to allow for setting an active boolean on each term in the YML, which I was hoping to use to hide default hyrax terms. As this was not doing what I expected, I took the simpler route and just removed them.

Plan

@seanupton
seanupton / coord.json
Created February 27, 2018 17:00
Idea for word coordinate JSON?
{
"terms": ["all", "terms"],
"coordinates": {
"all": [
{
"page": "1",
"x": 300,
"y": 78,
"width": 34,
"height": 18
@seanupton
seanupton / actor_invoke.rb
Last active June 21, 2018 17:50
Calling Hyrax Actor stack from rails console
# make a work
work = Work.new
work.title = ['Here, there, everywhere']
user = User.new
# make an ability with a user:
user.id = 'me123'
user.email = 'me@example.com'
user.password = 'another'
ability = Ability.new(user)
# have some attributes for changes to apply