Skip to content

Instantly share code, notes, and snippets.

View markalfred's full-sized avatar

Mark Battersby markalfred

View GitHub Profile
@markalfred
markalfred / containers-vs-components.md
Created April 28, 2017 16:50
React "Containers / Components" are an anti-pattern

Yeah, the "container vs component" distinction is falling more and more out of favor with me. It's an okay pattern to start, but it's a pretty hard black/white in a place where things are a lot more grey.

In my opinion, there's no reason for this:

// app/index.jsx
import AppComponent from './App'

const AppContainer = ({foo, bar, baz, buz, wham, bam, alakazam, setFoo, setBar, setBaz, setBuz, setWham, setBam, setAlakazam}) =>
  <AppComponent foo={foo} bar={bar} baz={baz} buz={buz} wham={wham} bam={bam} alakazam={alakazam} setFoo={setFoo}, setBar={setBar}, setBaz={setBaz}, setBuz={setBuz}, setWham={setWham}, setBam={setBam}, setAlakazam={setAlakazam} />
@markalfred
markalfred / es6-naming.md
Last active March 28, 2017 18:45
The trouble with ES6 named import/exports

The trouble with ES6 named import/exports

-or-

Regarding renaming SET_RELATIONSHIP_INFORMATION_ERRORS to SET_ERRORS:

I've noticed a particular issue that seems to have come about with the advent of named import/exports in ES6 — that is, that variable names have grown in length by orders of magnitude. This seems to be the result of the need to namespace. For instance, let's say you have a set of user actions...

// user-actions.js
@markalfred
markalfred / osx-for-hackers.sh
Last active May 8, 2016 01:51 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned. Also, please don't email me about this script, my poor inbox...
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
@markalfred
markalfred / ether.js
Last active March 12, 2016 03:06
Ethereum Prices — Current and Alltime High
$.ajax('http://ethereumwisdom.com/data/chart/kraken_USD_1800.json?&rand=0.38954108371399343').then(function(data){var high = data.map(function(c) {return parseFloat(c.h)}).sort(function (a, b) { return a-b; }).reverse()[0]; var current = data[data.length-1].c; console.log('current:', current, 'high:', high)})
@markalfred
markalfred / other_pane.py
Created December 24, 2014 16:31
Determine the best "other" Sublime Text pane.
def determine_output_pane(self):
"""
When the user performs some action which results in a file being
opened or generated in a new tab, we should place that "output"
code in an adjacent pane. This method will determine the correct
pane to place the output in.
It will use a tab to the right, if one exists in the current row.
If not, output is placed in the adjacent tab to the left. Output
should always be adjacent, and should never be on a different row,
@markalfred
markalfred / Skepticisms.sh
Last active August 29, 2015 14:06
Skepticisms. And other long words.
# Find the longest words you can type, alternating hands at each character. Y and B excluded.
egrep "^[$right]?([$left][$right]){6,}[$left]?\$" /usr/share/dict/words
# Qwerty
left=qwertasdfgzxcv
right=uiophjklnm
# Colemak
left=qwfpgarstdzxcv
@markalfred
markalfred / Given - with variable.sublime-snippet
Created October 29, 2013 19:46
Cucumber Step Templates for Sublime Text
<snippet>
<content><![CDATA[
Given(/^${1:Something called}${2: "(.*?)"}${3: does something}\$/) do |${4:variable_name}|
${0:}
end
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>given-variable step</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->