Skip to content

Instantly share code, notes, and snippets.

View JBreit's full-sized avatar

Jason Breitigan JBreit

  • Inner Mind Co.
  • Lancaster, PA
View GitHub Profile
const strategies = {
cacheFirst(request) {
return caches.open(APPLICATION_CACHE).then((cache) => {
return cache.match(request).then((matching) => {
return matching || Promise.reject('no-match');
});
});
},
networkFirst(request, delay) {
return new Promise((resolve, reject) => {
@JBreit
JBreit / daemon.js
Created May 31, 2017 01:27
Linux Node JS HTTP Daemon
#!/usr/bin/env node
/**
* bin/daemon
* A simple Linux HTTP Daemon
*/
require('daemon')();
const cluster = require('cluster');
@JBreit
JBreit / observable.js
Created June 4, 2017 20:15
Observable
const node = document.querySelector('input[name="test"]');
const p = document.querySelector('p');
function Observable(subscribe) {
this.subscribe = subscribe;
}
Observable.fromEvent = (element, name) => {
return new Observable((observer) => {
const callback = (event) => observer.next(event);
/* global document Rx*/
const link = document.querySelector('.nav-link');
const link$ = Rx.Observable.fromEvent(link, 'click');
const observer = {
next(event) {
console.log(event);
},
error(err) {
import NotFound from './notfound';
const Config = ($stateProvider, $urlRouterProvider, $locationProvider) => {
'ngInject';
$stateProvider
.state('404', NotFound);
$locationProvider
.html5Mode(false)
@JBreit
JBreit / index.html
Created June 16, 2017 22:17
Vanilla JS Fetch, History API SPA Experiment
<!DOCTYPE html>
<html lang="en-us">
<head>
<base href="/">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="Jason Breitigan">
.navbar {
display: block;
float: left;
position: relative;
background: #F7F7F7;
border-right: 1px solid #e5e5e5;
height: 100%;
min-height: 100%;
width: 55px;
margin-top: 50px;
@JBreit
JBreit / .babelrc
Last active July 16, 2017 13:49
Webpack 2.0 Configuration Demo
{
"presets": [
["env", {
"modules": false
}],
"react"
],
"plugins": []
}
@import url("common.css");
.app {
height: 100%;
}
@media only screen {
}
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const Clean = require('clean-webpack-plugin');
const Html = require('html-webpack-plugin');
const Text = require('extract-text-webpack-plugin');
const marked = require('marked');
const renderer = new marked.Renderer();