Skip to content

Instantly share code, notes, and snippets.

View chrishutchinson's full-sized avatar

Chris Hutchinson chrishutchinson

View GitHub Profile
@chrishutchinson
chrishutchinson / Absolute Centring
Created August 15, 2013 08:30
CSS: Absolute centring
div{
display: table;
height: auto;
margin: auto;
position: absolute;
left: 0;
bottom: 0;
top: 0;
right: 0;
width: 100px;

Keybase proof

I hereby claim:

  • I am chrishutchinson on github.
  • I am chrishutchinson (https://keybase.io/chrishutchinson) on keybase.
  • I have a public key whose fingerprint is 04A1 E95F E92A C7D6 A937 4350 6F9B 0283 EAE1 0988

To claim this, I am signing this object:

@chrishutchinson
chrishutchinson / Custom Sir Trevor JS Icon
Created September 11, 2014 11:27
CSS to add custom icons (in this case Font Awesome) to Sir Trevor JS blocks
a[data-type="tweet"]{
span{ display: none; }
&:before {
content: "\f099";
display: block;
font-family: FontAwesome;
font-style: normal;
font-weight: normal;
line-height: 1;
-webkit-font-smoothing: antialiased;
@chrishutchinson
chrishutchinson / index.js
Created May 13, 2015 10:47
AngularJS (ES6) filter wrapper for NumberStrings (https://www.npmjs.com/package/numberstrings)
'use strict';
// Import class
import NumberStrings from 'path/to/numberstrings.filter';
angular.module('appName', [])
.filter('NumberStrings', () => new NumberStrings()) // Add filter
@chrishutchinson
chrishutchinson / google-font.js
Created May 6, 2017 10:33
Get the base64 version of a Google Font
const googlefontcssmerge = require('googlefontcssmerge');
const googlefontcss64 = require('googlefontcss64');
const css = require('css');
const url = `http://fonts.googleapis.com/css?family=Open+Sans`;
googlefontcssmerge(url, function(error, style) {
if (error) throw error;
googlefontcss64(style, function(error, style) {
@chrishutchinson
chrishutchinson / 1.js
Created November 23, 2017 17:45
Budget Calculator 2017 code review
// HTML Element
<budget-calculator no-headline></budget-calculator>
// Polymer template code
<template is="dom-if" if="{{showHeadline}}">
<h1>This is my headline</h1>
</template>
// Polymer JavaScript code
// HTML Element
<budget-calculator no-headline></budget-calculator>
// Polymer template code
<template is="dom-if" if="{{showHeadline}}">
<h1>This is my headline</h1>
</template>
// Polymer JavaScript code
// Polymer template code
<form on-submit="handleFormSubmit"></form>
// Polymer JavaScript code
handleFormSubmit: function(event) {
// Your form submission behaviour would go here
}
// Polymer template code
<form autocomplete="off" id="form" on-submit="handleFormSubmit">
<input type="text" name="income" placeholder="Enter your annual income (£)" />
<div class="selectWrapper">
<i class="Icon Icon--arrowDown"></i>
<select name="category" id="dropdown">
<option value="" disabled selected>Your status</option>
</select>
// Polymer template code
<!-- A permanently visible (although empty) anchor, so we have somewhere to scroll to -->
<div id="results-anchor"></div>
// Polymer JavaScript code
const scrollToElement = (element, offset = 0) => {
const distanceFromTop = element.getBoundingClientRect().top;
window.scrollBy({
top: distanceFromTop + offset,
left: 0,