Skip to content

Instantly share code, notes, and snippets.

@denieler
denieler / service-worker-testing-script.ts
Created December 1, 2021 15:10
service-worker testing script
import { Workbox } from 'workbox-window'
const init = async () => {
console.log('update point - 15')
// console.log('sw controller:', navigator.serviceWorker.controller)
setInterval(async () => {
console.log('sw updated')
const registrations = await navigator.serviceWorker.getRegistrations()
import uuid from 'uuid/v4'
import DayCountExerciseType from '../repository/DayCountExerciseType'
import ExerciseType from '../repository/ExerciseType'
const DayCountExerciseTypes = DayCountExerciseType.getAll()
const ExerciseTypes = ExerciseType.getAll()
export const strongLifts5x5Program = {
_id: '1',
workout_iteration: 1,
@denieler
denieler / kadastr-api
Created May 19, 2020 19:45
Kadastr API
---------------------------
https://map.land.gov.ua/rrs/get-object-info
Request:
x, y, zoom, actLayers[]: kadastr
Response:
{
"parcel":[{
"koatuu":6821887500,
@denieler
denieler / data-test-id
Last active March 17, 2021 17:45
Data Test ID
Old test:
cy.visit('/email_messages')
cy.contains(FROM_EMAIL).click()
cy.findByRole('button', { name: 'Associate user' }).click()
cy.findByPlaceholderText('Type user name...').type(USER_NAME)
cy.findByRole('option', { name: new RegExp(USER_NAME) }).click()
cy.findByRole('button', { name: 'Select' }).click()
@denieler
denieler / pan.js
Created August 23, 2019 06:05
Make html element to be pannable (drag & drop)
import Sister from 'sister'
var dragStart,
dragMove,
dragEnd,
stopDrop
/**
* @param {HTMLElement} targetElement
*/
gifify
@denieler
denieler / convert-font-to-svg.sh
Created January 15, 2019 16:57
Convert Font to SVG files using FontForge
fontforge -lang=ff -c 'Open($1); SelectWorthOutputting(); foreach Export("svg"); endloop;' ~/Downloads/font.ttf
@denieler
denieler / test-utils.js
Created January 10, 2019 19:50
Custom render function for react-testing-library for jest snapshots with jss
import React from 'react'
import { render } from 'react-testing-library'
import JssProvider from 'react-jss/lib/JssProvider'
const generateClassName = (rule, styleSheet) =>
`${styleSheet.options.classNamePrefix}-${rule.key}`
const customRender = (node, options) => {
return render(
<JssProvider generateClassName={generateClassName}>
@denieler
denieler / array-deep-flatten.js
Created October 9, 2018 22:00
Array deep flatten implementation
Array.prototype.flatten = function () {
return this.reduce((list, x) => {
if (Array.isArray(x)) {
return list.concat(x.flatten())
} else {
return list.concat(x)
}
}, [])
}
@denieler
denieler / spacer-component.js
Last active October 4, 2018 08:08
Spacer component
import PropTypes from 'prop-types'
import styled from 'styled-components'
const Spacer = styled.div`
${props => (props.top ? 'margin-top: ' + props.top * 8 + 'px' : '')};
${props => (props.right ? 'margin-right: ' + props.right * 8 + 'px' : '')};
${props => (props.bottom ? 'margin-bottom: ' + props.bottom * 8 + 'px' : '')};
${props => (props.left ? 'margin-left: ' + props.left * 8 + 'px' : '')};
${props => (props.inline ? 'display: inline-block' : '')};
`