Skip to content

Instantly share code, notes, and snippets.

View ezekielchentnik's full-sized avatar

Ezekiel Chentnik ezekielchentnik

View GitHub Profile
/*
React JS Wisconsin
_
_| `...,, Scansin
( \/|
| /
\ /
| JS |
(______|
@ezekielchentnik
ezekielchentnik / react-redux-serviceworker.js
Last active June 29, 2017 12:12
service worker with redux and react
import 'file?name=[name].[ext]!./utils/serviceworker.js';
import '../css/components/_app.css';
import 'babel-polyfill';
import React from 'react';
import { render } from 'react-dom';
import configureStore from './store/configureStore';
import Root from './containers/Root';
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/serviceworker.js');
require('babel-register');
module.exports = require('./webpack.client');
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
'use strict';
const version = 'v0.01::';
const staticCacheName = version + 'static';
function updateStaticCache() {
return caches.open(staticCacheName)
.then( cache => {
// These items won't block the installation of the Service Worker
cache.addAll([
import express from 'express';
const app = express();
if (IS_DEV) {
require('piping')();
}
//express routes, etc.
export default app;
import webpack from 'webpack';
export default function(name, doneMessage){
return new webpack.ProgressPlugin(function(percentage, message) {
var MOVE_LEFT = new Buffer('1b5b3130303044', 'hex').toString();
var CLEAR_LINE = new Buffer('1b5b304b', 'hex').toString();
process.stdout.write(CLEAR_LINE + 'webpack compiling ['+name+']: ' + Math.round(percentage * 100) + '%: ' + message + MOVE_LEFT);
if(percentage == 1){
process.stdout.write(doneMessage || "webpack say good, fire up...\n");
@ezekielchentnik
ezekielchentnik / ApiActions.js
Created August 12, 2016 16:38
Session Storage interval caching with fetch and redux
const OPTIONS = {
credentials: 'include',
headers: {
'Accept': 'application/json', // eslint-disable-line
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest'
}
};
export function parseResponse(response) {
@ezekielchentnik
ezekielchentnik / isBrowser.js
Created September 2, 2016 15:53
Simple helper to facilitate checking for browser when doing SSR
export default typeof window !== 'undefined'