Skip to content

Instantly share code, notes, and snippets.

View dmsnell's full-sized avatar

Dennis Snell dmsnell

View GitHub Profile
@dmsnell
dmsnell / calypsoComments.purs
Last active May 26, 2017 19:07
Building a description of the Comment object in Calypso
module Main where
import Prelude
import Data.Foldable (fold)
import Data.Generic
import Data.Maybe
import TryPureScript
data CommentId = CommentId Int
type DateTime = String {- this interactive editor doesn't have the right type -}
@dmsnell
dmsnell / gridReducer.js
Created January 5, 2017 18:59
Building independent reducers of inter-related data
const height = ( state = 8, { type, height } ) =>
'SET_HEIGHT' === type || 'RESET_BOARD' === type
? height
: state;
const width = ( state = 8, { type, width } ) =>
'SET_WIDTH' === type || 'RESET_BOARD' === type
? width
: state;
version: '2'
services:
wordpress:
image: wordpress
ports:
- 80:80
environment:
WORDPRESS_DB_PASSWORD: example
@dmsnell
dmsnell / fractal.bas
Created November 11, 2016 20:42
Drawing a fractal in BASIC
SCREEN 12
CLS
RANDOMIZE TIMER
maxx = 640
maxy = 480
x1% = INT(RND * maxx) + 1
y1% = INT(RND * maxy) + 1
TYPE VERTEX
XC AS DOUBLE
@dmsnell
dmsnell / generate.js
Created November 5, 2016 20:17
Generate a star composite
const childProcess = require( 'child_process' )
const fs = require( 'fs' )
const spawn = childProcess.spawn
const spawnSync = childProcess.spawnSync
const l = m => { console.log( m ); return m }
const needsDir = dir => ! fs.existsSync( dir ) && fs.mkdirSync( dir )
@dmsnell
dmsnell / docker-compose.yml
Last active October 5, 2016 23:22
WordPress docker compose configuration for local Jetpack dev
version: '2'
services:
wordpress:
image: wordpress
ports:
- 80:80
environment:
WORDPRESS_DB_PASSWORD: example
volumes:
@dmsnell
dmsnell / analyticsMiddleware.js
Last active April 12, 2016 16:19
Taking out the test-busters
import {
newTracksEvent
} from 'analytics/actions'
export const Doohickey = ( { recordClick, hotness } ) =>
<div onClick={ recordClick( 'dingos', { hotness } ) }>Dingos!</div>
const mapDispatchToProps = dispatch => ( {
recordClick: compose( dispatch, newTracksEvent )
} )
@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() {
@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 / 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' ],