Skip to content

Instantly share code, notes, and snippets.

Avatar

Glen glen-84

  • Cape Town, South Africa
View GitHub Profile
@glen-84
glen-84 / index.ts
Created Apr 20, 2021
Koa middleware for Rendertron.
View index.ts
import axios from "axios";
import type {IncomingMessage} from "node:http";
import type {Middleware} from "koa";
/**
* A default set of user agent patterns for bots/crawlers that do not perform
* well with pages that require JavaScript.
*/
export const botUserAgents = [
// spell-checker:disable
@glen-84
glen-84 / gg-number-array.ts
Created Feb 13, 2019
Number array custom attribute
View gg-number-array.ts
import {autoinject, bindingMode, customAttribute} from "aurelia-framework";
/**
* Ensures that array elements are numbers.
*
* TODO: Using this custom attribute because value converters and binding behaviors are not working well with
* multi-select elements. See https://github.com/aurelia/binding/issues/611.
*/
@autoinject
@customAttribute("gg-number-array", bindingMode.twoWay)
@glen-84
glen-84 / app.html
Last active Aug 21, 2017 — forked from jdanyow/app.html
Aurelia set select options and value
View app.html
<template>
<h1>Instructions</h1>
<ol>
<li>Click the "Set value" button (selected option changes correctly)</li>
<li>Increment number to 3</li>
<li>Click the "Set options and value" button (selected option is not set correctly)</li>
</ol>
<select value.bind="matchGame.winner.id">
@glen-84
glen-84 / app.html
Created Mar 5, 2017 — forked from PWKad/app.html
DI inheritance
View app.html
<template>
<h1>Dialog Repro</h1>
<button click.delegate="submit()">Open Dialog</button>
</template>
View app.html
<template>
<require from="./select2-custom-attribute"></require>
<require from="./debug"></require>
<h1>Standard Select</h1>
<select value.bind="selectedThings" style="width: 100%">
<option repeat.for="thing of things" model.bind="thing">${thing.name}</option>
</select>
<h1>Select2</h1>
View letter-to-dc.txt
Hi,
I'm noticing that a disturbing number of package managers[1] and other software projects[2] are making use of JSON as a
configuration format, which is starting to bother me (probably more than it should), since JSON is a data serialization
format, and was not intended for this purpose (as I understand it).
Have you considered writing a new specification for a format that is more suited to such uses? Something similar to
JSON5 or YAML. YAML is pretty cool, but people don't like/use it because (I assume):
1. It has a stupid name.
View typings.d.ts
// Note: The definitions below are incomplete, they are just used to satisfy the TypeScript compiler for now.
declare module "glob2base" {
var glob2base: any;
export = glob2base;
}
declare module "gulp" {
var gulp: any;
export = gulp;
View gulpfile.js
var gulp = require("gulp");
var browserSync = require("browser-sync").create();
var swagger = require("swagger-parser");
var fs = require("fs");
gulp.task("serve", function() {
browserSync.init({
open: false,
server: {
baseDir: "./",
View gist:dc86ea06cdbd99d72598
@font-face {
font-family: 'icomoon';
src: url(data:application/x-font-ttf;charset=utf-8;base64,AAEAAAALAIAAAwAwT1MvMg8SDgQAAAC8AAAAYGNtYXAPfuIIAAABHAAAAExnYXNwAAAAEAAAAWgAAAAIZ2x5ZuM5hHAAAAFwAAABXGhlYWQEEsiwAAACzAAAADZoaGVhBgsDyQAAAwQAAAAkaG10eAluACUAAAMoAAAAIGxvY2EBPADgAAADSAAAABJtYXhwAAoAFgAAA1wAAAAgbmFtZVcZpu4AAAN8AAABRXBvc3QAAwAAAAAExAAAACAAAwQAAZAABQAAApkCzAAAAI8CmQLMAAAB6wAzAQkAAAAAAAAAAAAAAAAAAAABEAAAAAAAAAAAAAAAAAAAAABAAADw2gPA/8AAQAPAAEAAAAABAAAAAAAAAAAAAAAgAAAAAAACAAAAAwAAABQAAwABAAAAFAAEADgAAAAKAAgAAgACAAEAIPDa//3//wAAAAAAIPDX//3//wAB/+MPLQADAAEAAAAAAAAAAAAAAAEAAf//AA8AAQAAAAAAAAAAAAIAADc5AQAAAAABAAAAAAAAAAAAAgAANzkBAAAAAAEAAAAAAAAAAAACAAA3OQEAAAAAAQAAAQACSQJJABMAAAEUBwEGIyInASY1NDc2MyEyFxYVAkkL/wALDg8L/wALCwsPAgAOCwsCJQ8L/wALCwEACw8OCwsLCw4AAQAAANsCSQIlABMAAAEUBwYjISInJjU0NwE2MzIXARYVAkkLCw7+AA8LCwsBAAsPDgsBAAsBAA8LCwsLDw8LAQALC/8ACw8AAQAlAJIBbgLbABMAAAERFAcGIyInASY1NDcBNjMyFxYVAW4LCw8PC/8ACgoBAAsPDwsLArf+AA8LCwsBAAsPDwsBAAoKCw8AAQAAAJIBSQLbABMAAAEUBwEGIyInJjURNDc2MzIXARYVAUkL/wALDg8LCwsLDw4LAQA
@glen-84
glen-84 / LazySaveHandler.php
Last active Dec 16, 2015
Lazy session handler for ZF2
View LazySaveHandler.php
<?php
namespace Apex\Session;
use Zend\Session\SaveHandler\SaveHandlerInterface;
/**
* Based on https://github.com/adamfranco/lazy_sessions/blob/master/lazy_sessions.php
*
* @author Glen