Skip to content

Instantly share code, notes, and snippets.

View petebrowne's full-sized avatar

Pete Browne petebrowne

View GitHub Profile
npm install --save react react-dom d3-shape d3-scale
function isHtmlRequest(request) {
return (
request.method === 'GET' &&
request.headers.get('accept').includes('text/html')
);
}
self.addEventListener('fetch', event => {
if (isHtmlRequest(event.request)) {
event.respondWith(
var CACHE_VERSION = 1;
var CACHE_NAME = `example-4_${CACHE_VERSION}`;
var OFFLINE_URL = 'offline.html';
var CACHE_URLS = [
OFFLINE_URL
];
self.addEventListener('install', event => {
event.waitUntil(
caches.open(CACHE_NAME).then(cache => {
self.addEventListener('fetch', event => {
event.respondWith(
caches.match(event.request).then(response => {
return response || fetch(event.request);
})
);
});
var CACHE_VERSION = 1;
var CACHE_NAME = `example-3_${CACHE_VERSION}`;
var CACHE_URLS = [
'site.css',
'site.js'
];
self.addEventListener('install', event => {
event.waitUntil(
caches.open(CACHE_NAME).then(cache => {
navigator.serviceWorker.register('service-worker.js').then(function(registration) {
console.log('registered!', registration)
});
self.addEventListener('activate', event => {
event.waitUntil(
caches.keys().then(cacheNames => {
return Promise.all(
cacheNames.map(cacheName => {
if (cacheName !== CACHE_NAME) {
console.log('Deleting out of date cache:', cacheName);
return caches.delete(cacheName);
}
})
self.addEventListener('fetch', event => {
var response = new Response('This came from the service worker!');
event.respondWith(response);
// Default behavior - same as not using `respondWith`
// event.responseWith(fetch(event.request));
});
console.log(self);
self.addEventListener('install', event => {
console.log('installed!', event);
});
self.addEventListener('activate', event => {
console.log('activated!', event);
});
@petebrowne
petebrowne / in_network.sql
Created January 15, 2014 21:03
Insurance Coverage SQL queries. Third one is broken...
SELECT DISTINCT "insurance_insuranceissuer"."id", "insurance_insuranceissuer"."slug", "insurance_insuranceissuer"."issuer_code", "insurance_insuranceissuer"."legal_name", "insurance_insuranceissuer"."marketing_name", "insurance_insuranceissuer"."company_code", "insurance_insuranceissuer"."group_code", "insurance_insuranceissuer"."state", "insurance_insuranceissuer"."created_at", "insurance_insuranceissuer"."updated_at" FROM "insurance_insuranceissuer" INNER JOIN "insurance_coverage_practiceissuer" ON ( "insurance_insuranceissuer"."id" = "insurance_coverage_practiceissuer"."issuer_id" ) WHERE ("insurance_coverage_practiceissuer"."in_network" = %s AND "insurance_coverage_practiceissuer"."practice_id" = %s ) LIMIT 21' - PARAMS = (True, u'b107925f-aac8-4baa-b304-3ec720ef082d'); args=(True, u'b107925f-aac8-4baa-b304-3ec720ef082d')