Skip to content

Instantly share code, notes, and snippets.

😶
boop

ajv andreasvirkus

View GitHub Profile
@andreasvirkus
andreasvirkus / movies-2019.md
Created Mar 19, 2019
List of movies I've seen per year
View movies-2019.md
  • Tracking as of 28th Jan (prolly missed ~5) *

A Star Is Born Spider-Man: Into the Spider-Verse Widows Immortal Machines 1+2 The Guilty Cam Searching

@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' },
View fizzbuzz.js
for (var i = 1; i <= 100; i++) console.log((i % 3 ? "" : "Fizz") + (i % 5 ? "" : "Buzz") || i)
View fizzbuzz.py
#!/usr/bin/env python
for x in range(1,101):
s = ""
if x % 3 == 0:
s += "Fizz"
if x % 5 == 0:
s += "Buzz"
if s == "":
s = x
View createRange.js
export const createRange = (len, zeroBased = true) =>
new Array(len).fill().map((_, i) => zeroBased ? i : i + 1)
@andreasvirkus
andreasvirkus / findParentByClass.js
Last active Dec 6, 2018
A simple loop that traverses the DOM tree until it finds a parent with the specified class.
View findParentByClass.js
export const findParentByClass = (el, className) => {
while (el.parentNode) {
el = el.parentNode
if (el.classList && el.classList.contains(className)) return el
}
return null
}
@andreasvirkus
andreasvirkus / DateMask.vue
Created Nov 23, 2018
Basic (and with a bit of a buggy UX) date mask input for Vue
View DateMask.vue
<template>
<div
class="q-date-mask"
@keyup.capture="updateValue">
<input
v-if="showDay"
ref="day"
v-model="day"
class="q-date-mask__input q-date-mask__input--day"
type="number"
You can’t perform that action at this time.