Skip to content

Instantly share code, notes, and snippets.

View tthew's full-sized avatar
👨‍🎨

Matt Richards tthew

👨‍🎨
View GitHub Profile
const useWindowResize = invokeImmediately => {
const [immediatelyInvoked, setImmediatelyInvoked] = useState(false);
const [rect, setRect] = useState({
innerWidth: undefined,
innerHeight: undefined
});
const set = useCallback(() => {
if (!window) return;
const { innerWidth, innerHeight } = window;
<ApiProvider> // attach observables to context
<router>
<blah>
<blah>
{connectApi(<ApiConnectedComponet />) // take context observerables and pass as props to component
</blah>
</blah>
</router>
</ApiProvider>
@tthew
tthew / freed.js
Last active December 24, 2017 12:43
Free yourself from the Facebook feed.
// ==UserScript==
// @name Freed
// @description Free yourself from the Facebook feed.
// @version 1
// @include https://www.facebook.com/*
// @grant GM_addStyle
// ==/UserScript==
GM_addStyle(`
div[role=feed] {

Keybase proof

I hereby claim:

  • I am tthew on github.
  • I am tthew (https://keybase.io/tthew) on keybase.
  • I have a public key ASDeXOF72RPI_ZMTk-KRr6HjDTwzIU4mvYRJb7ryHRT2fAo

To claim this, I am signing this object:

Verifying that +_tthew is my blockchain ID. https://onename.com/_tthew
@tthew
tthew / angular-webpack-cssmodules-example.md
Last active March 28, 2016 13:01
An example of leveraging Webpack, cssmodules (via webpack + postcss) and Angular

A very basic / high-level example of how to use locally scoped cssmodules in Angular, via Webpack using the css-loader.

Read the cssmodules readme and the css-loader README for lots more high-level information. Also checkout the lower-level ICSS (interoperable css) spec/readme for the nitty gritty.

Tl;dr this approach solves many of the same problems BEM sets out to solve

This would require a refactor of existing codebases to use Webpack. But beyond that (which may or may not be trivial depending on many different factors) it appears to be a maintainable and scalable strategy.

Check out this gulp-webpack-angular-seed I put together some time ago as well as the this resume application and this mnutrition branch for examples o

<html>
<body>
<video id="v" width="300" height="300"></video>
<input id="b" type="button" disabled="true" value="Take Picture"></input>
<canvas id="c" style="display:none;" width="300" height="300"></canvas>
</body>
<script>
navigator.getUserMedia({video: true}, function(stream) {
var video = document.getElementById("v");
var canvas = document.getElementById("c");
#!/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'
var filesystem = require('fs');
var _ = require('lodash');
var models = {};
var relationships = {};
var orm = function orm() {
var Sequelize = require('sequelize');
var sequelize = null;
var assert = require('assert');
var path = require('path');
var protractor = require('protractor');
var webdriver = require('selenium-webdriver');
var browser = process.env.browser || 'chrome';
var driver = new webdriver.Builder()
.usingServer('http://localhost:4444/wd/hub')
.withCapabilities(webdriver.Capabilities[browser]())
.build();