Skip to content

Instantly share code, notes, and snippets.

View johno's full-sized avatar
🖤
Computering

John Otander johno

🖤
Computering
View GitHub Profile
@johno
johno / rehoc.md
Last active October 13, 2016 18:40
[Thinking Out Loud] Functional, unidirectional state management for React based on redux

↻ rehoc

Work in progress

Functional, unidirectional state management for React based on redux.

Why?

redux is great for predictably handling state but doesn't leverage Higher Order Components out of the box. rehoc provides functional, HOCs that can be used to cleanly "connect" your containers to state and action dispatchers.

@johno
johno / chart.js
Last active August 2, 2017 10:02
Example of Day/Hour Heatmap with a JS object - http://bl.ocks.org/tjdecke/5558084
var margin = { top: 50, right: 0, bottom: 100, left: 30 },
width = 960 - margin.left - margin.right,
height = 430 - margin.top - margin.bottom,
gridSize = Math.floor(width / 24),
legendElementWidth = gridSize*2,
buckets = 9,
colors = ['#ffffd9','#edf8b1','#c7e9b4','#7fcdbb','#41b6c4','#1d91c0','#225ea8','#253494','#081d58'], // alternatively colorbrewer.YlGnBu[9]
days = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'],
times = ['1a', '2a', '3a', '4a', '5a', '6a', '7a', '8a', '9a', '10a', '11a', '12a', '1p', '2p', '3p', '4p', '5p', '6p', '7p', '8p', '9p', '10p', '11p', '12p'];
@johno
johno / cson.js
Created September 21, 2016 22:06
Initial script output for tachyons cson build for atom snippets
var fs = require('fs')
var _ = require('lodash')
var path = require('path')
var glob = require('glob')
var titleize = require('titleize')
var fm = require('json-front-matter')
var rmHtmlExt = require('remove-html-extension')
glob('src/components/**/*.html', {}, function (err, components) {
if (err) {
@johno
johno / has-emotion.js
Last active September 20, 2016 23:18
EMBER: Using classNameBindings for dynamic Tachyons classes based on properties. This also includes a hasEmotion mixin I've used on a project to handle branding colors.
import Ember from 'ember';
export default Ember.Mixin.create({
kind: null,
classNameBindings: [
'hasEmotion:white',
'hasEmotion:hover-white',
'hasEmotion:focus-white',
'isAngry:bg-bad',
.pa0 { padding: 0rem; }
.ma0 { margin: 0rem; }
.pl0 { padding-left: 0rem; }
.ml0 { margin-left: 0rem; }
.pr0 { padding-right: 0rem; }
.mr0 { margin-right: 0rem; }
.pt0 { padding-top: 0rem; }
.mt0 { margin-top: 0rem; }
.pb0 { padding-bottom: 0rem; }
.mb0 { margin-bottom: 0rem; }
{
"title": "Full Bleed Background",
"slug": "If not the dasherized version of the title like it currently works, i.e., full-bleed-background",
"slug": "my-custom-slug",
"category": "article",
"featured": true,
"tags": [
"long-form",
"content",
"image"
@johno
johno / comp-that-merges-class-name.js
Last active August 26, 2016 18:00
Using dynamic classnames with Tachyons
import React from 'react'
import classNames from 'classnames'
export default ({ isLoading, className, ...otherProps }) => {
const cx = classNames(className, { 'bg-green': !isLoading }, { 'bg-yellow': isLoading })
return <div className={cx} {...otherProps} />
}
@johno
johno / proposal.md
Last active March 19, 2016 18:20
rj

Here's a working document of the proposed functionality and structure for rj so that we may "Command React".

Commands and options

❯ rj -h

  rj, Command React

  Usage
@johno
johno / clone.sh
Last active January 6, 2017 19:26
Tachyons maintenance -- Clone all repos from an org or user with github-repositories cli package on npm, upgrade all modules, publish modules, etc.
github-repositories REPO_NAME | sed 's/.* //' | xargs -L1 git clone
@johno
johno / job.rb
Created January 21, 2016 00:47
Testing asynchronous methods and behavior with Rails, DelayedJob, and Rspec
class SomeJob
attr_accessor :some_model
def initialize(some_model_id)
self.some_model = SomeModel.find(some_model_id)
end
def perform
some_model.do_stuff
end