Skip to content

Instantly share code, notes, and snippets.

😶
boop

ajv andreasvirkus

😶
boop
Block or report user

Report or block andreasvirkus

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View index.html
<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">
View minimalJquery.js
// Minimal jQuery
const $$ = document.querySelectorAll.bind(document);
const $ = document.querySelector.bind(document);
View firstAncestor.js
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">
View getPackageVersion.json
{
"name": "ver-extractor",
"description": "Get the version from your package.json",
"scripts": {
"get-version": "node -pe \"require('./package.json').version\""
}
}
View parseSubdomain.js
export const subdomainRegex = new RegExp('^(([^.]*))', 'g')
export const parseSubdomain = hostname => (hostname || window.location.hostname).match(subdomainRegex)[0]
@andreasvirkus
andreasvirkus / movies-2019.sh
Last active Aug 21, 2019
List of movies I've seen per year
View movies-2019.sh
* 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 Mar 10, 2019
Service worker with progressive caching
View serviceWorker.js
'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 Mar 10, 2019
Dockerfile for static SPAs
View Dockerfile
# 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 . .
View curly-bracket.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View deviceIntel.js
export const gatherDeviceIntel = () => {
const header = [
navigator.platform,
navigator.userAgent,
navigator.appVersion,
navigator.vendor,
window.opera
]
const dataos = [
{ name: 'Windows Phone', value: 'Windows Phone', version: 'OS' },
You can’t perform that action at this time.