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 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 May 29, 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
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' },
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
}
You can’t perform that action at this time.