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

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',
// ...
]
@andreasvirkus
andreasvirkus / Dockerfile
Created March 10, 2019 11:30
Dockerfile for static SPAs
# build stage
FROM node:lts-alpine as build-stage
WORKDIR /app
# Install git (required for @qualitista/i18n package)
RUN apk update && \
apk upgrade && \
apk add git
COPY package*.json ./
RUN CYPRESS_INSTALL_BINARY=0 npm ci && npm update @qualitista/i18n
COPY . .
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.