Skip to content

Instantly share code, notes, and snippets.

View telic's full-sized avatar

Maxwell Terpstra telic

  • Victoria, BC, Canada
View GitHub Profile
@telic
telic / Preferences.sublime-settings
Last active March 21, 2019 22:12
sublime-text preferences
{
"always_show_minimap_viewport": true,
"auto_find_in_selection": true,
"copy_with_empty_selection": false,
"default_line_ending": "unix",
"drag_text": false,
"ensure_newline_at_eof_on_save": true,
"find_selected_text": false,
"folder_exclude_patterns":
[
@telic
telic / greedymenu.js
Created April 24, 2017 02:04
A collapsing-menu enhancement script
/* eslint-env es6 */
/**
* Greedymenu - hides menu items that don't fit in a popup menu
*
* Automatically applies to to elements with MENU_CLASS or MENU_S_CLASS
* on document load. Also exports an initialization function (window.greedymenu)
* that can be used to transform nav lists explicitly.
*
* Inspired by http://codepen.io/lukejacksonn/pen/PwmwWV/
*
@telic
telic / throttle.js
Created April 24, 2017 01:30
Simple es6 throttle with leading and trailing-edge calls
function throttle(fn, threshold=250) {
let hold = false;
let trail;
let timeout = function() {
if (trail !== undefined) {
fn.apply(trail[0], trail[1]);
trail = undefined;
setTimeout(timeout, threshold)
} else {
hold = false;
@telic
telic / display-map.xq
Last active February 8, 2017 03:42
Display `map(*)` contents in eXide
declare function local:display-map($m as map(*)?) as element()? {
if (exists($m)) then
<map>{
for $k in map:keys($m) return
<key name="{$k}">{
for $v in $m($k) return
typeswitch ($v)
case document-node() return <document uri="{document-uri($v)}"/>
case attribute() return <attribute name="{name($v)}">{xs:string($v)}</attribute>
case map(*) return local:display-map($v)
@telic
telic / type.xq
Last active January 23, 2017 21:36
XQuery type name introspection
declare function local:type($item as item()?) as xs:string {
typeswitch ($item)
(: NOTE: eXist doesn't support XML Schema 1.1 types yet
case xs:dateTimeStamp return 'xs:dateTimeStamp'
:)
case xs:dateTime return 'xs:dateTime'
case xs:date return 'xs:date'
case xs:time return 'xs:time'
case xs:yearMonthDuration return 'xs:yearMonthDuration'
case xs:dayTimeDuration return 'xs:dayTimeDuration'
@telic
telic / GameOfLife.js
Last active August 29, 2015 14:17
lab8
/* d3 (d3js.org) */
!function(){function n(n){return n&&(n.ownerDocument||n.document||n).documentElement}function t(n){return n&&(n.ownerDocument&&n.ownerDocument.defaultView||n.document&&n||n.defaultView)}function e(n,t){return t>n?-1:n>t?1:n>=t?0:0/0}function r(n){return null===n?0/0:+n}function u(n){return!isNaN(n)}function i(n){return{left:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)<0?r=i+1:u=i}return r},right:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)>0?u=i:r=i+1}return r}}}function o(n){return n.length}function a(n){for(var t=1;n*t%1;)t*=10;return t}function c(n,t){for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}function l(){this._=Object.create(null)}function s(n){return(n+="")===pa||n[0]===va?va+n:n}function f(n){return(n+="")[0]===va?n.slice(1):n}function h(n){return s(n)in this._}function g(n){return(n=s(n))in this._&&delete this._[n]}f
@telic
telic / example.html
Last active August 29, 2015 14:14
Example HTML for COMP152 lab 5
<!DOCTYPE html>
<html>
<head>
<title>Lab 4</title>
</head>
<body>
<header>
<h1>Lab 4: HTML</h1>
David Bell-Brown<br/>Lab section: thebest
<nav>
@telic
telic / example.css
Created October 3, 2014 19:34
example CSS file for COMP 152 Lab 6
html {
background-color: #ddd;
padding: 0;
margin: 0;
}
body {
margin: 50px 200px;
padding: 0 3em 3em;
background-color: white;
border: 1px solid black;
@telic
telic / lab.css
Last active August 29, 2015 14:07
COMP 152 - Lab 6 CSS
/* basic structure */
h1, h2, h3, h4 { color: #3366ff; }
h2 { text-indent: .25em; }
h3 { text-indent: 1.5em; }
h2 small {
font-size: 75%;
font-weight: normal;
color: black;
display: inline;
margin-left: .5em;
@charset "utf-8";
hgroup {
background: linear-gradient(to bottom, black, black 24pt, rgba(0,0,0,.5));
color: white;
font-variant: small-caps;
font-weight: bold;
border-radius: 0 6px;
overflow: hidden;
padding: 0 10px;