Skip to content

Instantly share code, notes, and snippets.

View dmsnell's full-sized avatar

Dennis Snell dmsnell

View GitHub Profile
@dmsnell
dmsnell / generateWebVersions.sh
Last active August 29, 2015 14:24
Automatically generate web versions of high quality TIFF images placed in a given directory (with fswatch)
# Generates varying exports of a TIFF image
# for different web uses: one high quality
# image for Flickr and two scaled-down lower-quality
# versions for posting to blogs, Twitter, etc...
#
# Only operates on TIFF images because I wanted
# to preserve as much quality as I could until the
# end and also because I don't want to allow a loop
# on the output of this file triggering a new run.
#
var Immutable = require( 'immutable' );
var initialData,
updatedData,
partialData;
initialData = {
status: 200,
image: {
height: 64,
@dmsnell
dmsnell / webpagetest.org-codefortucson.org.json
Last active September 16, 2015 17:26
Performance test for codefortucson.org webpagetest.org before optimization milestone
{
"log": {
"version": "1.1",
"creator": {
"name": "WebPagetest",
"version": "2.18"
},
"pages": [
{
"startedDateTime": "2015-09-16T03:00:42.000+00:00",
@dmsnell
dmsnell / generate-linter-args.php
Last active October 22, 2015 03:28
Generate linter args from SVN repository
#!/usr/local/bin/php
<?php
/**
* Generates a structured list of files related to an
* SVN commit or working directory, or generates the
* diff between a particular SVN commit and its parent
* or between the working directory and the base revision.
*
* Calling:
@dmsnell
dmsnell / IntroToReact-TucsonJS.md
Created November 2, 2015 06:01
Presentation on React for TucsonJS, November 2015

How to React

and why you should


{
  "name": "Dennis Snell",
  "title": "Spline Reticulator",
  "company": "Automattic, Inc.",
@dmsnell
dmsnell / eagerOrLazy.js
Last active January 5, 2016 06:19
What will the following script spit out?
const l = m => console.log( m );
console.clear();
const a = () => { l( 'a ran' ); return 'a'; };
const b = () => { l( 'b ran' ); return 'b'; };
const c = false
? a()
: b();
@dmsnell
dmsnell / instanceConstructor.js
Created January 19, 2016 00:29
Creating an instance of a type class in JavaScript
const l = m => console.log( m );
function Maybe(v) {
this.value = v
}
Maybe.prototype.typeName = 'Maybe'
function Monad() {
this.value = null
@dmsnell
dmsnell / intervalsToNestedStructure.js
Created March 21, 2016 19:07
Takes a list of intervals with values and a string and chops up the string into a structured object containing those values.
"use strict"
const message = `The quick brown fox jumped over the lazy dog. What a jerk!`;
const intervals = [
[ 25, 32, 'strong' ],
[ 5, 9, 'a' ],
[ 26, 29, 'span' ],
[ 0, 0, 'img' ],
[ 32, 37, 'em' ],
@dmsnell
dmsnell / newWpcom.js
Created March 29, 2016 09:06
Thinking about inheritance patterns in a new and modern wpcom.js
'use strict'
const l = m => console.log( m )
const s = m => l( attempt( () => JSON.stringify( m ) ) )
const attempt = f => { try { return f() } catch (e) { return null } }
const wpcom = (() => {
const extender = a => Object.assign( {}, a, { extend: extend( a ) } )
const reducer = base => ( prev, builder ) =>
extender( Object.assign( {}, prev, builder( base ), { version: base.version + 1 } ) )
@dmsnell
dmsnell / test.js
Last active April 5, 2016 01:06 — forked from smoidu/test.js
const { Router,
Route,
IndexRoute,
Redirect,
Link,
IndexLink
} = ReactRouter
const Wrapper = React.createClass( {
render() {