Skip to content

Instantly share code, notes, and snippets.


Eric Gardner egardner

View GitHub Profile
egardner / Dockerfile
Last active Mar 1, 2019
Basic MW dev environment with Docker
View Dockerfile
# Put this in web/Dockerfile
# Adapted from
FROM php:7.2-apache
# System Dependencies.
RUN apt-get update && apt-get install -y \
git \
imagemagick \
libicu-dev \
egardner / epub.rake
Last active Oct 22, 2018
Work in progress Epub Parser in Ruby
View epub.rake
# lib/tasks/epub.rake
require "pathname"
namespace :epub do
desc "Import data from a target epub file"
task import: :environment do
path =
raise ArgumentError, "Please provide a path to a valid EPUB file." unless path.exist?

HTML Unroller

This script is a basic "proof-of-concept" implementation of a parsing tool that can "unroll" or flatten an HTML document into a simple JSON representation. Inspired by the Prosemirror document model.

There are two things which allow for the simplified output:

  1. We don't care about every HTML element, just a limited "whitelist"
  2. Text-level elements are represented as a linear sequence (in a real-world version, each text item would need some kind of attributes or properties field to indicate
egardner /
Last active Mar 17, 2018
Vuex action test examples

Testing actions in Vuex

In Vuex, Actions are analagous to Reducers in Redux. They are functions which can contain asynchronous operations, but they do not manipulate any state in the store directly. Instead, they can only commit mutations, which are synchronous functions that replace an existing store value with a new one.

Since Actions can potentially contain some complicated logic (like deciding which mutation or series of mutations should be committed), they are a good candidate for unit tests. Here is an example of how to do this following the suggestions in the Vuex docs.

egardner / manifest.rb
Last active Sep 18, 2017
Quick and dirty IIIF Manifest generator (WIP)
View manifest.rb
require 'json'
require 'fastimage'
# Quick and dirty IIIF Manifest Generator
# Initial values
# ==============================================================================
work_title = 'Concert for Piano and Orchestra: Solo for Piano'
work_author = 'John Cage'
work_publisher = 'Stony Point, N.Y.: Herman Press, c1960'
egardner / titles.txt
Created Aug 15, 2017
Pubs Repo: Editions with diverging catalog_copy and jacket_copy
View titles.txt
A Confederacy of Heretics -- 1st English Paperback Edition
A King Seen from the Sky -- 1st English Hardcover Edition
A Kingdom of Images -- 1st English Hardcover Edition
A Pocket Dictionary of Aztec and Mayan Gods and Goddesses -- 1st English Hardcover Edition
A Royal Passion -- 1st English Hardcover Edition
AD410 -- 1st English Hardcover Edition
Adolph Menzel -- 1st English Hardcover Edition
Amber and the Ancient World -- 1st English Hardcover Edition
American Painters on Technique -- 1st English Hardcover Edition
An ABC of What Art Can Be -- 1st English Hardcover Edition
View .babelrc
"presets": ["babel-preset-expo"],
"env": {
"development": {
"plugins": ["transform-react-jsx-source"]
egardner / App.js
Created Jun 1, 2017
Simple React Native app
View App.js
import React from 'react';
import { StyleSheet, Text, View, WebView } from 'react-native';
import { TabNavigator } from 'react-navigation';
import Icon from 'react-native-vector-icons/SimpleLineIcons';
// Icons & styles
const homeIcon = (<Icon name="home" size={24} />);
const globeIcon = (<Icon name="globe-alt" size={24} />);
const recentIcon = (<Icon name="rocket" size={24} />);
egardner / deepequal.js
Created May 22, 2017
Simple deep equality comparison in Javascript (ES5+)
View deepequal.js
// Deep Equality comparison example
// This is an example of how to implement an object-comparison function in
// JavaScript (ES5+). A few points of interest here:
// * You can get an array of all an object's properties in ES5+ by calling
// the class method Object.keys(obj).
// * The function recursively calls itself in the for / in loop when it
// compares the contents of each property
// * You can hide a "private" function inside a function of this kind by
egardner / app.js
Created Jan 17, 2017
Feedr AJAX request example
View app.js
// URLs: let's stash these here and access later
var breitbartUrl = '';
var foxUrl = '';
var nytUrl = ''
// Let's stash our container div as a variable here so we can access it
You can’t perform that action at this time.