Skip to content

Instantly share code, notes, and snippets.

View duhaime's full-sized avatar

Douglas Duhaime duhaime

View GitHub Profile
rbenv local 2.4.1
gem install jekyll
jekyll new hello
jekyll new-theme hello-theme
vim copy-theme.rb
```
require 'fileutils'
sudo yum groupinstall "Development Tools" -y
###
# Node
###
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash
. ~/.nvm/nvm.sh
nvm install 9.2.0
node -v
# get Let's Encrypt client
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
# pass domain to -d; must be a bound domain, not a raw IP
sudo ./certbot-auto --debug -v --server https://acme-v01.api.letsencrypt.org/directory certonly -d MYDOMAIN.PARTY
# on ec2, use the second option (temporary webserver) when prompted for a method
# within the app, replace all requests for http endpoints/assets with requests to https
from __future__ import division
from sklearn.cluster import KMeans
from numbers import Number
from pandas import DataFrame
import skfuzzy as fuzz
import sys, codecs, numpy
class autovivify_list(dict):
'''Pickleable class to replicate the functionality of collections.defaultdict'''
def __missing__(self, key):
@duhaime
duhaime / app.js
Last active August 12, 2018 20:45
Simple payments with Node + Stripe
var express = require('express')
var bodyParser = require('body-parser')
var path = require('path')
// payments
var keyPublishable = 'PUT YOUR TEST PUBLISHABLE KEY HERE (THIS STARTS WITH pk_)'
var keySecret = 'PUT YOUR TEST SECRET KEY HERE (THIS STARTS WITH sk_)'
var stripe = require('stripe')(keySecret)
// server
@duhaime
duhaime / index.html
Last active June 22, 2017 13:14
Carto data with Leaflet Interactions Sample
<!-- from: http://duspviz.mit.edu/web-map-workshop/databases-leaflet-cartodb/ -->
<!DOCTYPE html>
<html>
<head>
<title>Cambridge Coffee Shops</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css" />
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
@duhaime
duhaime / cache-positions.js
Created May 29, 2017 19:08
Cache node positions
document.querySelectorAll('.node').forEach(function(d){
console.log(d.id, d.getAttribute('cx'), d.getAttribute('cy'))
})
@duhaime
duhaime / index.html
Last active July 10, 2017 17:27 — forked from rfriberg/index.html
San Juan Island - Interactivity Demo (Tangram.js)
<!DOCTYPE html>
<html lang="en">
<head>
<title>San Juan Island Geology - Interactivity</title>
<meta charset="utf-8">
<link rel="stylesheet" href="https://mapzen.com/js/mapzen.css">
<script src="https://mapzen.com/js/mapzen.min.js"></script>
<style>
#map {
height: 100%;
@duhaime
duhaime / index.html
Last active July 10, 2017 17:26
London Printers, 1473-1800 (Tangram.js)
<!doctype html>
<html lang='en-us'>
<head>
<meta charset='utf-8'>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no'>
<title>Mapping Early English Books</title>
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.1/leaflet.css' />
<script type='text/javascript' src='https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.1/leaflet.js'></script>
<script type='text/javascript' src='https://cdn.rawgit.com/mlevans/leaflet-hash/master/leaflet-hash.js'></script>
{"Aberdare": "Mid Glamorgan", "Aberdeen": "Aberdeenshire", "Aberdovey": "Gwynedd", "Abergavenny": "Gwent", "Abergele": "Clwyd", "Abertillery": "Gwent", "Aberystwyth": "Dyfed", "Abingdon": "Oxfordshire", "Accrington": "Lancashire", "Airdrie": "Lanarkshire", "Alcester": "Warwickshire", "Aldeburgh": "Suffolk", "Alderley Edge": "Cheshire", "Aldershot": "Hampshire", "Alfreton": "Derbyshire", "Alness": "Ross-shire", "Alnwick": "Northumberland", "Alresford": "Hampshire", "Alston": "Cumbria", "Alton": "Hampshire", "Altrincham": "Cheshire", "Ambleside": "Cumbria", "Amersham": "Buckinghamshire", "Amesbury": "Wiltshire", "Ammanford": "Carmarthenshire", "Andover": "Hampshire", "Anstruther": "Fife", "Antrim": "Co Antrim", "Appleby-in-Westmorland": "Cumbria", "Arbroath": "Angus", "Ardrossan": "Ayrshire", "Armagh": "Co Armagh", "Arthog": "Gwynedd", "Arundel": "West Sussex", "Ascot": "Berkshire", "Ashbourne": "Derbyshire", "Ashburton": "Devon", "Ashford": "Middlesex", "Ashington": "Northumberland", "Ashtead": "Surrey", "Asht