Skip to content

Instantly share code, notes, and snippets.

View Antoinebr's full-sized avatar
:octocat:
🔥

Antoinebr

:octocat:
🔥
  • Fastly
  • Paris / Rennes
View GitHub Profile
const glob = require("glob")
const util = require('util');
const exec = util.promisify(require('child_process').exec);
// Updte with your image path
const yourImagesPath = "/home/mobileui/app/wp-content/uploads/2018/01/*.jpg";
glob(yourImagesPath, {}, function (er, files) {
if( er ) throw new Error( er );
caches.open('my-pwa-demo')
var CACHE_NAME = "my-pwa-demo";
var CACHED_URLS = [
'/',
"index.html",
"app.js",
"app.css"
/*
| --------------------------------------------------------------------------
| Prerender the checkout page from the cart
| --------------------------------------------------------------------------
|
+*/
add_action( 'wp_head', function(){
global $woocommerce;
@Antoinebr
Antoinebr / pwa-defering-prompt.js
Created June 25, 2018 19:10
pwa-defering-prompt.js
/*
| --------------------------------------------------------------------------
| Defering prompt
| --------------------------------------------------------------------------
*/
let deferredPrompt;
window.addEventListener('beforeinstallprompt', event =>{
@Antoinebr
Antoinebr / node-jwt.md
Last active October 26, 2018 21:26
node-jwt.js
function onPageRequest(req, res) {
res.writeHead(200, {
'Content-Type': 'application/json',
"Access-Control-Allow-Origin": "*"
});
res.end(JSON.stringify(
{
@Antoinebr
Antoinebr / os.md
Created August 8, 2018 10:32
OneSIgnal custom UI

One Signal

Create a custom subscription button

function subscribe() {
  OneSignal.push(["registerForPushNotifications"]);
[...document.querySelectorAll('input')].forEach( input => {
input.setAttribute('value', `my type is ${input.getAttribute('type')}`);
input.setAttribute('style', `color:black; font-size:20px; font-weight:bold;`);
});
@Antoinebr
Antoinebr / cacheOrNetwiork.js
Created December 10, 2018 15:20
cacheOrNetwiork.js
/**
* cacheOrNetwork
*
* Look for and returns an event request in the cache
* @param {eventRequest} event
* @param {string} cacheName
*/
const cacheOrNetwork = async (event, cacheName) => {