Skip to content

Instantly share code, notes, and snippets.

View schuyberg's full-sized avatar

Schuyler Lindberg schuyberg

  • The University of British Columbia
  • Vancouver, BC
View GitHub Profile
{
"@context": {
"@vocab": "http://purl.org/dc/elements/1.1/",
"dcterms": "http://purl.org/dc/terms/",
"dpla": "http://dp.la/terms/",
"edm": "http://www.europeana.eu/schemas/edm/",
"geo": "http://www.w3.org/2003/01/geo/wgs84_pos#",
"lcsh": "http://id.loc.gov/authorities/subjects/",
"ore": "http://www.openarchives.org/ore/terms/",
"skos": "http://www.w3.org/2004/02/skos/core#",
@schuyberg
schuyberg / dl-json-ld-collection-0.3.json
Last active December 13, 2017 11:35
Digital Library JSON-LD metadata model development
{
"@context" : "dl-json-ld-context-0.3.json",
"@id": "http://example.id/1234",
"@type": "dctypes:collection",
"_dl-id": "DL UID",
"_dl-type" : "collection",
"_created" : "COLLECTION CREATION TIMESTAMP",
@schuyberg
schuyberg / gist:034a9982bf8326c19fc9
Last active August 29, 2015 14:21
AngularJS & EnquireJS Media Query Service
// Example Service detects a max width of 400px
// use watch & unwatch functions to set or remove breakpoint listeners
// use ismatch & notmatch functions (callbacks) to act on breakpoint changes
services.factory('max400', ['$rootScope', '$timeout', function ($rootScope, $timeout) {
var max400 = {
watch: function() { enquire.register('screen and (max-width: 400px)', max400handler); },
unwatch: function() { enquire.unregister('screen and (max-width: 400px)'); },
ismatch: function(callback) { $rootScope.$on('match400', callback); },
@schuyberg
schuyberg / gist:2b5877f90a5f4bda5d4b
Last active August 29, 2015 14:22
AngularJS $rootScope.$emit service pattern
// pattern for creating servicesto communicate efficiently between angular components
services.factory('changeService', ['$rootScope',
function ($rootScope) {
var changeService = {};
// use changeService.changed(action) in controller to act on changes
changeService.changed = function(callback){
$rootScope.$on('change', callback);
/* AngularJS Print Service
thanks to Bahmni for the original code at https://github.com/Bhamni/openmrs-module-bahmniapps/blob/master/ui/app/common/ui-helper/printer.js
** modified here to work with ie10/11 */
services.factory('printer', [ '$rootScope', '$compile', '$http', '$timeout', 'utility', function ($rootScope, $compile, $http, $timeout, utility) {
var printHtml = function (html) {
var hiddenFrame = $('<iframe name="printframe" style="position: absolute; left: -9999px;"></iframe>').appendTo('body')[ 0 ];
var htmlContent = "<!doctype html>" +
'<head><meta http-equiv="X-UA-Compatible" content="IE=edge"></head>' +
// generates a table of contents
// blame @schuyberg 2016
//
//
// use on jquery object you want it appended before (usually first header)
// hStart = number: html heading level to start on (ie. 2 would be h2)
// depth = number: depth to traverse heading heirarchy (h2 + 1 = h2, h3)
// example: jQuery('h2').first().toc(2,1); --> adds contents before first h2 tag, includes h2, h3 tags.
$.fn.toc = function(hStart, depth){
@schuyberg
schuyberg / ProvinceState Arrays
Created September 11, 2017 21:33 — forked from james2doyle/ProvinceState Arrays
PHP array for states and Provinces in Canada and the US
$provinces = array(0 => 'Alberta',
1 => 'British Columbia',
2 => 'Manitoba',
3 => 'New Brunswick',
4 => 'Newfoundland and Labrador',
5 => 'Northwest Territories',
6 => 'Nova Scotia',
7 => 'Nunavut',
8 => 'Ontario',
9 => 'Prince Edward Island',
@schuyberg
schuyberg / clogs.php
Last active September 27, 2017 23:54
log to the JS console from PHP
// use this anywhere in your php app
function console_log() {
$messages = func_get_args();
if(!$GLOBALS['cLogs']){
$GLOBALS['cLogs'] = array();
}
$GLOBALS['cLogs'] = array_merge($GLOBALS['cLogs'], $messages);
}
// use this at the bottom of the global template (or wherever you can insert some js)
chmod 700 $HOME/.ssh
chmod go-w $HOME $HOME/.ssh
chmod 600 $HOME/.ssh/authorized_keys
chown `whoami` $HOME/.ssh/authorized_keys
@schuyberg
schuyberg / color-conversion-algorithms.js
Created December 14, 2017 20:18 — forked from mjackson/color-conversion-algorithms.js
RGB, HSV, and HSL color conversion algorithms in JavaScript
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param Number r The red color value
* @param Number g The green color value
* @param Number b The blue color value
* @return Array The HSL representation