Skip to content

Instantly share code, notes, and snippets.

View stephenparish's full-sized avatar

Stephen Parish stephenparish

View GitHub Profile
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@stephenparish
stephenparish / machine.js
Last active October 17, 2019 16:50
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions

Keybase proof

I hereby claim:

  • I am stephenparish on github.
  • I am stephenparish (https://keybase.io/stephenparish) on keybase.
  • I have a public key ASAfzZIcB4alF-E7dWJsJf4BE5n6sx7R-oZg64DtHldcUgo

To claim this, I am signing this object:

@stephenparish
stephenparish / iframeResizer.js
Created August 28, 2017 16:25
Embedded Iframe Resizing (fixes iOS Safari's auto-sizing issues)
// -----------------------------------------------------------
// Makes the iframe fill the screen, but leaves space for the header above the iframe.
// We do this becuase Safari and WebViews on iOS automatically resize the iframe height
// to capture the content of the iframe. This may be fine for some sites and incorrect fo others,
// this is done to make the behavior consitent across browsers and sites.
function hookupIframeResize() {
var iframeElement = document.querySelector('.iframe');
var headerElement = document.querySelector('.header');
function updateIframeSize() {
@stephenparish
stephenparish / mini-redux.js
Last active December 12, 2019 02:44 — forked from MarcoWorms/mini-redux.js
Redux in a nutshell
function createStore (reducers) {
let state = reducers()
const subscribers = [];
const store = {
dispatch: (action) => {
state = reducers(state, action);
subscribers.forEach((subscriber) => subscriber());
},
getState: () => {
return state
<div id="test-result"></div>
.scaleIt {
-webkit-transform: scale(0.5); /* Saf3.1+, Chrome */
-moz-transform: scale(0.5); /* FF3.5+ */
-ms-transform: scale(0.5); /* IE9 */
-o-transform: scale(0.5); /* Opera 10.5+ */
transform: scale(0.5); /* IE8+ - must be on one line, unfortunately */
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.5, M12=0, M21=0, M22=0.5, SizingMethod='auto expand')";
/* IE6 and 7 */
filter: progid:DXImageTransform.Microsoft.Matrix(
@stephenparish
stephenparish / mixins.less
Created December 2, 2014 15:00
A shorthand @font-face mixin
.font(@family, @url, @weight: normal, @style: normal) {
@font-face {
font-family: @family;
src: url('@{url}.eot'); // IE9 Compat Modes
src: url('@{url}.eot?#iefix') format('embedded-opentype'), // IE6-IE8
url('@{url}.woff') format('woff'), // Modern Browsers
url('@{url}.ttf') format('truetype'); // Safari, Android, iOS
// url('@{url}.svg') format('svg'); // Legacy iOS, pre-4.2, unecessary if not supporting that far.
font-weight: @weight;
font-style: @style;
@stephenparish
stephenparish / GetStatusBarHeight.java
Created July 27, 2014 01:56
Get android status bar height
public int getStatusBarHeight() {
int result = 0;
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
result = getResources().getDimensionPixelSize(resourceId);
}
return result;
}