Skip to content

Instantly share code, notes, and snippets.

View andreasvirkus's full-sized avatar
🙊
made you look

andreas andreasvirkus

🙊
made you look
View GitHub Profile
/**
* Medium-strength regex checks if the password contains 2 of:
* - lowercase alphabetical char
* - uppercase alphabetical char
* - numerical character
* - minimum of 6 characters
*
* Strong-strength regex checks if the password contains all of:
* - lowercase alphabetical char
* - uppercase alphabetical char
// See an excellent explanation over at
// https://medium.com/hackernoon/the-100-correct-way-to-split-your-chunks-with-webpack-f8a9df5b7758
optimization: {
runtimeChunk: 'single',
splitChunks: {
chunks: 'all',
maxInitialRequests: Infinity,
// Default is 30kB, let's set it to 5kB
minSize: 5000,
cacheGroups: {

Extension reloader

This will watch a Chrome extension's file directory, compile a hash based on the file names and date and reload the extension/add-on when the directory undergoes changes.

Compatible with Webpack and any other type of build setup! 📦

Usage

Add the script to your extension's manifest.json

<body>
<blockquote>
<p>Photos by <a href="https://source.unsplash.com/">random photographers</a> on <a href="https://unsplash.com/">Unsplash</a></p>
</blockquote>
<main>
<img lazy data-src="https://source.unsplash.com/random/800x600">
<img lazy data-src="https://source.unsplash.com/random/800x600">
<img lazy data-src="https://source.unsplash.com/random/800x600">
<img lazy data-src="https://source.unsplash.com/random/800x600">
// Minimal jQuery
const $$ = document.querySelectorAll.bind(document);
const $ = document.querySelector.bind(document);
const firstAncestor = (el, tagName) => {
while(el = el.parentNode && (el.tagName !== tagName.toUpperCase()))
return el
}
// Usage
var child = document.getElementById('child')
firstAncestor(child, 'div'); //<div id="parent">
{
"name": "ver-extractor",
"description": "Get the version from your package.json",
"scripts": {
"get-version": "node -pe \"require('./package.json').version\""
}
}
export const subdomainRegex = new RegExp('^(([^.]*))', 'g')
export const parseSubdomain = hostname => (hostname || window.location.hostname).match(subdomainRegex)[0]
@andreasvirkus
andreasvirkus / movies-2019.sh
Last active November 23, 2019 17:10
List of movies I've seen per year
* Tracking as of 28th Jan (prolly missed 5-10 movies) *
A Star Is Born
Spider-Man: Into the Spidey-verse
Widows
Immortal Machines
1+2
The Guilty
Cam
@andreasvirkus
andreasvirkus / serviceWorker.js
Created March 10, 2019 13:36
Service worker with progressive caching
'use strict'
const version = 'v1::'
const offlineFundamentals = [
'/assets/css/variables.css',
'/assets/css/global.css',
'/assets/js/script.min.js',
'/index.html',
// ...
]