Skip to content

Instantly share code, notes, and snippets.

View iamchristough's full-sized avatar

Chris Tough iamchristough

View GitHub Profile
function actThenThrottleEvents(listener, delay) {
var timeout;
return function(e) {
if (!timeout) { // no timer running
listener(e); // run the function
timeout = setTimeout( function() { timeout = null },
delay); // start a timer that turns itself off when it's done
}
//else, do nothing (we're in a throttling stage)
}
@iamchristough
iamchristough / FFMpeg Extract Frame CL
Created December 6, 2017 13:36
FFMpeg Extract single frame
ffmpeg -i video-3.mp4 -ss 00:00:05 -vframes 1 video-3.jpg
<script>
(function (p,h,a,n,t,o,m) {
p['GoogleAnalyticsObject'] = t;
p[t] = p[t] || function () {
(p[t].q = p[t].q || []).push(arguments)
}, p[t].l = 1 * new Date();
o = h.createElement(a),
m = h.getElementsByTagName(a)[0];
o.async = 1;
o.src = n;
@iamchristough
iamchristough / camphor.scss
Created December 8, 2017 10:55 — forked from bdno86/camphor.scss
camphor
$camphor300:'d09GMgABAAAAAQ5UABIAAAAEn0QAAQ3tAAEZmQAAAAAAAAAAAAAAAAAAAAAAAAAAG4SkahzOKgZgFotgAIosCCIJgnMRCAqLlgCKvTwBNgIkA5lwE4GnDguZdAAEIAW7bwcgDHJb0WS0WUXZkokWaBHx4wKbY7TigANIU/t980QCGzI/IkCsdbqJZwY1ZOgWDngIamw3I43435Dd+zJ1kNmKVp/DvXNAwaNm//////////////////+/NZkMZ5cAl0CpbZ3oiwloFA5GyIWNzOYVLt1bpXPX+pABI2fo5rMZpgVYIzYqgxt92ajECqUKh2G9gaOCVRC23VSRVypHfbvb7wYcwEM25WArF0esm1yKzDixrJRdcBGtcpBZTFbFbIl8LIU4gWOnEdSITqkoGrHWJ8ywn9eVFWWk3lC6m07qp1TXntHaWp6ekYHLrFoyzOXYiQnn2kWX2zqMaFBTca25vHKndPhJV66HRhQzL9lB3OT20KGTXuFHu62wm1qzoV/iTnaiLdc8o/D7B+1O94BrjSE3cia6U1A5XNp0kHmUj8IMBaeiGaiNJV7b1csb0bq8EWYo2h1TuipR+7hmYjxeZsonGLNcmgsKp5EUDCEj9SvRyxX2uMUNfINmfNqglBYNNtjtNmdwWV2ly4uQKheyDyka2RTRoQ3IEfs+0BNcGJ4Z5AnmHNpFbCKW5PsXkAzJ6VVzzVMo0fwIUpQQT67itTNRE946/NxDashl9KuAFUbZ6yW91vObh+WAMZ1mQ1J4wotF6KXHuo65X6wSz406hW/T6XZMf/6W+HGYUxCDfhyjPaoMGcWccmbYM/H35NdHTOd79Jg0ho/BDBvRy2vcg8pHsv07UYiKrDFeqzL0Qk7qCkXLuukl2EKuR3xS6VtsLEaT0BfWoDYoQ1YvEjjT729XNMYoCX3j+2ApedBG/UHLOJ7AAnfPSqdmmePsY+522MpfPaf7kf6fIJMn0/4SE6PmuI3yjyeGjWn+1qj/ukf09DE
@iamchristough
iamchristough / package.json
Created April 19, 2018 19:02 — forked from surma/package.json
Boilerplate for quick one-off TypeScript projects. Just run `npm start`
{
"name": "tsquickstart",
"version": "1.0.0",
"description": "Boilerplate for quick one-off TypeScript projects. Just run `npm start`",
"scripts": {
"init": "test -f tsconfig.json || (tsc --init -t ESNext -m ESNext && npm install)",
"start": "npm run init && concurrently \"npm run watch\" \"npm run serve\"",
"serve": "http-server",
"watch": "tsc -p . --watch",
"build": "tsc -p ."
@iamchristough
iamchristough / createComponent.js
Created January 3, 2019 14:48
Creates React components
const fs = require('fs');
const path = require('path');
/**
* Arguments
*/
const name = process.argv[2];
const location = process.argv[3];
const needRuntime = process.argv[4] === 'runtime';
@iamchristough
iamchristough / scrollToTop.js
Created February 7, 2019 17:04
scrollToTop
const scrollToTop = () => {
const c = document.documentElement.scrollTop || document.body.scrollTop;
if (c > 0) {
window.requestAnimationFrame(scrollToTop);
window.scrollTo(0, c - c / 8);
}
};
@iamchristough
iamchristough / reduce-animation.css
Last active February 7, 2019 17:05
tough-reset.css
@media (prefers-reduced-motion: reduce) {
* {
animation-duration: 0.1s !important;
transition-duration: 0.1s !important;
}
}
@iamchristough
iamchristough / collapse-component.js
Created February 7, 2019 17:12
Collapse React Component
class Collapse extends React.Component {
constructor(props) {
super(props);
this.state = {
collapsed: !!props.collapsed
};
this.style = {
collapsed: {
display: 'none'
},
@iamchristough
iamchristough / password-reveal.js
Created February 13, 2019 16:58
Password Reveal React component
class PasswordRevealer extends React.Component {
constructor(props) {
super(props);
this.state = {
shown: false
};
this.toggleShown = this.toggleShown.bind(this);
}
toggleShown() {