Skip to content

Instantly share code, notes, and snippets.

View kohlmannj's full-sized avatar

Joseph Kohlmann (he/him) kohlmannj

View GitHub Profile
@kohlmannj
kohlmannj / opml-generator.ts
Created November 1, 2019 22:57
Sketch of a TypeScript version of https://npm.im/opml-generator
/* eslint-disable no-underscore-dangle */
import xml from 'xml'
/**
* Created by azu on 2014/01/18.
* LICENSE : MIT
* @see https://github.com/azu/opml-generator
*/
/**
@kohlmannj
kohlmannj / sceneHasLights.ts
Created April 23, 2019 02:59
A Three.js helper function which determines if the given scene contains lights
import * as THREE from 'three';
/**
* Determine if the given scene contains any lights, i.e. objects
* that are subclasses of the `THREE.Light` abstract base class.
*
* @param scene the scene to check for lights
*
* @returns whether or not the scene contains lights
*/
{
"parser": "babel-eslint",
"extends": [
"airbnb",
"prettier",
"prettier/react"
],
"plugins": [
"jest",
"json",
@kohlmannj
kohlmannj / customDevServer.js
Created July 9, 2017 22:43
An example of using BrowserSync, webpack-dev-middleware, and webpack-hot-middleware together in a script that boots up a custom dev server
#! /usr/bin/env node
/* eslint-env node */
// Boot it up with:
// $ node customDevServer.js
// ...or:
// $ chmod +X customDevServer.js
// $ ./customDevServer.js
const webpack = require('webpack');
@kohlmannj
kohlmannj / RuntimeSingletonComponent.jsx
Last active July 3, 2017 19:10
A React class component that loads a runtime library on componentDidMount(), but only once for multiple instances.
import React, { Component } from 'react';
// A "global" promise for the runtime library.
const runtimePromise;
export default RuntimeSingletonComponent extends Component {
componentDidMount() {
// Have we previously loaded the runtime library?
if (!runtimePromise) {
// import() the runtime library for the first time.
import React from 'react';
import { storiesOf } from '@storybook/react';
import withPaidPostArticle from '../../../../../.storybook/withPaidPostArticle';
import withPlacement from '../../../../../.storybook/withPlacement';
import Figure from '../Figure';
import { paragraphs as lipsum } from '../../../../utils/placeholders/lorem-ipsum.json';
import breakpoints from '../../../../utils/layout/breakpoints.json';
const srcObj = {
$ yarn run test -- src/__tests__/Storyshots.test.js
yarn run v0.24.6
$ NODE_ENV=test jest src/__tests__/Storyshots.test.js
PASS src/__tests__/Storyshots.test.js
Storyshots
Figure
✓ with all props (story) (22ms)
✓ with a Picture (story) (8ms)
Test Suites: 1 passed, 1 total
$ yarn run test
yarn run v0.24.6
$ NODE_ENV=test jest
PASS src/__tests__/Storyshots.test.js
● Console
console.info node_modules/@storybook/react/dist/server/babel_config.js:67
=> Loading custom .babelrc
PASS src/components/standard/Figure/__tests__/Figure.test.jsx
@kohlmannj
kohlmannj / .babelrc
Created January 24, 2017 03:34
.babelrc Snapshot 2017-01-23
{
"presets": [
["latest", { "modules": false }],
"react",
"stage-2"
],
"env": {
"development": {
"plugins": [
"react-hot-loader/babel"