Skip to content

Instantly share code, notes, and snippets.

Avatar

Dennis Snell dmsnell

View GitHub Profile
@dmsnell
dmsnell / generateWebVersions.sh
Last active Aug 29, 2015
Automatically generate web versions of high quality TIFF images placed in a given directory (with fswatch)
View generateWebVersions.sh
# 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.
#
View ImmutableTest.js
var Immutable = require( 'immutable' );
var initialData,
updatedData,
partialData;
initialData = {
status: 200,
image: {
height: 64,
@dmsnell
dmsnell / webpagetest.org-codefortucson.org.json
Last active Sep 16, 2015
Performance test for codefortucson.org webpagetest.org before optimization milestone
View webpagetest.org-codefortucson.org.json
{
"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 Oct 22, 2015
Generate linter args from SVN repository
View generate-linter-args.php
#!/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 Nov 2, 2015
Presentation on React for TucsonJS, November 2015
View IntroToReact-TucsonJS.md

How to React

and why you should


{
  "name": "Dennis Snell",
  "title": "Spline Reticulator",
  "company": "Automattic, Inc.",
@dmsnell
dmsnell / eagerOrLazy.js
Last active Jan 5, 2016
What will the following script spit out?
View eagerOrLazy.js
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 Jan 19, 2016
Creating an instance of a type class in JavaScript
View instanceConstructor.js
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 Mar 21, 2016
Takes a list of intervals with values and a string and chops up the string into a structured object containing those values.
View intervalsToNestedStructure.js
"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 Mar 29, 2016
Thinking about inheritance patterns in a new and modern wpcom.js
View newWpcom.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 } ) )
View test.js
const { Router,
Route,
IndexRoute,
Redirect,
Link,
IndexLink
} = ReactRouter
const Wrapper = React.createClass( {
render() {