Skip to content

Instantly share code, notes, and snippets.

View LasaleFamine's full-sized avatar
🔮
Producing

Alessio Occhipinti LasaleFamine

🔮
Producing
View GitHub Profile
@LasaleFamine
LasaleFamine / login-page-medium-index.js
Created October 15, 2017 15:00
Simple index.js for a login page of a Polymer Skeleton application.
import {Element as PolymerElement} from '@polymer/polymer/polymer-element';
import User from './../../lib/user';
import css from './style.postcss';
import template from './template.html';
// Import our main application component
import './../sk-app';
@LasaleFamine
LasaleFamine / index.html
Last active October 24, 2017 21:24
Sample index.html for medium-webpack-workbox
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Webpack + Workbox</title>
<style>
body {
@LasaleFamine
LasaleFamine / index.js
Created October 24, 2017 21:26
Sample entry point for medium-webpack-workbox
'use strict';
const changeEverything = () => {
setTimeout(() => {
document.querySelector('h1').textContent = 'I was changed!';
}, 3000);
}
changeEverything();
@LasaleFamine
LasaleFamine / webpack.config.js
Created October 24, 2017 21:30
Sample webpack config for medium-webpack-workbox
'use strict';
const {resolve, join} = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const WorkboxPlugin = require('workbox-webpack-plugin');
const OUTPUT_PATH = resolve('./dist');
module.exports = {
entry: {
@LasaleFamine
LasaleFamine / sw-network.js
Created November 1, 2017 20:51
Service Worker cache network response from API
self.onfetch = event => {
// Ignore non-get request like when accessing the admin panel
if (event.request.method !== 'GET') { return; }
// Don't try to handle non-secure assets because fetch will fail
if (!/api\/v1/.test(event.request.url)) { return; }
// Here's where we cache all the things!
event.respondWith(
// Open the cache created when install
caches.open('OFFLINE_CACHE').then(function(cache) {
{
"HTML skeleton following the-frontend-checklist": {
"prefix": "html:meta",
"body": [
"<!doctype html>",
"<html lang=\"$1en\">",
"\t<head>",
"\t\t<title>$2</title>",
"\t\t<meta charset=\"UTF-8\">",
"\t\t<meta http-equiv=\"x-ua-compatible\" content=\"ie=edge\">",
@LasaleFamine
LasaleFamine / postcss-build.js
Created December 4, 2017 15:16
Building postcss files.
const fs = require('fs-extra');
const postcss = require('postcss');
const postcssrc = require('postcss-load-config');
const folder = './folder/';
const outputFolder = './out';
const run = async () => {
const files = await fs.readdir(folder);
0440ff4945d40ead38931da46a20b9af44d5de99e14b7bb38f5aca58b39c225af916a3c3c75d27d03693758c2de92e2c2cc1ea1515bfc4aaaff44b9dc899c444c4
@LasaleFamine
LasaleFamine / copy-object.js
Created April 4, 2018 12:29
Copy object -> definitive way ES2017
const Product = {
name: 'Some name',
price: 10,
set discount(x) {
this.disc = x;
},
get discount() {
return this.disc;
}
const fs = require('fs');
const vsts = require('vso-node-api');
const repoId = 'YOUR_REPO_ID';
const token = 'YOUR_TOKEN';
const run = async () => {
const writeStream = fs.createWriteStream('./output.zip');
const authHandler = vsts.getPersonalAccessTokenHandler(token);
const handler = new vsts.WebApi('https://<username>.visualstudio.com/defaultcollection', authHandler);