Skip to content

Instantly share code, notes, and snippets.

@adrienZ
adrienZ / jsToScss.js
Last active September 28, 2020 09:33
Convert a javascript object into a string of sass variables
/**
* @name jsToSassVariables
* @param {Object} obj
* @returns {String}
*/
function jsToSassVariables(obj) {
const { stringify, parse } = JSON
// remove null, undefined values and functions
const objStr = stringify(obj)
@adrienZ
adrienZ / sw.js
Last active December 16, 2018 11:45
Service worker activation and IndexedDB
self.addEventListener('activate', function(event) {
event.waitUntil(
createDB()
);
});
function createDB() {
idb.open('products', 1, function(upgradeDB) {
var store = upgradeDB.createObjectStore('beverages', {
keyPath: 'id'
@adrienZ
adrienZ / sw.js
Created December 15, 2018 16:25
Service worker fetch event and cached ressource
self.addEventListener('fetch', event => {
console.log('Fetch intercepted for:', event.request.url);
event.respondWith(caches.match(event.request)
.then(cachedResponse => {
if (cachedResponse) {
return cachedResponse;
}
return fetch(event.request);
})
);
@adrienZ
adrienZ / sw.js
Last active December 13, 2018 09:59
Service worker installation and activation with skipWaiting and clients.claim
const CACHE_NAME = 'cache-v1';
const precacheResources = [
'index.html',
'styles/main.css',
// your files ...
];
self.addEventListener('install', event => {
console.log('Service worker install event!');
event.waitUntil(
@adrienZ
adrienZ / sw.js
Last active December 13, 2018 09:59
Service worker activation and cache cleaning
self.addEventListener('activate', function(event) {
event.waitUntil(
caches.keys().then(function(cacheNames) {
return Promise.all(
cacheNames.map(function(cacheName) {
return caches.delete(cacheName);
})
);
})
);
@adrienZ
adrienZ / sw.js
Created December 12, 2018 12:02
Service worker installation and ressources caching
const CACHE_NAME = 'cache-v1';
const precacheResources = [
'/',
'index.html',
'styles/main.css',
'images/space1.jpg',
'images/space2.jpg',
'images/space3.jpg'
];
@adrienZ
adrienZ / main.js
Last active March 3, 2019 13:13
Service Worker registration
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/service-worker.js')
.then(function(registration) {
console.log('Registration successful, scope is:', registration.scope);
})
.catch(function(error) {
console.log('Service worker registration failed, error:', error);
});
}

mtllib cibe.mtl o Cube.002_Cube.004 v -0.220941 -0.388026 0.862489 v -0.225505 -0.357192 0.861503 v -0.215057 -0.386801 0.830920 v -0.213984 -0.417310 0.864002 v -0.225144 -0.388901 0.894057 v -0.229915 -0.357643 0.893564