Skip to content

Instantly share code, notes, and snippets.

View davidrleonard's full-sized avatar

David Leonard davidrleonard

View GitHub Profile
@davidrleonard
davidrleonard / opendataresource
Created October 15, 2014 23:49
Open data resources
x
@davidrleonard
davidrleonard / gist:59ecc9f12ee596df70d5
Created January 7, 2015 20:58
Jekyll/Liquid: Iterate over array in include
{% assign similar-speakers = 'catherine-bracy|michal-migurski' | split: '|' %}
<section class="layout-semibreve">
{% for entries in similar-speakers %}
{% for speaker in entries %}
<div class="layout-minim">{% include people/{{ speaker }}.html context="speaker-card" base=".." %}</div>
{% endfor %}
{% endfor %}
@davidrleonard
davidrleonard / gist:0fc96dacfda6b6ad5828
Created January 7, 2015 21:28
Jekyll/Liquid: Create fake-ish hash
{% assign test-topics = 'topic-one\Topic One|topic-two\Topic Two|topic-three\Topic Three' | split: '|' %}
{% for entries in test-topics %}
{% for topic in entries %}
<!-- topic = 'topic-one\Topic One' -->
<p>First: {{ topic | split: '\' | first }}</p><!-- First: topic-one -->
<p>Second: {{ topic | split: '\' | last }}</p><!-- Second: topic-two -->
{% endfor %}
{% endfor %}
@davidrleonard
davidrleonard / gist:0d9c2d81421b4c070849
Created April 6, 2015 20:51
Public Marketing Ducksboard
https://public.ducksboard.com/ijVTcgIdKtPzVyqY0BU0/
@davidrleonard
davidrleonard / csv-difference.py
Last active November 1, 2016 21:03
Compare two CSVs, output the difference between them
# Compares two CSVs and outputs a new CSV that excludes the intersection
# i.e.:
# $ python csv-difference.py -d fulldataset.csv -s subset.csv -o output.csv -u id -k id email name
import argparse
from csv import DictReader
from csv import DictWriter
def main():
parser = argparse.ArgumentParser(description='Output difference in CSVs.')
@davidrleonard
davidrleonard / eventbrite_copy_codes_snippet.js
Last active April 28, 2016 03:20
Eventbrite snippet - Copy all discount codes for event by scraping DOM
// Visit the Eventbrite discount/access code page for your event
// Expand the discount code table
// Open your JavaScript developer console and dump this code in
// Get the discount table rows
var t = $('#table_discount').find('tbody').find('tr');
// Create an array to hold the codes
var codes = new Array;
@davidrleonard
davidrleonard / 1-steps.md
Last active December 8, 2016 00:53
Upgrade Px element to Polymer 2.0

Step-by-step upgrade from Polymer 1.6 -> 2.0

Before you start

  1. Install Polymer/polymer#2.0-preview bower package and webcomponents/webcomponentsjs#v1 bower package
$ bower install --save Polymer/polymer#2.0-preview
$ bower install --save webcomponents/webcomponentsjs#v1
@davidrleonard
davidrleonard / execAsync.js
Last active November 29, 2022 03:42
Node exec async (with shell.js and bluebird)
const Promise = require('bluebird');
const sh = require('shelljs');
/**
* Asynchronously executes a shell command and returns a promise that resolves
* with the result.
*
* The `opts` object will be passed to shelljs's `exec()` and then to Node's native
* `child_process.exec()`. The most commonly used opts properties are:
*
@davidrleonard
davidrleonard / distribute-properties.js
Created March 1, 2017 18:50
Polymer behavior to distribute properties on lazily added Light DOM children
/**
* When light DOM children are distributed into a `px-map` framework component,
* that component will often have to share a reference to one of its properties
* with the child. This behavior wraps around that use case, ensuring that
* properties will be applied to any distributed light DOM children and that
* changes to those properties on the parent will trigger a re-distribution
* to the children that keeps them up-to-date.
*
* Distributions should be configured in the component's Polymer constructor
* in a similar way to the `observers` block provided by the Polymer library.
@davidrleonard
davidrleonard / 1-repeat-markers.html
Last active March 27, 2017 17:43
Create px-map markers with a dom-bind and dom-repeat
<!--
In this example, we use a template dom-repeat to insert multiple markers into a map
from an array of simple objects. This is a way to use markers and other components
without feeding in a complex blob of GeoJSON.
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Map 1 Demo -- Simple Map</title>