Skip to content

Instantly share code, notes, and snippets.

<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
/** @jsx React.DOM */
var ReadingTimeWidget = React.createClass({
getInitialState: function() {
return ({
secondsRequired: null,
});
},
componentWillMount: function() {
var cdiv = this.props.contentDiv;
@hizo
hizo / onCSSAnimationEnd.js
Created June 30, 2015 14:58
onCSSAnimationEnd
/*
By Osvaldas Valutis, www.osvaldas.info
Available for use under the MIT License
*/
;( function( $, window, document, undefined )
{
var s = document.body || document.documentElement, s = s.style, prefixAnimation = '', prefixTransition = '';
if( s.WebkitAnimation == '' ) prefixAnimation = '-webkit-';
const windowPopup = (url, width, height) => {
const left = (screen.width / 2) - (width / 2),
top = (screen.height / 2) - (height / 2);
window.open(
url,
"",
"menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left
);
}
@hizo
hizo / font-defaults.css
Created December 29, 2016 01:09
Font defaults
body {
color: #212121;
font-family: "Helvetica Neue", "Calibri Light", Roboto, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
letter-spacing: 0.02em;
}
@hizo
hizo / script-loading.js
Created December 29, 2016 01:10
Script loading
var scripts = ['app.a700a9a3e91a84de5dc0.js']; // script for all users
var newBrowser = (
'fetch' in window &&
'Promise' in window &&
'assign' in Object &&
'keys' in Object
);
if (!newBrowser) {
@hizo
hizo / file-hash.js
Created December 29, 2016 01:11
File hash
const fileHash = crypto.createHash('md5').update(fileContents).digest('hex');
@hizo
hizo / service-workers.js
Created December 29, 2016 01:12
Service workers easy way
swPrecache.write(path.resolve(__dirname, `../public/service-worker.js`), {
cacheId: `know-it-all`,
filename: `service-worker.js`,
stripPrefix: `public/`,
staticFileGlobs: [
`public/app.*.js`, // don't include the polyfills version
`public/*.{html,ico,json,png}`,
],
dontCacheBustUrlsMatching: [
/\.(js|json)$/, // I'm cache busting js and json files myself
@hizo
hizo / kubernetes.md
Last active March 13, 2019 22:37
Kubernetes useful commands
@hizo
hizo / data-fetching-hocs.js
Created July 27, 2018 09:05
React data fetching HOCs
// The same api state machine as before
const withApiState = TargetComponent =>
class extends React.Component {
state = {
current: "idle"
};
apiState = {
pending: () => this.setState({ current: "pending" }),
success: () => this.setState({ current: "success" }),