Skip to content

Instantly share code, notes, and snippets.

View egardner's full-sized avatar

Eric Gardner egardner

View GitHub Profile
@egardner
egardner / index.html
Created January 11, 2017 00:52
p5js Basic animated lines (I Ching)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.6/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.6/addons/p5.dom.min.js"></script>
</head>
<body>
@egardner
egardner / example.js
Last active November 21, 2016 02:11
Working with Github API in node
// Use the Github Node library
// Optional: use the Bluebird promise library to handle responses
var GitHubApi = require('github')
var gh = new GitHubApi({
debug: true,
Promise: require('bluebird')
})
// Get a User's public repos
// Repos is a Bluebird Promise object. Traditional callback approach also works here.
@egardner
egardner / README.md
Created October 24, 2016 22:48
Leaflet DZT Example

Leaflet DZT Example

This is a quick example showing how to get Leaflet to handle image tile output generated by the Ruby DZT library, using Leaflet-Deepzoom as a bridge. For the time being only Leaflet 0.7.7 is supported, not the latest version.

Assuming you have a folder called images containing the image you want:

dzt slice images/image-file.jpg --output=tiles --format=jpg --tile-size=256 --overwrite=true
@egardner
egardner / setup.md
Created June 1, 2016 23:35
Dev Environment Setup

Ruby Dev Environment Setup on OSX

Thoughtbot's Laptop Script is an excellent place to start. Using this script removes the need to do any of the steps below except for the final one. If you plan to set up manually, install the following tools (in this order):

  • Xcode Command-line tools (xcode-select --install), or all of Xcode if running on Mac OSX 10.8 or lower
  • Homebrew package manager
@egardner
egardner / Gemfile
Created May 4, 2016 01:09
Middleman Sprockets error stacktrace
# If you do not have OpenSSL installed, change
# the following line to use "http://"
source "https://rubygems.org"
# Uncomment these gems if you are using Windows
# gem "wdm", "~> 0.1.0", platforms: [:mswin, :mingw]
# gem "tzinfo-data", platforms: [:mswin, :mingw, :jruby]
gem "bourbon", "~> 4.2"
gem "middleman", "~> 4.0"
@egardner
egardner / Gemfile
Created February 29, 2016 18:20
Middleman Build Failure errors
source "https://rubygems.org"
# Uncomment these gems if you are using Windows
# gem "wdm", "~> 0.1.0", platforms: [:mswin, :mingw]
# gem "tzinfo-data", platforms: [:mswin, :mingw, :jruby]
gem "bourbon", "~> 4.2"
gem "middleman", "~> 4.0"
gem "middleman-autoprefixer", "~> 2.6"
gem "middleman-deploy", "= 2.0.0.pre.alpha"
@egardner
egardner / print.scss
Created February 18, 2016 22:24
Starter print stylesheet (for Prince XML)
// Variables
// -----------------------------------------------------------------------------
$page-width: 8.5in;
$page-height: 11in;
$bleed: 0.125in;
$bleed-height: 11.25in;
$bleed-width: 8.75in;
$bottom-margin: 1in;
@egardner
egardner / spec_helper.rb
Created February 10, 2016 20:11
Middleman v4 Testing Setup
require "middleman"
require "middleman/rack"
require "middleman-core/rack"
require "rspec"
require "capybara/rspec"
require "capybara/webkit"
module MiddlemanApplication
extend RSpec::SharedContext
@egardner
egardner / method.rb
Created February 4, 2016 02:23
Assignment Branch Condition
# Get Catalogue Sections
# Returns 3 arrays of resource objects (frontmatter, catalogue, backmatter)
def catalogue_sections
contents = sort_catalogue_contents
frontmatter = contents.find_all { |p| p.data.sort_order <= 10 }
backmatter = contents.find_all { |p| p.data.sort_order > 100 }
catalogue = contents.find_all do |p|
p.data.sort_order > 10 && p.data.sort_order <= 100
end
@egardner
egardner / index.html
Last active December 11, 2015 04:29 — forked from anonymous/index.html
A basic working example of using a more OOP pattern to wrap Leaflet's API. source http://jsbin.com/yudenugugu
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
#map {
height: 800px;