Skip to content

Instantly share code, notes, and snippets.

View heymatthenry's full-sized avatar

Matt Henry heymatthenry

View GitHub Profile
@heymatthenry
heymatthenry / d3-histogram.js
Last active April 8, 2018 21:57
Simple histogram to get the hang of d3's histogram layout method
import * as d3 from 'd3';
let normals = []
for (let i = 0; i < 10000; i++) normals.push(d3.randomNormal()())
const drawingArea = { w: 800, h: 600 }
const margin = { top: 20, right: 20, bottom: 20, left: 20 }
const binWidth = 10
const x = d3.scaleLinear()
@heymatthenry
heymatthenry / teDuedate.py
Last active January 4, 2016 20:29
Script to be run as a TextExpander snippet that creates a due date tag from a natural language date string.
#!/usr/local/bin/python
# Requires parsedatetime module:
# https://github.com/bear/parsedatetime
import parsedatetime as pdt
natLangDateStr = "%filltext:name=date:default=today%"
dt = pdt.Calendar().parse(natLangDateStr)[0]

The coming S3pocalypse

  • We currently use one S3 bucket for each client. We have about 70 buckets in use. Amazon limits accounts to 100 buckets. Is there a need to use separate buckets for each client? Can we just create another S3 account?

One bucket per client or one bucket per environment

  • As I understand it, the reason we've used a bucket for each client in the past has been so we could keep track of how much bandwidth each client uses. I don't know if this anybody has done this or currently does this, but as we run up against our hundred-bucket limit, we'll need an alternative.
  • The way forward is probably to create a bucket for each environment (local dev, development, qa, staging, & prodction). Actually, we'll likely want to have a 'draft' bucket for each of those environments to hold pre-publication assets. Alternatively there could be a 'drafts' folder in each bucket instead of creating a whole separate bucket.
  • If we do implement 'drafts' feature, we'll have to add some workflow functiona
@heymatthenry
heymatthenry / gist:2219614
Created March 27, 2012 19:41
Schema for data returned from feed API
{
"feed" : {
"title" : "The feed's name",
"items" : [{
"author" : "Author's name",
"content" : "The full text/html content of the feed item",
"description" : "Item synopsis",
"media" : {
"type" : "The MIME type of the media item",
"url" : "URL for media resource",
@heymatthenry
heymatthenry / iframe-index.html
Created February 15, 2012 18:22
Minimum test case for an iframe with a remote src pointing at an ad tag. The behavior we'd like to see is for links inside the iframe to open in the Android browser. Currently they just open inside the iframe (as you might expect). Changing the target att
<!DOCTYPE HTML>
<html>
<head>
<title>PhoneGap</title>
<script type="text/javascript" charset="utf-8" src="phonegap-1.4.1.js"></script>
</head>
<body>
<iframe src="http://mwhenry.com/ad.html" />
</body>
</html>
@heymatthenry
heymatthenry / txjs.md
Created June 15, 2011 14:31 — forked from dce/txjs.md

TXJS

Doug Crockford:

  • '{' on same line (for returning obj. literals)
  • Javascript gives you lots of ways to do things. You should do it the way that causes the least confusion and the fewest errors.

Brendan Eich:

@heymatthenry
heymatthenry / quix_commands.txt
Created April 27, 2010 00:26
My custom quix commands
>
> Quix command syntax reference: http://quixapp.com/syntax/
> Roll your own bookmarklet: http://quixapp.com/extend/
>
@greenideas's custom commands
i javascript:function%20iprl5(){var%20d=document,z=d.createElement('scr'+'ipt'),b=d.body;try{if(!b)throw(0);d.title='(Saving...)%20'+d.title;z.setAttribute('src','http://www.instapaper.com/j/SINXm2AswnG2?u='+encodeURIComponent(d.location.href)+'&t='+(new%20Date().getTime()));b.appendChild(z);}catch(e){alert('Please%20wait%20until%20the%20page%20has%20loaded.');}}iprl5();void(0) Save to Instapaper
t tweetie:%s New tweet with selected text
@heymatthenry
heymatthenry / lambda.js
Created January 3, 2010 19:29
Compare & contrast how different languages use lambdas
(function(x){return x*x})(3)